Skip to main content
Version: Next

Function: strk20SubaccountCommitment()

strk20SubaccountCommitment(walletWSF, dapp_name, nonce?): Promise<string>

Defined in: src/wallet/connectV6.ts:199

Compute the commitment of a DAPP STRK20 sub-account. The commitment is computed locally by the wallet from the user private state ; no transaction is sent.

When nonce is given, the full commitment of this single sub-account is returned. When nonce is omitted, the partial (nonce independent) commitment is returned instead : it is shared by every sub-account the user derives for this DAPP, so it can be published once to let a DAPP recognize all the sub-accounts of a user without learning any individual nonce.

Parameters

walletWSF

WalletWithStarknetFeatures

The get-starknet V6 wallet object to use.

dapp_name

string

The DAPP that scopes the sub-account(s).

nonce?

string

The sub-account nonce ; each nonce selects a distinct sub-account for this user + DAPP. Omit it to get the partial commitment.

Returns

Promise<string>

The sub-account commitment.

Example

const commitment = await strk20SubaccountCommitment(walletWSF, 'myDapp', '0x0');
// commitment = '0x5f2e...'