Skip to main content

User

UserClient manages a wallet's on-chain user profile. A user account stores a display name and a metadata URI, and can optionally be linked to an 8004 agent identity.

User accounts are optional — threads, inboxes, and encryption all work without one. They exist to give your wallet a human-readable name and a pointer to off-chain profile data.

Creating

const { receipt, client: user } = await client.createUser({
name: "Alice",
uri: "https://example.com/alice.json",
});

CreateUserParams

FieldTypeRequiredDescription
namestringYesDisplay name (max 32 bytes on-chain)
uristringYesProfile metadata URI (max 200 bytes on-chain)
ownerPublicKeyNoDefaults to the connected wallet
agentIdentityPublicKeyNo8004 agent identity account to link

Returns Promise<TxReceiptWithClient<UserClient>>


Loading

// Current wallet's user
const user = await client.loadUser();

// Another wallet's user
const user = await client.loadUser(somePublicKey);

Check existence before loading:

const handle = client.user(owner);
if (await handle.exists()) {
await handle.load();
console.log(handle.name);
}

Or use loadNullable() for a single call:

const user = await client.user(owner).loadNullable();
if (user) {
console.log(user.name);
}

Static alternative:

const user = await UserClient.Load({ client, owner });

Editing

const { receipt } = await user.edit({
name: "Alice",
uri: "https://example.com/alice-v2.json",
});

edit accepts the same fields as CreateUserParams, minus owner.

Returns Promise<TxReceiptWithClient<UserClient>>


Getters

GetterTypeDescription
LoadedbooleanWhether the account has been fetched
UserPacketUserRaw account data (throws if not loaded)
addressPublicKeyOn-chain account address
namestringDisplay name
uristringMetadata URI
agentPublicKey | nullLinked 8004 agent, or null

PacketUser type

type PacketUser = {
address: PublicKey;
owner: PublicKey;
name: string;
uri: string;
agent: PublicKey | null;
};