Contracts Reference
The @zk-privacy/eb-contracts package provides contract ABIs and deployment addresses.
Installation
npm install @zk-privacy/eb-contracts
Deployment Addresses
Base Mainnet (Chain ID: 8453)
import { DEPLOYMENTS, BASE_MAINNET } from '@zk-privacy/eb-contracts';
const baseDeployment = DEPLOYMENTS[8453];
const baseDeployment = BASE_MAINNET;
Get Deployment by Chain
import { getDeployment, RPC_URLS } from '@zk-privacy/eb-contracts';
const deployment = getDeployment(8453);
const rpcUrl = RPC_URLS[8453];
Contract ABIs
EBEMT (Main Token Contract)
import { EBEMT_ABI } from '@zk-privacy/eb-contracts';
const contract = getContract({
address: deployment.tokens.ebUSD,
abi: EBEMT_ABI,
client: publicClient,
});
const balance = await contract.read.encryptedBalances([compressedBpk]);
const owner = await contract.read.bpkOwner([compressedBpk]);
SwapRegistry (Atomic Swaps)
import { SWAP_REGISTRY_ABI } from '@zk-privacy/eb-contracts';
const swapContract = getContract({
address: deployment.swapRegistry,
abi: SWAP_REGISTRY_ABI,
client: publicClient,
});
const offer = await swapContract.read.offers([offerHash]);
Verifier Interface
import { VERIFIER_ABI } from '@zk-privacy/eb-contracts';
const verified = await verifierContract.read.verify([proofBytes, publicInputs]);
Types
import type { DeploymentAddresses } from '@zk-privacy/eb-contracts';
interface DeploymentAddresses {
tokens: Record<string, `0x${string}`>;
swapRegistry?: `0x${string}`;
relayerUrl?: string;
}
ABI Functions
EBEMT Functions
| Function | Type | Description |
|---|---|---|
encryptedBalances(bytes32) | read | Get encrypted balance for BPK |
balanceKeys(address) | read | Get BPK for EVM address |
bpkOwner(bytes32) | read | Get EVM address for BPK |
quorumPK() | read | Get compliance quorum public key |
stakeRoot() | read | Get current stake tree root |
registerBPK(uint256,uint256) | write | Register BPK |
shield(uint256,uint256,uint256) | write | Shield tokens |
transfer(bytes,bytes) | write | Private transfer |
unshield(bytes,bytes) | write | Unshield tokens |
stake(bytes,bytes) | write | Create L3 stake |
unstake(bytes,bytes) | write | Unstake from L3 |
SwapRegistry Functions
| Function | Type | Description |
|---|---|---|
offers(bytes32) | read | Get offer details |
createOffer(...) | write | Create swap offer |
cancelOffer(bytes32) | write | Cancel offer |
executeSwap(...) | write | Execute atomic swap |
Events
EBEMT Events
event Shield(bytes32 indexed compressedBpk, uint256 amount);
event Transfer(bytes32 indexed senderBpk, bytes32 indexed recipientBpk);
event Unshield(bytes32 indexed compressedBpk, address indexed recipient, uint256 amount);
event Stake(bytes32 indexed commitment, uint256 leafIndex);
event Unstake(bytes32 indexed nullifier, bytes32 indexed recipientBpk);
SwapRegistry Events
event OfferCreated(bytes32 indexed offerHash, address indexed maker);
event SwapExecuted(bytes32 indexed offerHash, address indexed taker);