Skip to main content

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

FunctionTypeDescription
encryptedBalances(bytes32)readGet encrypted balance for BPK
balanceKeys(address)readGet BPK for EVM address
bpkOwner(bytes32)readGet EVM address for BPK
quorumPK()readGet compliance quorum public key
stakeRoot()readGet current stake tree root
registerBPK(uint256,uint256)writeRegister BPK
shield(uint256,uint256,uint256)writeShield tokens
transfer(bytes,bytes)writePrivate transfer
unshield(bytes,bytes)writeUnshield tokens
stake(bytes,bytes)writeCreate L3 stake
unstake(bytes,bytes)writeUnstake from L3

SwapRegistry Functions

FunctionTypeDescription
offers(bytes32)readGet offer details
createOffer(...)writeCreate swap offer
cancelOffer(bytes32)writeCancel offer
executeSwap(...)writeExecute 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);