This repository demonstrates the implementation of the ERC7802 standard for cross-chain token transfers using Chainlink's Cross-Chain Interoperability Protocol (CCIP).
This project showcases how to create and deploy upgradeable ERC20 tokens that implement the ERC7802 interface, along with the necessary token pool contracts to facilitate cross-chain transfers using Chainlink CCIP.
The tokens have been deployed to the following addresses:
- ShibuyaToken (SBY): 0x3c1F7c5f4C560afFCFe2b5ebF1271c3310867ff4 on Soneium Minato
- AstarToken (ASTR): 0x2CAE934a1e84F693fbb78CA5ED3B0A6893259441 on Soneium
ERC7802 is an Ethereum Improvement Proposal that standardizes cross-chain ERC20 token transfers. This standard defines a consistent interface for tokens that can be transferred across different blockchain networks.
- crosschainMint: Function that mints tokens when they arrive from another chain
- crosschainBurn: Function that burns tokens when they are sent to another chain
- Events: StandardizedCrosschainMint and StandardizedCrosschainBurn events that emit when tokens move across chains
- Standardization: Creates a unified interface for cross-chain token bridges
- Transparency: Provides clear events for tracking cross-chain movements
- Compatibility: Works with existing token standards like ERC20
- Interoperability: Enables seamless integration with various cross-chain communication protocols
By implementing ERC7802, tokens can be bridged between different blockchains in a standardized way, improving the interoperability of the blockchain ecosystem.
The Optimism Superchain has adopted ERC7802 as their standard for cross-chain token transfers through their SuperchainERC20 implementation. This provides a practical example of how ERC7802 is being used in major blockchain ecosystems.
Key aspects of the Optimism implementation:
- Asset Teleportation: Instead of wrapping assets, tokens are "teleported" between chains through burn/mint mechanics, providing a secure and capital-efficient method for cross-chain transactions.
- Infrastructure Simplicity: Zero infrastructure cost to make a token cross-chain compatible.
- Deployment Requirements: Tokens must deploy at the same address on all chains for interoperability.
- Permission Model: Token contracts must grant permission to the
SuperchainTokenBridgeto callcrosschainMintandcrosschainBurn.
The SuperchainERC20 approach demonstrates how ERC7802 enables:
- Consistent user experience across multiple chains
- Elimination of liquidity fragmentation
- Simplified cross-chain token transfers without wrapping or liquidity pools
- Common interface across the entire EVM ecosystem
This aligns with our implementation approach using Chainlink CCIP as the cross-chain communication protocol, showing the versatility of the ERC7802 standard across different bridge solutions.
Chainlink Cross-Chain Interoperability Protocol (CCIP) is a secure interoperability protocol enabling:
- Token transfers across blockchains
- Cross-chain messaging
- Building cross-chain applications
- Enabling cross-chain real-world assets
- Connecting private and public blockchains
CCIP provides defense-in-depth security and is powered by Chainlink oracle networks, which have secured tens of billions of dollars and enabled over $18 trillion in on-chain transaction value.
Key features:
- Risk Management Network: Actively monitors, detects, and mitigates risks in real-time
- Cross-Chain Tokens (CCTs): Cross-chain-native assets secured by CCIP
- Programmable Token Transfers: Send tokens with instructions for their use on the destination chain
- Arbitrary Messaging: Transfer data between smart contracts on different blockchains
- ERC7802 Implementation: Support for the emerging standard for cross-chain ERC20 token transfers
- Upgradeable Contracts: Uses OpenZeppelin's UUPS proxy pattern for upgradeability
- Two Pool Types:
- BurnMintTokenPool: Burns tokens on the source chain and mints them on the destination chain
- LockReleaseTokenPool: Locks tokens on the source chain and releases them on the destination chain
- Role-Based Access Control: Fine-grained permissions for minting and burning
- Two-Step Ownership Transfer: Secure ownership management with transfer request and acceptance
- Comprehensive Test Suite: Full coverage of token functionality, upgradeability, and cross-chain operations
This codebase has been audited by Cyfrin, a professional smart contract auditing firm. The audit report can be found here:
The audit focused on the Shibuya token implementation and verified the security of the contract's role-based access control, cross-chain functionality, and upgradeability mechanisms.
- Node.js v16+
- pnpm (recommended) or npm
- An Ethereum wallet with testnet ETH for deployment
- Access to Chainlink CCIP supported networks
# Clone the repository
git clone https://github.com/your-org/chainlink-ccip-erc7802.git
cd chainlink-ccip-erc7802
# Install dependencies
pnpm install- Set up environment variables:
# Install the environment variable encryption tool
pnpm add -D @chainlink/env-enc
# Create and encrypt your environment variables
npx env-enc set PRIVATE_KEY your_private_key
npx env-enc set PRIVATE_KEY_2 your_backup_private_key- Configure networks in
config/config.jsonwith appropriate chain selectors, routers, and RMN proxy addresses.
Run the comprehensive test suite to verify token functionality:
pnpm testFor test coverage:
pnpm coverageDeploy your token and token pool to a supported network using one of the following methods:
For quick deployment to preconfigured networks:
# Deploy to Soneium Minato testnet
pnpm run deploy:soneiumMinato
# Deploy to Soneium mainnet
pnpm run deploy:soneiumFor more customized deployments:
# Deploy AstarToken with a BurnMint pool
npx hardhat deployAstarTokenAndPool --network soneium --pooltype burnMint --verifycontract true
# Or deploy with a LockRelease pool that accepts liquidity
npx hardhat deployAstarTokenAndPool --network soneiumMinato --pooltype lockRelease --acceptliquidity trueYou can try cross-chain token transfers between the following networks:
- Mainnet: Astar Network to Soneium
- Testnet: Shiden to Soneium Minato
To bridge tokens between networks, visit the Astar Portal and use the cross-chain transfer functionality. The portal provides a user-friendly interface for transferring tokens using Chainlink CCIP.
graph TD
%% Base contracts and inheritances
ERC20U[ERC20Upgradeable] --> Token[AstarToken/ShibuyaToken]
ERC20BU[ERC20BurnableUpgradeable] --> Token
ACU[AccessControlUpgradeable] --> Token
UUPSU[UUPSUpgradeable] --> Token
IERC7802[IERC7802] --> Token
%% Proxy pattern
Token --- Proxy[ERC1967Proxy]
Proxy --> DeployedToken[Deployed Token Contract]
%% Key roles and permissions
Owner[Owner] --> MINTER_ROLE[MINTER_ROLE]
Owner --> BURNER_ROLE[BURNER_ROLE]
%% ERC7802 functions
MINTER_ROLE --> CrosschainMint[crosschainMint]
BURNER_ROLE --> CrosschainBurn[crosschainBurn]
%% Events
CrosschainMint --> MintEvent[CrosschainMint event]
CrosschainBurn --> BurnEvent[CrosschainBurn event]
-
BurnMint Pattern:
- Source Chain: Token is burned
- Cross-Chain Message: Sent via CCIP
- Destination Chain: Equivalent token is minted
-
LockRelease Pattern:
- Source Chain: Token is locked in the pool
- Cross-Chain Message: Sent via CCIP
- Destination Chain: Equivalent token is released from the pool
/contracts: Smart contracts- Main token implementations (Astar.sol, Shibuya.v0/v1/v2.sol)
- Interface definitions (IERC7802.sol)
- Dependencies and re-exports
/tasks: Hardhat tasks for deployment and management/test: Comprehensive test suites/config: Network and deployment configurations/utils: Utility functions for contract verification
This project follows several best practices for secure and maintainable blockchain development:
- Explicit Versioning: Contract upgrades are tracked with explicit version markers
- Role-Based Security: Strict access control for sensitive operations
- Defensive Programming: Extensive validation and error handling
- Event Emissions: Events for all significant state changes
- Upgradeability Testing: Thorough verification of upgrade paths
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Chainlink CCIP Documentation
- Chainlink Cross-Chain - Official CCIP landing page
- CCIP Technical Documentation - Developer resources and guides
- OpenZeppelin Contracts
- ERC7802 Standard
- Optimism SuperchainERC20 - OP Stack ERC7802 implementation
- Cyfrin Audits