Accounts and transfers
The transcripts below were captured on a local devnet (Before you start) at d81e637aa, except the public dry run, captured on a standalone sequencer. Your ids and heights will differ, and the heights here jump where the session paused. Three things are shortened: the Transaction data is … line every send prints (tens of thousands of characters; SUPPRESS_VERBOSE_PRINTS turns it off), viewing keys (1184 bytes, cut with …), and repeated account ids in commands (7VDm7YRP...). The first-run password prompts and recovery phrase are left out.
Making accounts
A wallet with no store sets one up on the first command, and starts synced at the chain tip rather than at genesis:
$ wallet account import public --secret 10a26a9aec7d34b82364eeae45c5294dbb0a764b000b94eeb9b58511dc487c4d
Persistent storage not found, need to execute setup
New wallet starts synced at block 22
Imported public account Public/7VDm7YRPvimbZgCzuFqCGf6RwPsTV3XY5W9DzT71oain
That secret is one of the two the wallet-import-test-accounts recipe in the Justfile imports. It changes with the devnet’s genesis, so take it from the recipe. On a local devnet it is where your first tokens come from. Nothing before block 22 is scanned; Reading the chain covers the ways back.
$ wallet account new public --label alice
Generated new account with account_id Public/2wVCroZMktk9AiXnoum4zhZABxrGrFNfH2sMbQPigMUK at path /0
With initial key 000b801cd3c10935026199bfe4714b96c7835626a6c51ae166bcbff30af6ca37de
$ wallet account new private --label bob-private
Generated new account with account_id Private/YeJGB32itVaAGNBDWRCWsbYDgYkjuM8ck16SaRJDtKq at path /0
With npk 7972829f024b2d557461b1c9327af5df3cc1b722da26dc44749c5eca80e39690
With vpk 9cf468cf5c4cd2014226e804179…
$ wallet account list
Public/7VDm7YRPvimbZgCzuFqCGf6RwPsTV3XY5W9DzT71oain
/0 Public/2wVCroZMktk9AiXnoum4zhZABxrGrFNfH2sMbQPigMUK [alice]
/ Public/CQTkqXve5aZDXdS3SaLJeYXTWCvbtFTNmYw7Ube4eDjA
/ Private/93tFbzLqybuNUAsEE9TajiZ9F2pjnPVdizmiuWziyDCK
/0 Private/YeJGB32itVaAGNBDWRCWsbYDgYkjuM8ck16SaRJDtKq [bob-private]
The leading token is the derivation path the account came from, blank for an imported key. A label is unique across the wallet and works in --from, --to and --account-id, but not in --fee-payer or --refund-to, which take ids (global flags). A public account’s id is derived from its initial key, the key for nonce 0; the wallet signs each later nonce with a new key from the same secret (Keys, nonces and rotation). The first payment to an unused public account must carry that key: the wallet attaches it for an account it holds, and --to-initial-key attaches it for someone else’s (Admission).
Sending
wallet auth-transfer send --from <account> --amount <n> <recipient flags>
| Recipient | Flag | What it takes |
|---|---|---|
| Any public account, or a private one this wallet owns | --to | a base58 account id with its Public/ or Private/ prefix, or a label. A Public/ id needs no ownership; a Private/ one does, because the wallet has to prove the account’s current state, which only its keys open |
| Someone else’s private account | --to-npk and --to-vpk | the nullifier public key as 32-byte hex, and the ML-KEM-768 viewing key as hex, 1184 bytes |
| Someone else’s private account, from a file | --to-keys | a path to a keys file holding npk and vpk on separate lines. Replaces the two flags above |
| A public account that has never been used | --to-initial-key | the recipient’s initial key |
--from and --amount are always required. --to-keys conflicts with --to-npk and --to-vpk, and --to-initial-key conflicts with all the others, both enforced by the argument parser. --to together with --to-keys, or with both --to-npk and --to-vpk, fails later, when the recipient is resolved: Provide only one variant: either account account_id of receiver or their public keys. Use --to for an account this wallet owns, and the keys for anyone else’s.
--to takes a value starting m/ as a Keycard key path, which this version refuses, and anything that is not a prefixed id as a label, so a /0 copied out of account list fails with No account found for label `/0`.
Pricing it first
Any command takes --dry-run, which simulates and reports instead of sending. For a public transaction:
$ wallet --dry-run auth-transfer send --from Public/7VDm7YRPvimbZgCzuFqCGf6RwPsTV3XY5W9DzT71oain --to alice --amount 500000
Dry run: nothing sent
fee payer: 7VDm7YRPvimbZgCzuFqCGf6RwPsTV3XY5W9DzT71oain
declared gas: 0
metered cycles: 0
wire bytes: 621
base fees: exec 8 / stor 8 (height 3)
fee at head: 4968 (tip 0)
reserve at head: 4968 (max fee 8073)
signer authority: 7VDm7YRPvimbZgCzuFqCGf6RwPsTV3XY5W9DzT71oain under 11111111111111111111111111111111
action: applies
action is the line to read: it says applies, or REVERTS with a reason, and a reverting transaction still pays. --allow-revert sends one anyway. Only a transaction a public signer pays gets the line; a private send whose public part fails in its simulation ends with that error instead. A private dry run that passes can still revert at settlement, which runs against live state under a lower cycle cap (Three runs of one engine). signer authority names the actor the signature authorizes and its program: 11111111111111111111111111111111 is the native token’s id (32 zero bytes in base58), so this is the payer’s native balance.
Public to public
One transaction, no proof:
$ wallet auth-transfer send --from Public/7VDm7YRPvimbZgCzuFqCGf6RwPsTV3XY5W9DzT71oain --to alice --amount 500000
Transaction hash is f08765ec784e5ef6ff0794bdec54c7ba2d384c5e163e8be4fdb6e3a43852e62a
Transaction is included in block 23
$ wallet account get --scope balance --account-id alice
Label: alice
Balance 500000, nonce 0
Alice’s nonce stays 0 because only the accounts that signed advance it, and she only received.
Shielding into a private account you own
A shield moves tokens from a public account into a private one; a deshield moves them out of a private account into a public one. Both are privacy-preserving transactions, which take longer and cost more. Price it first, and name who pays:
$ wallet --dry-run auth-transfer send --from Public/7VDm7YRP... --to bob-private --amount 20000000 --fee-payer Public/7VDm7YRP...
Dry run: nothing sent
fee payer: 7VDm7YRPvimbZgCzuFqCGf6RwPsTV3XY5W9DzT71oain
declared gas: 409764
metered cycles: 0
wire bytes: 235661
base fees: exec 8 / stor 8 (height 25)
fee at head: 5163400 (tip 0)
reserve at head: 5163400 (max fee 8390525)
signer authority: 7VDm7YRPvimbZgCzuFqCGf6RwPsTV3XY5W9DzT71oain under 11111111111111111111111111111111
action: applies
--fee-payer decides who pays, and takes a prefixed id. Left out, the wallet takes the first of these that exists:
- an owned private account that holds the fee, whether the transaction mentions it or not;
- the first owned private account the transaction mentions, paying out of what the transaction credits it, unless the transaction has a public part that can fail (a shield does) or the credit falls short;
- the best funded public signer.
This shield would get the public signer anyway (bob-private is still empty); the commands here name it explicitly. Name the payer when it matters which.
Public/<id> has the public signer declare and pay the fee, usually what you want when shielding: the private account you are paying into does not exist yet and holds nothing.
Private/<id> has an owned private account pay from inside the proof. For a shield it must already hold the fee: the fee fallback that pays if the shield’s public part fails has to fit in what the account held before, so the wallet refuses up front: Fee payer <id> holds 0, short of the fee of 5174824: fund it first, or have a public signer pay the fee. Collecting a stored message is the exception; the next section shows why.
fee at head is the fee at the current base fees, reserve at head is the amount held, and max fee is the cap after headroom (How fees are priced). --fee-headroom moves the cap, --max-fee sets it, and --tip adds to the fee.
$ wallet auth-transfer send --from Public/7VDm7YRP... --to bob-private --amount 20000000 --fee-payer Public/7VDm7YRP...
Transaction hash is e0e69ea0e1dfe01ad2bcba1b587b73783fc93592d69c1e91cc149ef9d7bea79a
Transaction is included in block 28
$ wallet account sync-private --yes
Latest block is 29
Syncing to block 29. Blocks to sync: 5
Synced to block 29 in 45.763916ms
$ wallet account get --scope balance --account-id bob-private
Label: bob-private
Balance 20000000, nonce 54714446476954508813235880172123505360
The full 20,000,000 arrives because the public signer paid the fee from its own balance, not from the credit. Had a private account paid, the balance would be the amount less its reserve.
Sync before reading a private account, whose nonce is a hash, not a counter (Reading the chain). --yes answers the prompt the sync shows whenever there are blocks to scan; a script never blocks on it, because the confirmation returns true when not attached to a terminal.
Paying a private account you do not own
The recipient exports their keys in their own wallet:
$ wallet account show-keys --account-id Private/265rYQM792Z5G2Fzf7jRTgmCZTnT2CzCA5a3stjBRY1W
a8046f9bc12ee0d4f0ff91dcb09f65289e165edeb40cd9f283ee2a3cd73bfa72
f0107e0a183184fac624394d3bf826c0b70e9ce23e84410244079e27778bcb48…
Two lines, npk then vpk, 64 and 2368 hex characters. Redirect it to a file and send that file to whoever is paying you; it is what --to-keys takes. show-keys works only for private accounts.
A private account id is SHA256(prefix ‖ npk ‖ vpk), so one key pair is exactly one regular private account, with no identifier to choose.
The sender pays as before, with the public signer covering the fee:
$ wallet auth-transfer send --from Public/7VDm7YRP... --to-keys dave.keys --amount 20000000 --fee-payer Public/7VDm7YRP...
Transaction hash is 52cad0d899c6df1dd4ebad96312dc3f48f318072427158f26b74dba28122f65d
Transaction is included in block 36
Only a holder of the account’s keys can produce the proof that advances it, so the credit is stored on chain (Pending messages). The recipient collects it:
$ wallet pending list
Latest block is 37
Syncing to block 37. Blocks to sync: 2
Synced to block 37 in 22.572667ms
Message 19: to 265rYQM792Z5G2Fzf7jRTgmCZTnT2CzCA5a3stjBRY1W at program 11111111111111111111111111111111, from 7VDm7YRPvimbZgCzuFqCGf6RwPsTV3XY5W9DzT71oain at program 11111111111111111111111111111111, 17 bytes
$ wallet pending receive --position 19 --fee-payer Private/265rYQM792Z5G2Fzf7jRTgmCZTnT2CzCA5a3stjBRY1W
Latest block is 37
Transaction hash is 93a1598c3222ff4adca90c51b59651ea7f6ddf152cb24c8a7df17a94ba3c696c
Transaction is included in block 38
$ wallet account sync-private --yes
Latest block is 39
Syncing to block 39. Blocks to sync: 2
Synced to block 39 in 18.735208ms
$ wallet account get --scope balance --account-id Private/265rYQM792Z5G2Fzf7jRTgmCZTnT2CzCA5a3stjBRY1W
Label: dave
Balance 14829672, nonce 296197159399728484730127573470210145222
Dave’s account held nothing and still paid its own fee: 20,000,000 less its reserve of 5,170,328 is 14,829,672. The reserve is the fee at head here, because the wallet reserves no more than the payer held before the root (nothing) and never less than the fee at head; what happens to a surplus is in Private fees. The fee runs after the transaction’s root, here the collected message, so its credit is already in the account. A shield’s credit is there too, but its public part can fail, so the wallet keeps its reserve within what the payer held before; a collection does nothing publicly except pay the fee, so the wallet lets the payer pay out of what it receives.
--position takes the number pending list prints, the message’s leaf position in the commitment tree, shared with account commitments. It is not an index into your own list, so the first message you are shown is almost never at position 0, and one that is not yours, or that you already collected, fails with No pending message at this position.
So a payment to a stranger usually costs two fees, one on each side; here the recipient’s came out of what they were sent. A credit swept into a later private send of theirs costs no extra fee.
Reading the result
wallet account get --scope balance --account-id Public/<id>
wallet account sync-private --yes
wallet account get --scope balance --account-id Private/<id>
Reading the chain covers the rest.