diff --git a/standard-bridge-custom-token/config.js b/standard-bridge-custom-token/config.js index 0f3917d..70e2414 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, }, + TestTT: { + name: "TestToken", + symbol: "TT", + decimals: 18, + l1TokenAddress: "0x8D7090DdDa057f48FdBbb2ABCeA22D1113AB566a", + l2TokenAddress: "0x8D7090DdDa057f48FdBbb2ABCeA22D1113AB566a", + isTestnet: true, + }, MATIC: { name: "Matic Token", symbol: "MATIC", diff --git a/standard-bridge-custom-token/contracts/TestToken.sol b/standard-bridge-custom-token/contracts/TestToken.sol new file mode 100644 index 0000000..009c023 --- /dev/null +++ b/standard-bridge-custom-token/contracts/TestToken.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.15; + +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +contract TestToken is ERC20 { + constructor(uint256 initialSupply) ERC20("TestToken", "TT") { + _mint(msg.sender, initialSupply); + } +} diff --git a/standard-bridge-custom-token/hardhat.config.js b/standard-bridge-custom-token/hardhat.config.js index f921a3f..ac906c2 100644 --- a/standard-bridge-custom-token/hardhat.config.js +++ b/standard-bridge-custom-token/hardhat.config.js @@ -17,6 +17,12 @@ module.exports = { }, }, networks: { + goerli: { + // Ankr's Public RPC URL + url: "https://rpc.ankr.com/eth_goerli", + // PRIVATE_KEY loaded from .env file + accounts: [process.env.PRIVATE_KEY], + }, "optimism-goerli": { chainId: 420, url: `https://opt-goerli.g.alchemy.com/v2/${process.env.L2_ALCHEMY_KEY}`, @@ -39,7 +45,11 @@ module.exports = { }, }, etherscan: { - apiKey: { "manta-testnet": "test", "manta-mainnet": "test" }, + apiKey: { + "manta-testnet": "test", + "manta-mainnet": "test", + goerli: process.env.ETHER_SCAN_API_KEY, + }, customChains: [ { network: "manta-testnet", diff --git a/standard-bridge-custom-token/scripts/deploy_l1.js b/standard-bridge-custom-token/scripts/deploy_l1.js new file mode 100644 index 0000000..2b73f1b --- /dev/null +++ b/standard-bridge-custom-token/scripts/deploy_l1.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( + "MantaMintableERC20" + ); + const args = [ + "0x4638aC6b5727a8b9586D3eba5B44Be4b74ED41Fc", + token.l2TokenAddress, + token.name, + token.symbol, + token.decimals, + ]; + const l2CustomERC20 = await l2CustomERC20Factory.deploy(...args); + console.log(`${token.symbol} L1 Address: ${l2CustomERC20.address}`); + + await l2CustomERC20.deployTransaction.wait(); + + await run("verify:verify", { + address: l2CustomERC20.address, + constructorArguments: args, + contract: "contracts/MantaMintableERC20.sol:MantaMintableERC20" + }); +} + +const tokenInfo = TOKENS[process.env.DEPLOY_TOKEN_NAME]; +if (!tokenInfo) { + console.error('Invalid Token: "process.env.DEPLOY_TOKEN_NAME"'); + return; +} +if (tokenInfo.l1TokenAddress) { + console.error(`Already Deployed: ${tokenInfo.l1TokenAddress}`); + return; +} + +main(tokenInfo).catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/standard-bridge-custom-token/scripts/deploy_l2_native_token.js b/standard-bridge-custom-token/scripts/deploy_l2_native_token.js new file mode 100644 index 0000000..4484b23 --- /dev/null +++ b/standard-bridge-custom-token/scripts/deploy_l2_native_token.js @@ -0,0 +1,24 @@ +require("dotenv").config(); + +const { ethers, run } = require("hardhat"); + + +async function main() { + const factory = await ethers.getContractFactory("TestToken"); + const args = [ethers.BigNumber.from("10000000000000000000000")]; + const l1CustomERC20 = await factory.deploy(...args); + console.log(`L2 Address: ${l1CustomERC20.address}`); + + await l1CustomERC20.deployTransaction.wait(); + + await run("verify:verify", { + address: l1CustomERC20.address, + constructorArguments: args, + contract: "contracts/TestToken.sol:TestToken", + }); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +});