Programmatic Gateway
This page explains how to use the Sonic Gateway in your application or script to transfer ERC-20 assets from Ethereum to Sonic and back.
Sonic Bridge: Programmatic Usage Guide
Contract Addresses
// Ethereum (L1)
const ETH_CONTRACTS = {
TOKEN_DEPOSIT: "0xa1E2481a9CD0Cb0447EeB1cbc26F1b3fff3bec20",
TOKEN_PAIRS: "0xf2b1510c2709072C88C5b14db90Ec3b6297193e4",
STATE_ORACLE: "0xB7e8CC3F5FeA12443136f0cc13D81F109B2dEd7f"
};
// Sonic (L2)
const SONIC_CONTRACTS = {
BRIDGE: "0x9Ef7629F9B930168b76283AdD7120777b3c895b3",
TOKEN_PAIRS: "0x134E4c207aD5A13549DE1eBF8D43c1f49b00ba94",
STATE_ORACLE: "0x836664B0c0CB29B7877bCcF94159CC996528F2C3"
};Setup
// Network RPC endpoints
const ETHEREUM_RPC = "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY";
const SONIC_RPC = "https://rpc.soniclabs.com";
// Initialize providers
const ethProvider = new ethers.providers.JsonRpcProvider(ETHEREUM_RPC);
const sonicProvider = new ethers.providers.JsonRpcProvider(SONIC_RPC);
// Initialize signer with your private key
const PRIVATE_KEY = "your-private-key";
const ethSigner = new ethers.Wallet(PRIVATE_KEY, ethProvider);
const sonicSigner = new ethers.Wallet(PRIVATE_KEY, sonicProvider);Bridge Operations
1. Ethereum to Sonic Transfer
2. Claim Tokens on Sonic
3. Sonic to Ethereum Transfer
4. Claim Tokens on Ethereum
Complete Example
Required ABIs
Important Notes
Last updated

