Created
August 7, 2022 00:05
-
-
Save tatsuyasusukida/7246f3c7fafb7e83203116bf54f6c83f to your computer and use it in GitHub Desktop.
πͺ How to create your own ERC-20 Token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
API_URL="https://eth-goerli.g.alchemy.com/v2/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | |
PRIVATE_KEY="0000000000000000000000000000000000000000000000000000000000000000" | |
ETHERSCAN_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
CONTRACT_ADDRESS="update after deploying" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main() | |
async function main () { | |
try { | |
const SusukidaCoin = await ethers.getContractFactory("SusukidaCoin") | |
const susukidaCoin = await SusukidaCoin.deploy() | |
console.info(`Token address: ${susukidaCoin.address}`) | |
} catch (err) { | |
console.error(err) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @type import('hardhat/config').HardhatUserConfig */ | |
require('dotenv').config() | |
require('@nomiclabs/hardhat-ethers') | |
require('@nomiclabs/hardhat-etherscan') | |
module.exports = { | |
solidity: "0.8.9", | |
defaultNetwork: "goerli", | |
networks: { | |
hardhat: {}, | |
goerli: { | |
url: process.env.API_URL, | |
accounts: [`0x${process.env.PRIVATE_KEY}`], | |
}, | |
}, | |
etherscan: { | |
apiKey: process.env.ETHERSCAN_API_KEY, | |
}, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "how-to-mint-erc20-token", | |
"version": "1.0.0", | |
"main": "index.js", | |
"scripts": { | |
"deploy": "hardhat run scripts/deploy.js", | |
"verify": "source .env && hardhat verify --contract contracts/SusukidaCoin.sol:SusukidaCoin $CONTRACT_ADDRESS", | |
"gist": "gist -od 'πͺ How to create your own ERC-20 Token' contracts/SusukidaCoin.sol scripts/deploy.js .env.example hardhat.config.js package.json" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"@openzeppelin/contracts": "^4.7.2", | |
"dotenv": "^16.0.1" | |
}, | |
"devDependencies": { | |
"@nomiclabs/hardhat-ethers": "^2.1.0", | |
"@nomiclabs/hardhat-etherscan": "^3.1.0", | |
"hardhat": "^2.10.1" | |
}, | |
"description": "" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: Unlicense | |
pragma solidity ^0.8.9; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
contract SusukidaCoin is ERC20 { | |
uint constant _initial_supply = 1000000 * (10**18); | |
constructor() ERC20("SusukidaCoin", "SSKD") { | |
_mint(msg.sender, _initial_supply); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment