Runnable TypeScript examples for the deBridge Borderless API — gasless, non-custodial cross-chain and same-chain execution.
Gasless intents let you bundle multiple trades across chains into a single atomic operation. The deBridge protocol signs and pays gas on your behalf — you never need native tokens to cover transaction fees. This repository provides ready-to-run scripts covering the full lifecycle: creating bundles, signing intents, submitting trades, querying status, cancelling bundles, attaching pre/post-hooks, and working with both EVM and Solana chains.
| Category | Description | Chains | Path |
|---|---|---|---|
| Bundle Creation | Create and inspect bundles without submitting | EVM | prepare-bundle/ |
| Bundle Submission | End-to-end create → sign → submit workflows | EVM | submit-bundle*.ts, aa-disabled-evm.ts |
| Querying Bundles | Fetch bundles by ID, owner, order ID, date range | EVM | queries/ |
| Cancellation | Cancel by bundle ID, by intent owner, by partner authority, stuck bundles | EVM | cancellation/ |
| Pre-hooks | Arbitrary on-chain actions executed before settlement | EVM | prehooks/ |
| Post-hooks | On-chain actions after settlement (Morpho deposit, ERC-20 send, native send) | EVM | posthooks/ |
| Solana Source Chain | Bundles originating from Solana (AA enabled/disabled, pre-swap, same-chain) | Solana → EVM | solana/src-cases/ |
| Solana Destination Chain | Atomic fulfillment with Solana as destination | EVM → Solana | solana/dst-cases/ |
| Solana Prepare Steps | SPL token approval and SOL wrapping before bundle submission | Solana | solana/prepare-steps/ |
| Solana Trade Scenarios | Mixed cross-chain and same-chain Solana bundles | EVM + Solana | solana-trade-scenarios/ |
| WebSockets | Real-time bundle status tracking via WebSocket client + HTML tracker | EVM | web-sockets/ |
| EIP-7702 Authorization | Manual account abstraction authorization on Base | EVM (Base) | manual-authorization-base.ts |
| Price API | Token rates table and price chart with SVG output | Any chain | price/examples/ |
nvm use # Node v20.18.0
npm install
cp .env.example .env # fill in keys (see below)Run your first queries:
npx tsx src/gasless-intents/queries/get-bundles.ts
npx tsx src/gasless-intents/queries/get-bundle-by-id.tsSubmit a bundle end-to-end:
npx tsx src/gasless-intents/submit-bundle.ts- Node.js v20.18.0 —
.nvmrcprovided, runnvm use - RPC URLs — Alchemy (or equivalent) endpoints for Polygon, BNB Chain, Arbitrum, Base, and Solana
- EVM private key (
SIGNER_PK) — wallet that will sign EIP-712 intents - Solana private key (
SOL_PK) — base58-encoded keypair (only needed for Solana examples) - deBridge partner API key (
DE_BRIDGE_PARTNER_API_KEY) — obtain from deBridge
Copy .env.example to .env and fill in the values:
| Variable | Description |
|---|---|
SIGNER_PK |
EVM private key (hex, with or without 0x prefix) |
SOL_PK |
Solana private key (base58-encoded) |
POLYGON_RPC_URL |
Polygon RPC endpoint |
BNB_RPC_URL |
BNB Chain RPC endpoint |
ARB_RPC_URL |
Arbitrum RPC endpoint |
BASE_RPC_URL |
Base RPC endpoint |
SOL_RPC_URL |
Solana RPC endpoint |
DE_BRIDGE_PARTNER_API_KEY |
deBridge partner API key |
Create bundles via the Borderless API without submitting them on-chain. Useful for inspecting the response payload, understanding
intent structure, and validating trade parameters. create-bundle.ts shows a minimal single-trade example; multi-poly-to-bsc.ts
demonstrates multi-trade bundles.
End-to-end workflow: create a bundle of trades, collect EIP-712 signatures for each intent via processIntentBundle(), and
submit. submit-bundle.ts shows a 3-trade Polygon/BSC bundle with account abstraction enabled. aa-disabled-evm.ts shows the
same flow with enableAccountAbstraction: false, requiring the signer to pay gas directly.
Read-only scripts for fetching bundle data. Filter bundles by owner address, by creation or update date range, by order ID, or retrieve a single bundle by its UUID. These scripts only require a valid API key — no private keys needed.
Cancel pending bundles before they are fulfilled. cancel-bundle-by-id.ts cancels a single bundle by UUID.
cancel-bundles-intent-owner.ts cancels all bundles for a given intent owner within a time window.
cancel-bundle-partner-authority.ts cancels via the partner authority. stuck-bundle.ts demonstrates handling bundles with
unfavorable pricing that won't be fulfilled.
Attach arbitrary on-chain actions to bundles. Pre-hooks execute before the bundle's intents are processed (e.g., sending native assets to fund an operation). Post-hooks execute after settlement — examples include depositing received USDC into a Morpho vault, sending ERC-20 tokens to another address, and forwarding native assets to a beneficiary.
Solana examples span four directories. Source chain scripts create bundles that originate from Solana with both AA-enabled and
AA-disabled flows, plus a pre-swap variant. Destination chain shows atomic fulfillment when Solana is the receiving chain.
Prepare steps handle SPL token approval (check-approve-spl-prepare.ts) and SOL wrapping (check-wrap-sol-prepare.ts)
required before submitting Solana-origin bundles. Trade scenarios demonstrate mixed bundles combining cross-chain and
same-chain Solana trades (e.g., 2 cross-chain + 2 same-chain, or 3 same-chain SOL swaps).
Real-time bundle tracking over WebSockets. example.ts connects to the deBridge WebSocket API and subscribes to bundle updates
filtered by referral code, intent owner, or bundle ID. DebridgeWsClient.ts is a reusable client with auto-reconnect.
bundle-tracker-ws.html provides a browser-based tracker UI.
manual-authorization-base.ts demonstrates signing and submitting an EIP-7702 authorization transaction on Base. This delegates
your EOA to a
EIP7702StatelessDeleGator contract,
introduced with MetaMask delegation framework, enabling account abstraction without deploying a separate smart account.
token-rates.ts fetches current USD prices for a set of tokens via POST /v1/token/price and renders a table as an SVG file.
token-chart.ts fetches historical price data via GET /v1/token/chart (line or OHLC) and renders a chart as an SVG file.
Additional chart scripts demonstrate longer time ranges (THREE_MONTHS, SIX_MONTHS, FIVE_YEARS, ALL).
All scripts write SVG output to the output/ directory.
npx tsx src/price/examples/chart-three-months.ts # → output/token-chart-line-THREE_MONTHS.svg
npx tsx src/price/examples/chart-six-months.ts # → output/token-chart-line-SIX_MONTHS.svg
npx tsx src/price/examples/chart-five-years.ts # → output/token-chart-line-FIVE_YEARS.svg
npx tsx src/price/examples/chart-all.ts # → output/token-chart-line-ALL.svgNote: The
canvasnpm package (used by Vega for server-side SVG rendering) has native bindings. On Ubuntu/WSL, install system libraries first:sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
- Bundle lifecycle:
createBundle()→ collect signatures viaprocessIntentBundle()→submitBundle() - Wallet setup: viem
WalletClientinstances for EVM chains, SolanaKeypairfor Solana, mapped by chain ID viagetChainIdToWalletClientMap() - Signing: EIP-712 typed data for EVM intents, NaCl (
tweetnacl) for Solana, EIP-7702 for account abstraction authorization - Trade definitions: Factory functions in
trades.ts(e.g.,getPolyUsdcToBscUsdcTrade()) or inlineTradeobjects - Hooks: Pre/post-hooks attached to the
BundleProposeBodyas arrays of calldata objects targeting specific chains and contracts - Atomicity:
isAtomic: trueensures all-or-nothing settlement — either every intent in the bundle is fulfilled, or none are
src/
├── gasless-intents/ # All example scripts
│ ├── prepare-bundle/ # Bundle creation (no submission)
│ ├── queries/ # Read-only bundle queries
│ ├── cancellation/ # Bundle cancellation flows
│ ├── prehooks/ # Pre-hook examples
│ ├── posthooks/ # Post-hook examples
│ ├── solana/
│ │ ├── src-cases/ # Solana as source chain
│ │ ├── dst-cases/ # Solana as destination chain
│ │ └── prepare-steps/ # SPL approve & SOL wrap
│ ├── solana-trade-scenarios/ # Mixed Solana trade bundles
│ ├── web-sockets/ # WebSocket client & HTML tracker
│ ├── submit-bundle.ts # Main EVM submission example (AA enabled)
│ ├── submit-bundle-example-2.ts
│ ├── submit-bundle-poly-to-base.ts
│ ├── aa-disabled-evm.ts # Submission without account abstraction
│ ├── manual-authorization-base.ts # EIP-7702 authorization
│ ├── trades.ts # Trade factory functions
│ └── types.ts # Shared TypeScript types
├── price/ # Price API
│ ├── examples/ # Runnable scripts (rates, charts by range)
│ ├── renderers/ # Vega-Lite SVG renderers
└── utils/ # Shared utilities
├── api.ts # createBundle, submitBundle, getBundles, cancelBundles
├── chains.ts # Chain ID constants
├── constants.ts # Token addresses, API URLs
├── wallet.ts # Wallet client setup
├── posthooks.ts # Post-hook builders
├── signatures/
│ └── intent-signatures.ts # EIP-712 & NaCl signing
├── solana/ # Solana-specific utilities
├── morpho/ # Morpho vault integration
└── contract-calls/ # Low-level contract interaction helpers
- Add examples under
src/gasless-intents/in a descriptive subdirectory - Use
@utils/*and@gasless-intents/*path aliases for cross-module imports - Run
npm run lintbefore committing - Keep examples self-contained and runnable with
npx tsx