Skip to main content
Use @thru/bridge-sdk when you need to move assets between Polygon and Thru from a wallet, deposit flow, or bridge integration.

Install

npm install @thru/bridge-sdk

Import

The package exposes a single root entry point.
import {
  createBridgeClient,
  BridgeClient,
  THRU_POLYGON_CHAIN_IDS,
  THRU_TOKEN_PROGRAM_ADDRESS,
} from '@thru/bridge-sdk';

When to use it

Use @thru/bridge-sdk when your task is explicitly about bridge deposits or redemptions. If you only need general RPC reads, block queries, or transaction submission, use @thru/thru-sdk instead. If you only need raw protobuf messages, use @thru/proto.

What it exports

The root export includes:
  • createBridgeClient(config) and BridgeClient
  • POLYGON_BRIDGE_ABI
  • POLYGON_ERC20_ABI
  • THRU_POLYGON_CHAIN_IDS
  • THRU_STATE_PROOF_WIRE_TYPES
  • THRU_TOKEN_PROGRAM_ADDRESS
  • Types for bridge config, requests, results, routes, and token metadata

Setup

Create a bridge client with Polygon signer settings, Thru signer settings, or both depending on which direction you need to support.
const bridge = createBridgeClient({
  polygon: {
    signer: {
      privateKey: process.env.POLYGON_PRIVATE_KEY!,
      rpcUrl: process.env.POLYGON_RPC_URL!,
    },
    polygonBridgeAddress: process.env.POLYGON_BRIDGE_ADDRESS!,
  },
  thru: {
    signer: {
      baseUrl: process.env.THRU_BASE_URL!,
      feePayerAddress: process.env.THRU_FEE_PAYER_ADDRESS!,
      feePayerPrivateKey: process.env.THRU_FEE_PAYER_PRIVATE_KEY!,
    },
    thruBridgeProgramAddress: process.env.THRU_BRIDGE_PROGRAM_ADDRESS!,
  },
});

Polygon To Thru

Use the Polygon side when you want to approve an ERC-20 and deposit it into Thru.
  • getPolygonTokenMetadata(polygonTokenAddress)
  • approvePolygonToken({ polygonTokenAddress, rawAmount })
  • depositPolygonToThru({ thruRecipient, polygonTokenAddress, rawAmount })
  • getPolygonDepositFromTx(txHash)
depositPolygonToThru(...) validates the Thru recipient address, checks ERC-20 allowance, submits the Polygon bridge deposit, and returns the receipt plus the parsed deposit event when available.

Thru To Polygon

Use the Thru side when you want to deposit a bridged Thru token back to Polygon.
  • getThruPolygonTokenRoute(thruTokenMintAddress)
  • depositThruToPolygon({ thruTokenMintAddress, polygonRecipientAddress, rawAmount, thruTokenAccountAddress?, payloadHex? })
getThruPolygonTokenRoute(...) tells you whether a mint is bridged from Polygon and, if so, which Polygon token it maps to.

Good fit for

This package is a good fit when you are building:
  • a wallet deposit flow that starts on Polygon and finishes on Thru
  • a redeem flow that starts on Thru and pays out on Polygon
  • a custom bridge UI or backend that needs to inspect token metadata, allowances, or parsed deposit events