Skip to content

Instantly share code, notes, and snippets.

@tatsuyasusukida
Created August 7, 2022 00:05
Show Gist options
  • Save tatsuyasusukida/7246f3c7fafb7e83203116bf54f6c83f to your computer and use it in GitHub Desktop.
Save tatsuyasusukida/7246f3c7fafb7e83203116bf54f6c83f to your computer and use it in GitHub Desktop.
πŸͺ™ How to create your own ERC-20 Token
API_URL="https://eth-goerli.g.alchemy.com/v2/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
PRIVATE_KEY="0000000000000000000000000000000000000000000000000000000000000000"
ETHERSCAN_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
CONTRACT_ADDRESS="update after deploying"
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)
}
}
/** @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,
},
};
{
"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": ""
}
//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