Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Tokens and Services

Helpers for reading token state and querying Mirage services. None of these require a wallet client.

Token utilities

import {
  getTokenMetadata,
  getTokenBalance,
  getTokenAllowance,
  isNativeToken,
  NATIVE_TOKEN_ADDRESS,
} from "@mirageprivacy/sdk";
 
const meta = await getTokenMetadata(tokenAddress, publicClient);
// { address, name, symbol, decimals }
 
const balance = await getTokenBalance(tokenAddress, owner, publicClient);
const allowance = await getTokenAllowance(tokenAddress, owner, spender, publicClient);
 
// Native ETH is represented by the zero address
isNativeToken(NATIVE_TOKEN_ADDRESS); // true

ERC-20 metadata is immutable, so getTokenMetadata caches per chain and collapses concurrent lookups for the same token into one set of reads. For the native token it resolves locally without touching the chain, and getTokenBalance falls back to the account's ETH balance.

Service utilities

import { fetchNetworkKey, fetchApiHealth, fetchTransferLimit } from "@mirageprivacy/sdk";
 
// SGX attestation status for a node
const key = await fetchNetworkKey("https://sgx1.mirageprivacy.com");
// { publicKey, attested, debug, chainId, mrenclave?, mrsigner?, verification? }
 
// Service health
const health = await fetchApiHealth("https://api.mirageprivacy.com");
// { status, version?, maxTransferUsd?, whitelistRequiredUsd? }
 
// Per-network transfer limit, in USD
const limit = await fetchTransferLimit("https://api.mirageprivacy.com", 1);
// "10000" | null | undefined

attested only means the node served a quote; it says nothing about that quote's validity. The verification field is present only when the quote was cryptographically verified and bound to the served payload, and it carries the TCB status, advisory IDs, measurements, and enclave security version.