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
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name (max 32 bytes on-chain) |
uri | string | Yes | Profile metadata URI (max 200 bytes on-chain) |
owner | PublicKey | No | Defaults to the connected wallet |
agentIdentity | PublicKey | No | 8004 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
| Getter | Type | Description |
|---|---|---|
Loaded | boolean | Whether the account has been fetched |
User | PacketUser | Raw account data (throws if not loaded) |
address | PublicKey | On-chain account address |
name | string | Display name |
uri | string | Metadata URI |
agent | PublicKey | null | Linked 8004 agent, or null |
PacketUser type
type PacketUser = {
address: PublicKey;
owner: PublicKey;
name: string;
uri: string;
agent: PublicKey | null;
};