Skip to main content

Creating UTXOs

UTXOs are the fundamental building blocks for private transactions. Each UTXO represents an unspent output with an amount and cryptographic commitments.

Empty UTXO

Create an empty UTXO (used as placeholder in transactions):

UTXO with Amount

Create a UTXO with a specific amount:

SPL Token UTXO

Create a UTXO for SPL tokens:

UTXO Properties

Access UTXO properties:

Generating Commitments

Commitments are Poseidon hashes that hide UTXO details while allowing verification:
The commitment formula:

Generating Nullifiers

Nullifiers mark UTXOs as spent, preventing double-spending:
The nullifier formula:
Nullifiers are unique per UTXO and must be tracked to prevent double-spending.

Building Merkle Trees

Merkle trees track all commitments in the privacy pool:

Merkle Path Structure

From test files at ~/workspace/source/anchor/tests/sol_tests.ts:966-982:

Calculating External Data Hash

The external data hash binds transaction metadata to the proof:

External Data Structure

Generating Zero-Knowledge Proofs

Proofs verify transaction validity without revealing details:

Parse Proof for On-Chain Submission

From test files at ~/workspace/source/anchor/tests/sol_tests.ts:772-791:

Calculating Fees

Fee calculation from test files at ~/workspace/source/anchor/tests/sol_tests.ts:22-38:

Finding Program-Derived Addresses

Nullifier accounts use PDAs to prevent double-spending:
The cross-check nullifiers prevent attackers from reusing the same UTXO in different input positions.

Constants and Configuration

From ~/workspace/source/anchor/tests/lib/constants.ts:

Next Steps

Examples

View complete transaction examples

API Reference

Explore detailed API documentation