This project is a suite of smart contracts implementing L1 to L2 minting of the m3ter state as tokens. It enables bridging and minting operations between Layer 1 and Layer 2, as a m3terchain application.
L1MinterAndBridger.sol: Orchestrates minting of L1 tokens and bridges them to L2, using rollup state and power agreements.L1Token.sol: ERC20 token for Layer 1, with a minter role for controlled minting.L2Token.sol: Optimism-compatible ERC20 token for Layer 2, mintable by the L2 bridge, tracks total bridged balance.PowerAggreements.sol: Manages deposited m3ter NFTs and their ownership, tracks which NFTs are eligible for power agreements and who owns them.RollupMock.sol: Mock rollup contract for testing, simulates state and account data for m3ter tokens.CarbonCredits.sol: ERC721 contract that mints carbon credit NFTs based on energy usage reported by the rollup and m3ter NFT ownership.M3terNFTMock.sol: Mock ERC721 contract for m3ter NFTs, used for testing and development.
- Foundry (for Solidity development, testing, and deployment)
- Node.js and npm (for some scripts, optional)
- Install Foundry:
curl -L https://foundry.paradigm.xyz | bash foundryup - Clone the repository:
git clone https://github.com/Emmo00/m3ter-state-token-minter.git cd m3ter-state-token-minter - Install dependencies:
forge install
Format all contracts:
forge fmtRun all tests:
forge testDeploy contracts using the provided script (edit PRIVATE_KEY and RPC URLs as needed):
forge script script/Deploy.s.sol --rpc-url $SEPOLIA_URL --broadcast --private-key $PRIVATE_KEYSet the following environment variables for deployment and testing:
PRIVATE_KEY: Your deployer wallet private keySEPOLIA_URL: RPC URL for Ethereum SepoliaOP_SEPOLIA_URL: RPC URL for Optimism SepoliaETHERSCAN_API_KEY: (optional) for contract verification
src/: Main Solidity contractstest/: Foundry test contractsscript/: Deployment and utility scriptslib/: External dependencies
For more details on the m3tering protocol and m3terchain, see the official documentation.