diff --git a/standard-bridge-custom-token/README.md b/standard-bridge-custom-token/README.md index 189a39f..9cd3429 100644 --- a/standard-bridge-custom-token/README.md +++ b/standard-bridge-custom-token/README.md @@ -13,6 +13,9 @@ npx hardhat run scripts/deploy.js --network manta-mainnet # or npx hardhat run scripts/deploy_l1.js --network mainnet +# or +npx hardhat run scripts/deployBridgeFlagToken.js --network manta-mainnet + # step 4: # configure the l2TokenAddress address in the console into config diff --git a/standard-bridge-custom-token/config.js b/standard-bridge-custom-token/config.js index e181aa7..c677380 100644 --- a/standard-bridge-custom-token/config.js +++ b/standard-bridge-custom-token/config.js @@ -9,6 +9,14 @@ const TOKENS = { l2TokenAddress: "0xA2B0b1DF7FbD966560A302E9E2cFB9d0f115FfD6", isTestnet: true, }, + TestUSDT: { + name: "Manta Tether USD", + symbol: "maUSDT", + decimals: 6, + l1TokenAddress: "0xf4b2cbc3ba04c478f0dc824f4806ac39982dce73", + l2TokenAddress: "", + isTestnet: true, + }, TestManta: { name: "Manta Token", symbol: "MANTA", diff --git a/standard-bridge-custom-token/contracts/MantaMintableERC20WithBridgeFlag.sol b/standard-bridge-custom-token/contracts/MantaMintableERC20WithBridgeFlag.sol new file mode 100644 index 0000000..68fe308 --- /dev/null +++ b/standard-bridge-custom-token/contracts/MantaMintableERC20WithBridgeFlag.sol @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.15; + +import {OptimismMintableERC20} from "@eth-optimism/contracts-bedrock/src/universal/OptimismMintableERC20.sol"; + +contract MantaMintableERC20WithBridgeFlag is OptimismMintableERC20 { + address public admin; + bool public bridgePaused; + + modifier onlyAdmin() { + require(admin == msg.sender, "MantaMintableERC20WithBridgeFlag: Only Admin"); + _; + } + + constructor( + address _bridge, + address _remoteToken, + string memory _name, + string memory _symbol, + uint8 _decimals + ) OptimismMintableERC20(_bridge, _remoteToken, _name, _symbol, _decimals) { + admin = msg.sender; + bridgePaused=true; + } + + function setAdmin(address _newAdmin) external onlyAdmin { + require( + _newAdmin != address(0), + "MantaMintableERC20WithBridgeFlag: invalid new admin" + ); + admin = _newAdmin; + } + + function pause() external onlyAdmin { + bridgePaused = true; + } + + function unPause() external onlyAdmin { + bridgePaused = false; + } + + function burn(address _from, uint256 _amount) external override onlyBridge { + require(!bridgePaused, "MantaMintableERC20WithBridgeFlag: bridge paused"); + + _burn(_from, _amount); + emit Burn(_from, _amount); + } +} diff --git a/standard-bridge-custom-token/scripts/deployBridgeFlagToken.js b/standard-bridge-custom-token/scripts/deployBridgeFlagToken.js new file mode 100644 index 0000000..47fa742 --- /dev/null +++ b/standard-bridge-custom-token/scripts/deployBridgeFlagToken.js @@ -0,0 +1,42 @@ +require("dotenv").config(); + +const { ethers, run } = require("hardhat"); +const { TOKENS } = require("../config"); + +async function main(token) { + const l2CustomERC20Factory = await ethers.getContractFactory( + "MantaMintableERC20WithBridgeFlag" + ); + const args = [ + "0x4200000000000000000000000000000000000010", + token.l1TokenAddress, + token.name, + token.symbol, + token.decimals, + ]; + const l2CustomERC20 = await l2CustomERC20Factory.deploy(...args); + console.log(`${token.symbol} L2 Address: ${l2CustomERC20.address}`); + + await l2CustomERC20.deployTransaction.wait(); + + await run("verify:verify", { + address: l2CustomERC20.address, + constructorArguments: args, + contract: "contracts/MantaMintableERC20WithBridgeFlag.sol:MantaMintableERC20WithBridgeFlag" + }); +} + +const tokenInfo = TOKENS[process.env.DEPLOY_TOKEN_NAME]; +if (!tokenInfo) { + console.error('Invalid Token: "process.env.DEPLOY_TOKEN_NAME"'); + return; +} +if (tokenInfo.l2TokenAddress) { + console.error(`Already Deployed: ${tokenInfo.l2TokenAddress}`); + return; +} + +main(tokenInfo).catch((error) => { + console.error(error); + process.exitCode = 1; +});