Prerequisites
Before you begin, ensure you have the following installed:Node.js 18 or higher
This project requires Node.js v18 or higher. The recommended version is specified in Check your Node.js version:If you’re using nvm, switch to the correct version:Otherwise, download Node.js from nodejs.org
.nvmrc:Installation
Install dependencies
Install all required npm packages:This will install:
ethers- Ethereum library for EVM chains@solana/web3.js- Solana web3 library@debridge-finance/dln-client- Official deBridge clienttronweb- TRON blockchain librarydotenv- Environment variable managementtypescript- TypeScript compiler
Environment variables reference
Here’s a complete breakdown of all environment variables:| Variable | Required | Description |
|---|---|---|
SIGNER_PK | Yes | EVM private key in hex format with 0x prefix. Used for Ethereum, Polygon, Arbitrum, BNB, Base, etc. |
SOL_PK | For Solana | Solana private key in base58 format. Required for any Solana-related examples |
POLYGON_RPC_URL | For Polygon | Polygon mainnet RPC endpoint. Get from Alchemy, Infura, or other providers |
ARB_RPC_URL | For Arbitrum | Arbitrum One mainnet RPC endpoint |
BNB_RPC_URL | For BNB Chain | BNB Smart Chain mainnet RPC endpoint |
BASE_RPC_URL | For Base | Base mainnet RPC endpoint |
SOL_RPC_URL | For Solana | Solana mainnet RPC endpoint |
TRON_RPC_URL | For TRON | TRON mainnet RPC endpoint (usually https://api.trongrid.io) |
TRON_PK | For TRON | TRON private key |
TRONGRID_API_KEY | For TRON | TronGrid API key (optional but recommended for rate limits) |
MEGA_ETH_RPC_URL | For MegaETH | MegaETH RPC endpoint (only needed for MegaETH examples) |
You only need to configure RPC URLs for the chains you plan to use. Most examples use Polygon and Arbitrum, so start with those two at minimum.
Verify your setup
Test that your environment is configured correctly:Project structure
Familiarize yourself with the key directories:Common issues
Error: Cannot find module 'dotenv'
Error: Cannot find module 'dotenv'
This means dependencies weren’t installed correctly. Run:
Error: SIGNER_PK not found in .env file
Error: SIGNER_PK not found in .env file
You either didn’t create a
.env file or it’s missing required variables. Copy .env.example to .env and fill in your credentials:Error: insufficient funds for gas
Error: insufficient funds for gas
Your wallet needs native tokens for gas fees:
- Polygon: Need MATIC
- Arbitrum: Need ETH
- BNB Chain: Need BNB
- Solana: Need SOL
RPC connection errors
RPC connection errors
If you see “Failed to initialize providers” or connection timeout errors:
- Verify your RPC URLs are correct
- Check that your API keys are active
- Ensure you haven’t exceeded free tier rate limits
- Try using a different RPC provider as a fallback
Node version mismatch
Node version mismatch
If you see errors about unsupported Node features:
Next steps
Now that your environment is set up, you’re ready to run your first example:Quick start guide
Execute your first cross-chain swap from Polygon to Arbitrum