Skip to content

Commit

Permalink
Сreated deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
Kron1749 committed Sep 16, 2022
1 parent 1081b05 commit 8728b01
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 5 deletions.
33 changes: 29 additions & 4 deletions contracts/TestToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,34 @@
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract TestToken is ERC20 {
constructor(uint256 initialSupply) ERC20("TestToke","TT") {
_mint(msg.sender,initialSupply);
contract TestToken is ERC20, Ownable {
constructor(uint256 initialSupply) ERC20("TestToke", "TT") {
_mint(msg.sender, initialSupply);
}
}

mapping(address => bool) stakeHolders;
mapping(address => uint256) stakeSize;
uint256 totalStake;

function addStakeHolder(address _stakeHolder) public {
if (!stakeHolders[_stakeHolder]) {
stakeHolders[_stakeHolder] = true;
}
}

function removeStakeHolder(address _stakeHolder) public {
if (stakeHolders[_stakeHolder]) {
stakeHolders[_stakeHolder] = false;
}
}

function getStakeOf(address _stakeHolder) public view returns (uint256) {
return stakeSize[_stakeHolder];
}

function getTotalStake() public view returns (uint256) {
return totalStake;
}
}
24 changes: 24 additions & 0 deletions deploy/01-deploy-test-token.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { getNamedAccounts, deployments, network } = require("hardhat")
const { networkConfig, developmentChains } = require("../helper-hardhat-config")
const { verify } = require("../utils/verify")

module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()

const args = [1000000]

const testToken = await deploy("TestToken", {
from: deployer,
args: args,
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
})

if (!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY) {
// If we are on a testnet
await verify(testToken.address, args)
}
}

module.exports.tags = ["all", "fundme"]
5 changes: 4 additions & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ module.exports = {
{
version: "0.8.7",
},
{
version: "0.7.5",
},
],
},
mocha: {
timeout: 500000,
},
}
}
35 changes: 35 additions & 0 deletions helper-hardhat-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const networkConfig = {
31337: {
name: "localhost",
ethUsdPriceFeed: "0x9326BFA02ADD2366b30bacB125260Af641031331",
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc", // 30 gwei
mintFee: "10000000000000000", // 0.01 ETH
callbackGasLimit: "500000", // 500,000 gas
},

4: {
name: "rinkeby",
ethUsdPriceFeed: "0x8A753747A1Fa494EC906cE90E9f37563A8AF630e",
vrfCoordinatorV2: "0x6168499c0cFfCaCD319c818142124B7A15E857ab",
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
callbackGasLimit: "500000", // 500,000 gas
mintFee: "10000000000000000", // 0.01 ETH
},
5: {
name: "goerli",
ethUsdPriceFeed: "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e",
vrfCoordinatorV2: "0x2Ca8E0C643bDe4C2E08ab1fA0da3401AdAD7734D",
gasLane: "0x79d3d8832d904592c0bf9818b621522c988bb8b0c05cdc3b15aea1b6e8db0c15",
callbackGasLimit: "500000", // 500,000 gas
mintFee: "10000000000000000", // 0.01 ETH
},
}

const VERIFICATION_BLOCK_CONFIRMATIONS = 5
const developmentChains = ["hardhat", "localhost"]

module.exports = {
networkConfig,
developmentChains,
VERIFICATION_BLOCK_CONFIRMATIONS,
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"timeout": 10000000
},
"dependencies": {
"@uniswap/hardhat-v3-deploy": "^0.1.1",
"@uniswap/v3-periphery": "^1.4.1"
}
}
19 changes: 19 additions & 0 deletions utils/verify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { run } = require("hardhat")

const verify = async (contractAddress, args) => {
console.log("Verifying contract...")
try {
await run("verify:verify", {
address: contractAddress,
constructorArguments: args,
})
} catch (e) {
if (e.message.toLowerCase().includes("already verified")) {
console.log("Already verified!")
} else {
console.log(e)
}
}
}

module.exports = { verify }
9 changes: 9 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,15 @@
resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44"
integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==

"@uniswap/hardhat-v3-deploy@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@uniswap/hardhat-v3-deploy/-/hardhat-v3-deploy-0.1.1.tgz#8cdbb86f495a61385078b76c88df9e79e1b3ce02"
integrity sha512-Qtwj1cNqCgzjtAonoU+morZnZuYCtiPi76ThnW9oYwHAlmcZ6y8jmlP7A2IzNzRaztaafC3bOamLmCNSyYqqpQ==
dependencies:
"@uniswap/v3-core" "1.0.0"
"@uniswap/v3-periphery" "^1.0.1"
cli-table3 "^0.6.0"

"@uniswap/lib@^4.0.1-alpha":
version "4.0.1-alpha"
resolved "https://registry.yarnpkg.com/@uniswap/lib/-/lib-4.0.1-alpha.tgz#2881008e55f075344675b3bca93f020b028fbd02"
Expand Down

0 comments on commit 8728b01

Please sign in to comment.