This project demonstrates how to create cross-chain token bridges between Ethereum Sepolia and Base Sepolia using Axelar Network, with additional integration of Squid Router for enhanced cross-chain swaps.
+-------------------+ +----------------+ +------------------+
| Ethereum Sepolia | | Axelar Network | | Base Sepolia |
| | | | | |
| +--------------+ | Messages | +------------+ | Messages | +--------------+ |
| | MoonTokenEth |<-|---------------->| | Relayer | |<-------------->| | MoonTokenBase| |
| | (ERC-20) | | | | | | | | (ERC-20) | |
| +--------------+ | | +------------+ | | +--------------+ |
| | | | | |
+-------------------+ +----------------+ +------------------+
^ ^
| |
| +----------------------------------+ |
+--------------| Squid Router (Cross-Chain Swaps) |--------------------+
+----------------------------------+
The architecture consists of two main components:
-
Primary Chain (Ethereum Sepolia)
- MoonTokenEth (MOON): ERC-20 token with fixed supply
- Total Supply: 10,000,000 MOON tokens minted at deployment
-
Secondary Chain (Base Sepolia)
- MoonTokenBase (MOON): ERC-20 token with role-based access control
- Includes minting and burning capabilities with proper role management
-
Axelar Network
- Acts as the communication layer between chains
- Securely transmits messages using the Interchain Token Service (ITS)
- Primary token on Ethereum Sepolia
- ERC-20 standard with 18 decimals
- Fixed supply of 10 million tokens minted at deployment
- Secondary token on Base Sepolia
- ERC-20 standard with 18 decimals and role-based access control
- Minter and Burner roles for controlled minting/burning functionality
This project uses Axelar's Interchain Token Service (ITS) to link the two custom tokens across chains. The integration follows these steps:
- Deploy MoonTokenEth on Ethereum Sepolia
- Deploy MoonTokenBase on Base Sepolia
- Register token metadata with the ITS Contract on both chains
- Register both tokens with the Interchain Token Factory
- Link the tokens using the Interchain Token Factory
- Assign appropriate minting/burning roles to token managers
When properly configured, the Interchain Token Service allows:
-
Token transfers from Ethereum Sepolia to Base Sepolia
- Tokens are locked on Ethereum
- Equivalent tokens are minted on Base Sepolia
-
Token transfers from Base Sepolia to Ethereum Sepolia
- Tokens are burned on Base Sepolia
- Equivalent tokens are released on Ethereum
- Node.js and npm installed
- Ethereum wallet with private key
- Sepolia ETH for gas fees
- Base Sepolia ETH for gas fees
- Clone the repository:
git clone https://github.com/yourusername/axelar-token-bridge.git
cd axelar-token-bridge- Install dependencies:
npm install- Create
.envfile:
cp .env.example .env- Fill in your environment variables in
.env:
PRIVATE_KEY=your_private_key_here
ETHEREUM_SEPOLIA_RPC_URL=your_sepolia_rpc_url
BASE_SEPOLIA_RPC_URL=your_base_sepolia_rpc_url
ETHERSCAN_API_KEY=your_etherscan_api_key
BASESCAN_API_KEY=your_basescan_api_key
- Deploy MoonTokenEth to Ethereum Sepolia:
npx hardhat run scripts/deploy/01-deploy-moon-token-eth.ts --network sepolia- Deploy MoonTokenBase to Base Sepolia:
npx hardhat run scripts/deploy/02-deploy-moon-token-base.ts --network baseSepoliaTo set up the cross-chain integration between the two tokens using Axelar:
npx hardhat run scripts/axelar-crosschain-integration.tsThis script handles:
- Registering both token metadata with the ITS Contract
- Registering token with the Interchain Token Factory
- Linking the tokens across chains
- Setting up minting/burning permissions
Squid Router enhances our token bridge by providing cross-chain liquidity and swaps. It allows for:
- One-click cross-chain transactions
- Optimized routing for best prices
- Multi-chain liquidity access
For more information, check out the Squid Router documentation.
Run tests for both tokens with:
npx hardhat testThis will run comprehensive tests for both MoonTokenEth and MoonTokenBase contracts, ensuring all functionality works correctly.