Skip to main content

CommitmentTree

The CommitmentTree stores all commitments in a Merkle tree and manages root history.

Address: 0xe382a7C7a5CE3B9250D73aE6ab97931E5798e6F7

Constants

ConstantValueMeaning
TREE_DEPTH20Max 1,048,576 commitments
ROOT_HISTORY_SIZE100Last 100 roots are valid
MIN_COMMITMENT_FEE0.001 etherRequired commit fee
MAX_COMMITS_PER_BLOCK10Per-address rate limit

Read Functions

leafCount

Returns the number of commitments in the tree.

function leafCount() external view returns (uint256);

currentRoot

Returns the current Merkle root.

function currentRoot() external view returns (bytes32);

isKnownRoot

Check if a root is in the last 100 roots.

function isKnownRoot(bytes32 root) external view returns (bool);

Events

event CommitmentAdded(bytes32 indexed commitment, uint256 indexed leafIndex, uint256 timestamp);
event RootUpdated(bytes32 indexed oldRoot, bytes32 indexed newRoot, uint256 leafCount);
event RootOperatorChanged(address indexed oldOperator, address indexed newOperator);
event FeesWithdrawn(address indexed operator, uint256 amount);

Root History

The tree maintains a rolling history of the last 100 roots. When generating proofs, you must use a root that is in this history.

Stale Roots

If your proof uses a root older than 100 updates ago, the reveal will fail with InvalidRoot. Generate proofs with recent roots.

Useful Commands

# Get current leaf count
cast call 0xe382a7C7a5CE3B9250D73aE6ab97931E5798e6F7 "leafCount()(uint256)" \
--rpc-url https://testnet-rpc.umbraline.com

# Get current root
cast call 0xe382a7C7a5CE3B9250D73aE6ab97931E5798e6F7 "currentRoot()(bytes32)" \
--rpc-url https://testnet-rpc.umbraline.com

# Check if root is valid
cast call 0xe382a7C7a5CE3B9250D73aE6ab97931E5798e6F7 "isKnownRoot(bytes32)(bool)" <root> \
--rpc-url https://testnet-rpc.umbraline.com