registerAccount
Register an additional account for an existing user.
Each user has a BTreeMap<AccountIndex, Addr> of up to 5 accounts; this
action mints the next one and (optionally) seeds it with funds. The new
account's address can be computed deterministically ahead of time. See
protocol book: overview/3-dango-contracts §3.
Signature
function registerAccount(
client: Client<Signer>,
parameters: {
sender: Address
funds?: Funds
},
txParameters?: { gasLimit?: number },
): Promise<{ hash: Uint8Array } & TxData>Example
import { createSignerClient, createTransport, testnet, PrivateKeySigner } from "@left-curve/sdk"
import type { Address } from "@left-curve/sdk"
const client = createSignerClient({
chain: testnet,
transport: createTransport(),
signer: PrivateKeySigner.fromMnemonic(process.env.DANGO_MNEMONIC!),
})
const sender: Address = "0x1234567890abcdef1234567890abcdef12345678"
await client.registerAccount({ sender }, { gasLimit: 250_000 })Parameters
sender — Address. An existing account of the user.
funds — Funds, optional. Initial coins to send into the new account.
txParameters — { gasLimit?: number }, optional. Positional second argument used by the action builder to forward gas overrides.
Returns
{ hash: Uint8Array } & TxData — see broadcastTxSync.
Notes
- The action builder accepts
txParametersas a positional second argument, not as a field on the first parameter. This is unique among mutations. - The new account address can be derived ahead of time via
getNextAccountIndex+computeAddress. - Rejected if the user already owns 5 accounts (the per-user cap).