A cross-chain compatible ERC20 token implementation designed for the Optimism ecosystem. This token can be bridged across different chains in the Optimism Superchain using the L2 Standard Bridge.
- ERC20 token with cross-chain capabilities
- Compatible with Optimism's L2 Standard Bridge
- Built with Solady for gas optimization
- Supports ERC165 interface detection
- Implements ISemver for version tracking
- Fully audited and tested codebase
-
BTBFinance.sol
- Main token contract that inherits from SuperchainERC20
- Implements token-specific logic (name, symbol, decimals)
- Manages token supply and ownership
- Uses Solady's Ownable for efficient ownership management
-
SuperchainERC20.sol
- Abstract base contract for cross-chain functionality
- Implements IERC7802 for cross-chain token standards
- Handles bridge minting and burning through L2 Standard Bridge
- Version tracking through ISemver
- Current version: 1.0.0-beta.8
-
IERC7802.sol
- Standard interface for cross-chain token operations
- Defines crosschainMint and crosschainBurn functions
- Includes event definitions for cross-chain operations
-
ISemver.sol
- Interface for semantic versioning
- Enables version tracking across contract upgrades
-
Predeploys.sol (from @eth-optimism/contracts-bedrock)
- Contains L2 predeploy addresses
- Used for L2 Standard Bridge integration
-
CommonErrors.sol
- Common error definitions
- Includes
Unauthorized()
error
{
"@eth-optimism/contracts-bedrock": "latest",
"@openzeppelin/contracts": "^5.0.1",
"@rari-capital/solmate": "^6.4.0",
"solady": "^0.0.294",
"ethers": "^6.9.0"
}
- Solidity 0.8.25 with optimizer enabled
- Uses IR-based code generation (viaIR: true)
The contract uses several predefined addresses from the Optimism ecosystem:
- L2 Standard Bridge:
0x4200000000000000000000000000000000000010
- L2 Cross Domain Messenger:
0x4200000000000000000000000000000000000007
The token implements cross-chain capabilities through:
-
CrosschainMint Function
function crosschainMint(address _to, uint256 _amount) external
- Restricted to L2 Standard Bridge
- Used for receiving tokens from other chains
-
CrosschainBurn Function
function crosschainBurn(address _from, uint256 _amount) external
- Restricted to L2 Standard Bridge
- Used when sending tokens to other chains
-
Clone the Repository
git clone <repository-url> cd SuperChainToken
-
Install Dependencies
npm install
-
Environment Setup Create a
.env
file with:PRIVATE_KEY=your_private_key OP_SEPOLIA_RPC_URL=https://sepolia.optimism.io ETHERSCAN_API_KEY=your_etherscan_api_key
-
Compile Contracts
npx hardhat compile
-
Run Tests
npx hardhat test
-
Deploy
npx hardhat run scripts/deploy.ts --network op-sepolia
-
Access Control
- Bridge operations restricted to L2 Standard Bridge
- Owner functions protected by Solady's Ownable
- No direct mint/burn functions exposed
-
Audited Codebase
- All contracts have been audited
- No modifications to core contract logic
- Using well-tested dependencies
-
Error Handling
- Custom error definitions for gas efficiency
- Clear error messages for debugging
SuperChainToken/
├── contracts/
│ ├── BTBFinance.sol
│ ├── interfaces/
│ │ ├── L2/
│ │ │ ├── IERC7802.sol
│ │ │ └── SuperchainERC20.sol
│ │ └── universal/
│ │ └── ISemver.sol
│ └── libraries/
│ └── errors/
│ └── CommonErrors.sol
├── scripts/
│ └── deploy.ts
├── test/
├── .env
├── .gitignore
├── hardhat.config.ts
└── package.json
MIT