API Reference
@mistcash/sdk
Section titled “@mistcash/sdk”Initialization
Section titled “Initialization”function initCore(): Promise<void>function initWasm(): Promise<void>function initGaraga(): Promise<void>Hashing
Section titled “Hashing”function hash2(a: string, b: string): Promise<string>function hash2Sync(a: string, b: string): stringfunction hash3(a: string, b: string, c: string): Promise<string>function hash3Sync(a: string, b: string, c: string): stringfunction txSecret(key: string, to: string): stringfunction hash_with_asset(secret: string, asset: string, amount: string): stringfunction txHash(key: string, owner: string, tokenAddr: string, amount: string): bigintfunction generateClaimingKey(): stringZero-Knowledge Proofs
Section titled “Zero-Knowledge Proofs”function prove_groth16(witness: Witness): Promise<ProofResponse>function full_prove(witness: Witness): Promise<bigint[]>
const FIXTURES: { witness: Witness proof: string verifyingKey: string}Merkle Trees
Section titled “Merkle Trees”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): bigintfunction evenLeafFilter(leaf: bigint): bigintContract Utilities
Section titled “Contract Utilities”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>Formatting
Section titled “Formatting”function fmtAmount(amount: bigint, decimals: number): stringfunction fmtAmtToBigInt(amountStr: string, decimals: number): bigintfunction getHashParams(): Record<string, string>Development
Section titled “Development”function devVal<T>(val: T, defaultVal?: T): Tfunction devStr(val: string): string@mistcash/config
Section titled “@mistcash/config”Constants
Section titled “Constants”const CHAMBER_ADDR_MAINNET: stringconst CHAMBER_ABI: Abiconst ERC20_ABI: AbiToken Data
Section titled “Token Data”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>@mistcash/react
Section titled “@mistcash/react”function useMist( provider: ProviderInterface | undefined, sendTx: (calls: Call[]) => void): UseMistResult