Useful Commands
These commands use Foundry's cast to interact with Ghost Protocol contracts.
Network Commands
# Check current block
cast block-number --rpc-url https://testnet-rpc.umbraline.com
# Check chain ID
cast chain-id --rpc-url https://testnet-rpc.umbraline.com
# Get block details
cast block latest --rpc-url https://testnet-rpc.umbraline.com
CommitmentTree Commands
# Check commitment 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 a root is valid
cast call 0xe382a7C7a5CE3B9250D73aE6ab97931E5798e6F7 "isKnownRoot(bytes32)(bool)" \
<root> \
--rpc-url https://testnet-rpc.umbraline.com
NullifierRegistry Commands
# Check if nullifier is spent
cast call 0x03972E4453fD143A5203602020DbE2f7DcF6e0db "isSpent(bytes32)(bool)" \
<nullifier> \
--rpc-url https://testnet-rpc.umbraline.com
GhostVault Commands
# Get commitment fee
cast call 0x9A8F98916d324153B61F1C4B6D7d85F52988b3b1 "COMMITMENT_FEE()(uint256)" \
--rpc-url https://testnet-rpc.umbraline.com
# Commit (send transaction)
cast send 0x9A8F98916d324153B61F1C4B6D7d85F52988b3b1 \
"commit(bytes32)" <commitment> \
--value 0.001ether \
--private-key <your-key> \
--rpc-url https://testnet-rpc.umbraline.com \
--legacy
Account Commands
# Check GHOST balance
cast balance <address> --rpc-url https://testnet-rpc.umbraline.com
# Check balance in ether units
cast balance <address> --rpc-url https://testnet-rpc.umbraline.com -e
Transaction Commands
# Get transaction details
cast tx <tx-hash> --rpc-url https://testnet-rpc.umbraline.com
# Get transaction receipt
cast receipt <tx-hash> --rpc-url https://testnet-rpc.umbraline.com
# Decode revert reason
cast call <contract> "<function>" <args> \
--rpc-url https://testnet-rpc.umbraline.com 2>&1 | cast --to-ascii
Contract Addresses
For quick copy-paste:
# GhostVault
export VAULT=0x9A8F98916d324153B61F1C4B6D7d85F52988b3b1
# CommitmentTree
export TREE=0xe382a7C7a5CE3B9250D73aE6ab97931E5798e6F7
# NullifierRegistry
export REGISTRY=0x03972E4453fD143A5203602020DbE2f7DcF6e0db
# ProofVerifier
export VERIFIER=0x2Bc0ac5508FF31A0Ad055A1F823C7653F48D37bE
Debugging Tips
Transaction Reverted?
- Check the error code - See Error Codes for meanings
- Simulate first - Use
cast callbeforecast sendto see revert reason - Check balance - Ensure sufficient GHOST for gas + commitment fee
Nullifier Already Spent?
cast call 0x03972E4453fD143A5203602020DbE2f7DcF6e0db "isSpent(bytes32)(bool)" \
<your-nullifier> \
--rpc-url https://testnet-rpc.umbraline.com
If true, this commitment was already revealed.
Root Not Valid?
cast call 0xe382a7C7a5CE3B9250D73aE6ab97931E5798e6F7 "isKnownRoot(bytes32)(bool)" \
<your-root> \
--rpc-url https://testnet-rpc.umbraline.com
If false, the root is stale (>100 updates ago). Generate a fresh proof.