Skip to main content

Contract ABIs

ABIs for the essential Ghost Protocol contract functions.

GhostVault ABI

const VAULT_ABI = [
{
name: 'commit',
type: 'function',
inputs: [{ name: 'commitment', type: 'bytes32' }],
outputs: [{ name: 'leafIndex', type: 'uint256' }],
stateMutability: 'payable',
},
{
name: 'commitWithCallback',
type: 'function',
inputs: [
{ name: 'commitment', type: 'bytes32' },
{ name: 'application', type: 'address' },
{ name: 'data', type: 'bytes' },
],
outputs: [{ name: 'leafIndex', type: 'uint256' }],
stateMutability: 'payable',
},
{
name: 'verifyAndNullify',
type: 'function',
inputs: [
{ name: 'proof', type: 'tuple', components: [
{ name: 'a', type: 'uint256[2]' },
{ name: 'b', type: 'uint256[2][2]' },
{ name: 'c', type: 'uint256[2]' },
]},
{ name: 'nullifier', type: 'bytes32' },
{ name: 'root', type: 'bytes32' },
{ name: 'dataHash', type: 'bytes32' },
{ name: 'recipient', type: 'address' },
],
outputs: [{ name: 'valid', type: 'bool' }],
stateMutability: 'nonpayable',
},
{
name: 'revealWithCallback',
type: 'function',
inputs: [
{ name: 'proof', type: 'tuple', components: [
{ name: 'a', type: 'uint256[2]' },
{ name: 'b', type: 'uint256[2][2]' },
{ name: 'c', type: 'uint256[2]' },
]},
{ name: 'nullifier', type: 'bytes32' },
{ name: 'root', type: 'bytes32' },
{ name: 'application', type: 'address' },
{ name: 'data', type: 'bytes' },
{ name: 'recipient', type: 'address' },
],
outputs: [{ name: 'valid', type: 'bool' }],
stateMutability: 'nonpayable',
},
{
name: 'Committed',
type: 'event',
inputs: [
{ name: 'commitment', type: 'bytes32', indexed: true },
{ name: 'leafIndex', type: 'uint256', indexed: true },
{ name: 'timestamp', type: 'uint256', indexed: false },
],
},
{
name: 'Revealed',
type: 'event',
inputs: [
{ name: 'nullifier', type: 'bytes32', indexed: true },
{ name: 'dataHash', type: 'bytes32', indexed: true },
{ name: 'recipient', type: 'address', indexed: true },
],
},
];

CommitmentTree ABI

const TREE_ABI = [
{
name: 'leafCount',
type: 'function',
inputs: [],
outputs: [{ name: '', type: 'uint256' }],
stateMutability: 'view',
},
{
name: 'currentRoot',
type: 'function',
inputs: [],
outputs: [{ name: '', type: 'bytes32' }],
stateMutability: 'view',
},
{
name: 'isKnownRoot',
type: 'function',
inputs: [{ name: 'root', type: 'bytes32' }],
outputs: [{ name: '', type: 'bool' }],
stateMutability: 'view',
},
];

NullifierRegistry ABI

const REGISTRY_ABI = [
{
name: 'isSpent',
type: 'function',
inputs: [{ name: 'nullifier', type: 'bytes32' }],
outputs: [{ name: '', type: 'bool' }],
stateMutability: 'view',
},
];

Usage with viem

import { createPublicClient, http } from 'viem';

const publicClient = createPublicClient({
transport: http('https://testnet-rpc.umbraline.com'),
});

// Read leaf count
const leafCount = await publicClient.readContract({
address: '0xe382a7C7a5CE3B9250D73aE6ab97931E5798e6F7',
abi: TREE_ABI,
functionName: 'leafCount',
});

// Check if nullifier is spent
const isSpent = await publicClient.readContract({
address: '0x03972E4453fD143A5203602020DbE2f7DcF6e0db',
abi: REGISTRY_ABI,
functionName: 'isSpent',
args: [nullifier],
});

Contract Addresses

const CONTRACTS = {
vault: '0x9A8F98916d324153B61F1C4B6D7d85F52988b3b1',
tree: '0xe382a7C7a5CE3B9250D73aE6ab97931E5798e6F7',
registry: '0x03972E4453fD143A5203602020DbE2f7DcF6e0db',
verifier: '0x2Bc0ac5508FF31A0Ad055A1F823C7653F48D37bE',
};