This page defines the words that the API uses.
A private balance is a set of notes. A note has a token, a value, and an
owner. The RAILGUN contract stores only the commitment of each note, in a
merkle tree. A tree holds 65,536 commitments. A commitment has a
treeNumber (which tree) and a leafIndex (the position in that tree).
When a wallet spends a note, the transaction publishes the nullifier of the note. The nullifier marks the note as spent. Nobody can link the nullifier to the commitment without the keys of the wallet.
getNotes() returns the decrypted notes of a wallet as DecryptedNote rows.
One mnemonic and one index give a set of keys:
loadWallet does not return it.The 0zk address (0zk1...) encodes the master public key and the viewing
public key. Senders use it to make notes for the wallet.
| Operation | From | To | Proof | Method |
|---|---|---|---|---|
| Shield | Public 0x account |
0zk address | No | shield, buildShield |
| Transfer | 0zk wallet | 0zk address | Yes | transfer, buildTransfer |
| Unshield | 0zk wallet | Public 0x address |
Yes | unshield, buildUnshield |
Each operation has two forms:
buildX() returns an unsigned transaction. It does not sign or send.x() builds, signs with a viem WalletClient, sends, and parses the
receipt.Transfer and unshield make a Groth16 proof. Give the client a prover, and
give each call a loadArtifact function for the circuit artifacts.
Sync has two steps:
sync() runs both steps.
On some networks, a note must have a Private Proof of Innocence (PPOI) before the wallet can spend it. A PPOI node tells the wallet the status of each note for each required list. The SDK puts each note into one WalletBalanceBucket:
| Bucket | Meaning |
|---|---|
Spendable |
The wallet can spend the note. |
ShieldPending |
A shielded note is not Valid on each required list yet. |
ShieldBlocked |
A required list blocked the note. |
ProofSubmitted |
A proof is submitted. The node did not validate it yet. |
MissingInternalPOI |
A change note (the wallet paid itself) has no PPOI. |
MissingExternalPOI |
A note from another wallet has no PPOI. |
Spent |
The note is spent. |
transfer and unshield spend only Spendable notes. After a transfer or
an unshield, call sync() and then
submitPoi() with each railgunTxid
from the result.