Skip to content

Instantly share code, notes, and snippets.

@Skyge
Last active July 6, 2021 16:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Skyge/a7476b10e080af9fb75cc2c3c38d45f9 to your computer and use it in GitHub Desktop.
Save Skyge/a7476b10e080af9fb75cc2c3c38d45f9 to your computer and use it in GitHub Desktop.
PRIVATE_KEY =
INFURA_KEY =
ETHERSCAN_KEY =
async function main() {
const [deployer] = await ethers.getSigners();
console.log(
"Deploying contracts with the account:",
deployer.address
);
console.log("Account balance:", (await deployer.getBalance()).toString());
const Token = await ethers.getContractFactory("Token");
const token = await upgrades.deployProxy(Token, ["Mock Token", "MT"], { initializer: 'initialize' });
console.log("Token address:", token.address);
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
import 'dotenv/config';
import { HardhatUserConfig } from 'hardhat/config'
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-waffle'
import '@nomiclabs/hardhat-etherscan'
import '@openzeppelin/hardhat-upgrades'
import 'hardhat-typechain'
const privateKey = process.env.PRIVATE_KEY;
const infuraKey = process.env.INFURA_KEY;
const config: HardhatUserConfig = {
defaultNetwork: 'hardhat',
// This is a sample solc configuration that specifies which version of solc to use
solidity: {
version: '0.6.12',
settings: {
optimizer: {
enabled: true,
runs: 2000,
},
},
},
networks: {
kovan: {
url: `https://kovan.infura.io/v3/${infuraKey}`,
accounts: [`0x${privateKey}`],
gasPrice: 1000000000,
},
},
typechain: {
outDir: 'types',
target: 'ethers-v5',
},
etherscan: {
apiKey: process.env.ETHERSCAN_KEY
},
}
export default config
{
"name": "mycontract",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^2.0.1",
"@nomiclabs/hardhat-waffle": "^2.0.0",
"@openzeppelin/contracts-upgradeable": "^3.2.0",
"@openzeppelin/hardhat-upgrades": "^1.3.1",
"@typechain/ethers-v5": "^4.0.0",
"dotenv": "^8.2.0",
"ethers": "^5.0.20",
"hardhat": "^2.0.3",
"hardhat-typechain": "^0.3.3",
"ts-node": "^9.0.0",
"typechain": "^4.0.0",
"typescript": "^4.0.5"
}
}
pragma solidity 0.6.12;
import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
contract Token is Initializable, ERC20Upgradeable{
function initialize(
string memory _name,
string memory _symbol
) public initializer {
__ERC20_init(_name, _symbol);
}
function mint(address account, uint256 amount) public {
_mint(account, amount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment