PintSwap Docs


Methods used to customize an account's data including username, biography, and profile image.

Get Pint Peer Address

Returns the pint address for the PintSwap PeerId
A pint address is an encoding of the underlying libp2p multihash, converted to bech32 with a pint prefix.
const pintAddress = pintswap.address;
// pint1zgsw52stcg9kgy4y6qvl3rpu0dzwzdcy9m3yy4mdnfm22c5ht90jh8qtvlwzh

Assign Username

await pintswap.registerName(name)
Uses the /pintswap/0.1.0/ns/register protocol handler.
Registers a name on the PintSwap nameservers. Currently, only .drip nameservers are available for registration, however there are plans to increase options. The nameserver this request is routed to depends on the table stored in NS_MULTIADDRS exported by @pintswap/sdk
await pintswap.registerName('wock.drip');
//{ status: 0 }
The default pintswap-ns implementation requires that you retain custody of your PeerId for as long as you wish to use the name registered. If the PeerId is lost, the name cannot be released unless nameserver operators release it intentionally.

Assign Profile Picture

Registers an image per peer that is used as the peer's profile picture. It is important to note that an array buffer must be passed into the parameters of this method.
An implementation of the following can be found below that is used as the event handler for a <input type="file" />:
async function handleImageChange(e?: ChangeEventHandler<HTMLInputElement>) {
const image = ( as any)[0] ?? null;
const buffer = Buffer.from(await image.arrayBuffer());

Assign Biography

pintswap.setBio(bio: string)
Registers a biography for the connected peer.