@zethub/bridge
Reference

API reference

Every method on the client, grouped by area.

Constructor

new ZetHubBridge(options?: ZetHubBridgeOptions);

interface ZetHubBridgeOptions {
  environment?: Environment;                     // default MAINNET
  rpc?: Partial<Record<NetworkIdInput, readonly string[]>>;
  attestation?: IAttestationService;             // override the Iris client
  fees?: IFeeService;                            // override the fee client
}

See Configuration.

Instance properties

PropertyTypeNotes
environmentEnvironmentThe environment chosen at construction. Immutable.
bridgeBridgeAPIRaw tx builder, allowance helpers, quote, trustline check.
attestationAttestationAPIIris fetch and waitFor.

Discovery

sdk.chainDetailsMap(): Promise<ChainDetailsMap>;
sdk.tokens(): Promise<readonly TokenWithChainDetails[]>;
sdk.tokensByChain(id: NetworkIdInput): Promise<readonly TokenWithChainDetails[]>;
sdk.supportedAssets(): readonly AssetSymbol[];

ChainDetailsMap is Record<string, { network: Network; tokens: TokenWithChainDetails[] }>.

Balances

sdk.getTokenBalance({ token, address }): Promise<string>;
sdk.getNativeTokenBalance({ chainSymbol, address }): Promise<string>;
sdk.getGasBalance({ chainSymbol, address }): Promise<string>; // alias

Amounts are returned as human readable strings ("5.25") so you can print them without a decimals lookup.

Bridge API

sdk.bridge groups the pre flight and tx building calls.

sdk.bridge.rawTxBuilder.approve({ token, owner, amount? }): Promise<RawTransaction>;
sdk.bridge.rawTxBuilder.send({
  sourceToken, destinationToken, amount,
  fromAccountAddress, toAccountAddress,
  minFinalityThreshold?, memo?,
}): Promise<RawTransaction>;
sdk.bridge.rawTxBuilder.receive({
  destinationToken, toAccountAddress, message, attestation,
}): Promise<RawTransaction>;

sdk.bridge.getAllowance({ token, owner }): Promise<string>;
sdk.bridge.checkAllowance({ token, owner, amount }): Promise<boolean>;
sdk.bridge.quote({ sourceToken, destinationToken, minFinalityThreshold? }): Promise<BridgeQuote>;
sdk.bridge.hasTrustline({ token, address }): Promise<boolean>;

See Bridging overview for the flow, and Signing transactions for what to do with the raw txs.

Attestation API

sdk.attestation.fetch(source: NetworkIdInput, burnTxHash: string): Promise<AttestationEnvelope>;
sdk.attestation.waitFor(
  source: NetworkIdInput,
  burnTxHash: string,
  opts?: AttestationWaitOptions,
): Promise<AttestationEnvelope>;

See Attestation polling.

Everything else the package exports

The client is the surface most consumers use. The package also exports the underlying types, ports, and helpers so you can build on top or wire up custom testing.

Constants and enums: Environment, NetworkId, ChainFamily, AssetSymbol, BridgeStatus, BridgeSide, FinalityThreshold, MemoType, AttestationStatus.

Domain types: Amount, Address, Network, TokenAsset, BridgeMemo, BridgeTransactionState, BridgeEventRecord, BridgeQuote. See Types.

Raw transactions: RawTransaction, RawEvmTransaction, RawSorobanTransaction, isRawEvm, isRawSoroban.

Ports: IAttestationService, IFeeService, INetworkService, IChainConnector.

Services: IrisAttestationService, IrisFeeService, NetworkService, EvmChainConnector, StellarChainConnector, DefaultRawTxBuilder.

CCTP helpers: CctpEncoder, FeeMath, StellarCodec, StellarPassphrase, StellarRpc, StellarTrustline, CctpEventReader, CctpEvent, USDC_ABI, TOKEN_MESSENGER_V2_ABI, MESSAGE_TRANSMITTER_V2_ABI.

Errors and validation: BridgeError, ErrorCode, ErrorMessage, ValidationMessage, evmAddressSchema, stellarAddressSchema, stellarStrkeySchema, hexSchema, humanAmountSchema.

On this page