Skip to content

Types

Represents a token asset with an address and amount.

interface Asset {
addr: string;
amount: string | bigint;
}

Usage:

const asset: Asset = {
addr: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
amount: 1000000000000000000n, // 1 ETH
};

Input to the zero-knowledge proof generator. Contains all data needed to prove knowledge of a valid transaction without revealing which one.

interface Witness {
ClaimingKey: string;
Owner: string;
TxAsset: string;
Withdraw: {
Amount: string;
};
MerkleRoot: string;
MerkleProof: string[];
Tx1Secret: string;
}

Fields:

FieldDescription
ClaimingKeyThe secret key that proves ownership of the deposit
OwnerThe address that will receive the withdrawn tokens
TxAssetThe token contract address
Withdraw.AmountThe amount to withdraw (as string)
MerkleRootThe current Merkle root of the transaction tree
MerkleProofArray of sibling hashes forming the proof path
Tx1SecretDerived from txSecret(ClaimingKey, Owner)

Response from the Groth16 proof generation.

interface ProofResponse {
status: "ok" | "error";
proof?: string;
error?: string;
message?: string;
}

Success case:

{ status: "ok", proof: "..." }

Error case:

{ status: "error", error: "invalid witness", message: "..." }

Token metadata from @mistcash/config.

interface Token {
name: string;
symbol: string;
address: string;
decimals: number;
image?: string;
}

A typed contract instance for the Chamber smart contract. Provides full TypeScript autocomplete for all contract methods.

type ChamberTypedContract = TypedContractV2<typeof CHAMBER_ABI>;

Key contract methods:

MethodReturnsDescription
deposit(hash, asset)voidDeposit tokens with commitment
withdraw_no_zk(key, owner, asset, proof)voidWithdraw without ZK (testing)
handle_zkp(proof)voidProcess ZK proof withdrawal
tx_array()bigint[]Get all transaction leaves
merkle_root()bigintGet current Merkle root
merkle_proof(index)bigint[]Get proof for leaf index
assets_from_secret(secret)AssetLookup asset by tx secret
nullifiers_spent(nullifiers)boolean[]Check if nullifiers are spent

Full return type of the useMist hook. See the @mistcash/react documentation for a detailed breakdown of each property.

interface UseMistResult {
// Contract
chamberAddress: string;
contract: ChamberTypedContract;
txLeaves: bigint[];
// Loading
loadingStatus: "FINDING_TX" | "READY";
loadingMessage: string;
// Inputs
valTo: string;
setTo: (val: string) => void;
valKey: string;
setKey: (val: string) => void;
// Asset
asset: Asset | undefined;
setAsset: (asset: Asset | undefined) => void;
setAssetAddr: (addr: string) => void;
setAssetAmt: (amount: bigint) => void;
// Actions
send: (calls?: Call[]) => void;
fetchAsset: () => Promise<Asset>;
updateTxLeaves: () => Promise<bigint[]>;
handleWithdraw: (asset: Asset, newTxAmount?: string) => Promise<void>;
// Status
isPending: boolean;
error: string | null;
txError: Error | null;
// Seek and Hide
valSnHTo: string;
setSnHTo: (val: string) => void;
valSnHKey: string;
setSnHKey: (val: string) => void;
valSnHAmt: string;
setSnHAmt: (val: string) => void;
}