Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

registerUser

Create a new user and their first account in a single transaction. Submitted by the account factory itself (sender-less from the caller's perspective).

Registration requires a pre-existing deposit (≥ min_deposit) sent to the factory, a signed RegisterUserData proving control of the public key, and a chain id binding. If referrer is provided, the factory atomically forwards a SetReferral to the perps contract. The username on the new user record is immutable once set. See protocol book: overview/3-dango-contracts §3.

Signature

function registerUser(
  client: Client<Signer | undefined>,
  parameters: {
    key: Key
    keyHash: KeyHash
    seed: number
    signature: Signature
    referrer?: number
  },
): Promise<{ hash: Uint8Array } & TxData>

Example

import { createSignerClient, createTransport, testnet, PrivateKeySigner } from "@left-curve/sdk"
 
const signer = PrivateKeySigner.fromRandomKey()
const client = createSignerClient({
  chain: testnet,
  transport: createTransport(),
  signer,
})
 
// Build the signature off-band per the chain's registration protocol.
await client.registerUser({
  key: { secp256k1: "base64-encoded-pubkey" },
  keyHash: await signer.getKeyHash(),
  seed: 1,
  signature: { secp256k1: "base64-signature" },
})

Parameters

keyKey. The public key to register ({ secp256k1 }, { secp256r1 }, or { ethereum }).

keyHashKeyHash. SHA-256 of the public key, uppercase hex.

seednumber. Salt input — see createAccountSalt.

signatureSignature. Signature proving control of the key.

referrernumber, optional. Referrer's user index.

Returns

{ hash: Uint8Array } & TxData — see broadcastTxSync.

Notes

  • Unlike normal mutations, registerUser is submitted by the account factory contract itself. The action calls simulate for gas and broadcasts an unsigned tx (the contract is its own credential).
  • Exactly one RegisterUser message is allowed per transaction (anti-batching constraint).
  • Nonce jump on the resulting account is limited to 100 to bound the seen-nonce set.

See also