Skip to content

API Reference

function initCore(): Promise<void>
function initWasm(): Promise<void>
function initGaraga(): Promise<void>
function hash2(a: string, b: string): Promise<string>
function hash2Sync(a: string, b: string): string
function hash3(a: string, b: string, c: string): Promise<string>
function hash3Sync(a: string, b: string, c: string): string
function txSecret(key: string, to: string): string
function hash_with_asset(secret: string, asset: string, amount: string): string
function txHash(key: string, owner: string, tokenAddr: string, amount: string): bigint
function generateClaimingKey(): string
function prove_groth16(witness: Witness): Promise<ProofResponse>
function full_prove(witness: Witness): Promise<bigint[]>
const FIXTURES: {
witness: Witness
proof: string
verifyingKey: string
}
function calculateMerkleRoot(
leaves: bigint[],
hasher?: (a: bigint, b: bigint) => bigint,
leafFilter?: (leaf: bigint) => bigint
): bigint
function calculateMerkleRootAndProof(
leaves: bigint[],
index: number,
hasher?: (a: bigint, b: bigint) => bigint,
leafFilter?: (leaf: bigint) => bigint
): bigint[]
function merkleRootFromPath(
element: bigint,
path: bigint[],
hasher?: (a: bigint, b: bigint) => bigint,
leafFilter?: (leaf: bigint) => bigint
): bigint
function get_next_level(
tree: bigint[],
hasher?: (a: bigint, b: bigint) => bigint
): bigint[]
function merkleHasher(left: bigint, right: bigint): bigint
function evenLeafFilter(leaf: bigint): bigint
function getChamber(provider?: ProviderInterface): ChamberTypedContract
function fetchTxAssets(
contract: ChamberTypedContract,
valKey: string,
valTo: string
): Promise<Asset>
function checkTxExists(
contract: ChamberTypedContract,
valKey: string,
valTo: string,
tokenAddr: string,
amount: string
): Promise<boolean>
function getTxIndexInTree(
leaves: bigint[],
valKey: string,
valTo: string,
tokenAddr: string,
amount: string
): Promise<number>
function fmtAmount(amount: bigint, decimals: number): string
function fmtAmtToBigInt(amountStr: string, decimals: number): bigint
function getHashParams(): Record<string, string>
function devVal<T>(val: T, defaultVal?: T): T
function devStr(val: string): string

const CHAMBER_ADDR_MAINNET: string
const CHAMBER_ABI: Abi
const ERC20_ABI: Abi
const tokensData: Token[]
const tokensMap: Record<string, Token>
const tokenNamesMap: Record<string, Token>
interface Token {
name: string
symbol: string
address: string
decimals: number
image?: string
}
type ChamberTypedContract = TypedContractV2<typeof CHAMBER_ABI>

function useMist(
provider: ProviderInterface | undefined,
sendTx: (calls: Call[]) => void
): UseMistResult