@zethub/bridge
Getting started

Configuration

Every client option, in one page.

The constructor takes one options object. Every field is optional. You can call new ZetHubBridge() with no arguments and it works.

Options

import type { ZetHubBridgeOptions } from "@zethub/bridge";
import { Environment } from "@zethub/bridge";

const options: ZetHubBridgeOptions = {
  environment: Environment.MAINNET,   // default MAINNET
  rpc: {},                            // per network RPC overrides
  attestation: undefined,             // override the Iris client
  fees: undefined,                    // override the Iris fee client
};
OptionTypePurpose
environmentEnvironmentMAINNET or TESTNET. Defaults to MAINNET.
rpcPartial<Record<NetworkId, readonly string[]>>Per network RPC URLs, prepended to the built in defaults so failover still works.
attestationIAttestationServiceCustom Iris client. The default one is fine for every consumer.
feesIFeeServiceCustom Iris fee client. Same.

No signer, no storage

The SDK never touches keys. Every write returns an unsigned RawTransaction. There is no evmSigner or stellarSigner. Sign with whatever wallet library you already use.

The SDK is also stateless. It does not persist transfers. If you want to survive a page reload after the burn, store the burn tx hash yourself and see Recovering a stalled transfer.

Custom RPC endpoints

Point any network at your own node. Your endpoints are tried first, then the built in defaults.

import { ZetHubBridge, Environment, NetworkId } from "@zethub/bridge";

const sdk = new ZetHubBridge({
  environment: Environment.MAINNET,
  rpc: {
    [NetworkId.BASE]: ["https://your-base-node.example"],
    [NetworkId.STELLAR]: ["https://your-soroban-rpc.example"],
  },
});

Networks not mentioned in rpc use the built in defaults unchanged. Every network already has two to four fallback public RPCs configured.

Changing environment

Environment is chosen at construction and is immutable on the instance. If your app switches between testnet and mainnet at runtime, construct a new instance.

const testnetSdk = new ZetHubBridge({ environment: Environment.TESTNET });
const mainnetSdk = new ZetHubBridge({ environment: Environment.MAINNET });

Construction is cheap. No network calls happen until the first read.

On this page