add hardhat deploy logic

Signed-off-by: AlienTornadosaurusHex <>
This commit is contained in:
AlienTornadosaurusHex 2023-06-12 19:39:42 +00:00
parent 015c5d8a14
commit 80078475d5
6 changed files with 132 additions and 6 deletions

7
.env.example Normal file

@ -0,0 +1,7 @@
MAINNET_RPC_URL=
ETHERSCAN_KEY=
PRIVATE_KEY=
GOERLI_RPC_URL=
SEOPLIA_RPC_URL=
RINKEBY_RPC_URL=

7
.gitignore vendored

@ -20,6 +20,11 @@ package-lock.json
# yarn # yarn
yarn.lock yarn.lock
yarn-error.log
# VScode files # VScode files
.vscode .vscode
# hh
artifacts
cache_hardhat

5
config.js Normal file

@ -0,0 +1,5 @@
module.exports = {
torn: "0x77777FeDdddFfC19Ff86DB637967013e6C6A116C",
governanceProxy: "0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce",
registryProxy: "0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2"
}

76
hardhat.config.js Normal file

@ -0,0 +1,76 @@
require('dotenv').config()
require('@nomicfoundation/hardhat-foundry')
require('@nomicfoundation/hardhat-verify')
require('@nomiclabs/hardhat-ethers')
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: {
compilers: [
{
version: '0.6.2',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: '0.6.12',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
},
networks: {
hardhat: {
forking: {
url: `${process.env.MAINNET_RPC_URL}`,
},
chainId: 1,
loggingEnabled: false,
allowUnlimitedContractSize: false,
},
rinkeby: {
url: `${process.env.RINKEBY_RPC_URL}`,
accounts: `${process.env.PRIVATE_KEY}`
? [`${process.env.PRIVATE_KEY}`]
: { mnemonic: 'test test test test test junk' },
},
goerli: {
url: `${process.env.GOERLI_RPC_URL}`,
accounts: `${process.env.PRIVATE_KEY}`
? [`${process.env.PRIVATE_KEY}`]
: { mnemonic: 'test test test test test junk' },
},
sepolia: {
url: `${process.env.SEPOLIA_RPC_URL}`,
accounts: `${process.env.PRIVATE_KEY}`
? [`${process.env.PRIVATE_KEY}`]
: { mnemonic: 'test test test test test junk' },
},
mainnet: {
url: `${process.env.MAINNET_RPC_URL}`,
accounts: `${process.env.PRIVATE_KEY}`
? [`${process.env.PRIVATE_KEY}`]
: { mnemonic: 'test test test test test junk' },
},
},
mocha: {
timeout: 9999999999 /* The following simply does not work: ignore: ["factory.with.registry.test.js", "sidechain.instance.factory.test.js"] */,
},
spdxLicenseIdentifier: {
overwrite: true,
runOnCompile: true,
},
etherscan: {
apiKey: `${process.env.ETHERSCAN_KEY}`,
},
}

@ -14,15 +14,20 @@
"author": "Theo", "author": "Theo",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"bignumber.js": "^9.1.1",
"dotenv": "^16.1.3",
"web3": "^1.10.0",
"web3-utils": "^1.10.0",
"@openzeppelin/contracts": "^3.2.0-rc.0", "@openzeppelin/contracts": "^3.2.0-rc.0",
"@openzeppelin/upgrades-core": "^1.0.1", "@openzeppelin/upgrades-core": "^1.0.1",
"torn-token": "^1.0.4" "bignumber.js": "^9.1.1",
"dotenv": "^16.1.4",
"torn-token": "^1.0.4",
"web3": "^1.10.0",
"web3-utils": "^1.10.0"
}, },
"devDependencies": { "devDependencies": {
"@nomicfoundation/hardhat-foundry": "^1.0.1",
"@nomicfoundation/hardhat-verify": "^1.0.1",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"ethers": "^5",
"hardhat": "^2.15.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^5.1.3" "typescript": "^5.1.3"
} }

28
scripts/deployProposal.js Normal file

@ -0,0 +1,28 @@
const hre = require('hardhat')
const config = require("../config")
const { ethers } = hre
async function main() {
const factory_staking = await ethers.getContractFactory("TornadoStakingRewards")
const factory_proposal = await ethers.getContractFactory("Proposal")
const staking = await factory_staking.deploy(config.governanceProxy, config.torn, config.registryProxy)
console.log("\nStaking contract impl successfully deployed @ " + staking.address + '\n')
await hre.run('verify:verify', {
address: staking.address,
constructorArguments: [config.governanceProxy, config.torn, config.registryProxy],
})
const proposal = await factory_proposal.deploy(staking.address)
console.log("\nProposal 25 successfully deployed @ " + proposal.address + '\n')
await hre.run('verify:verify', {
address: proposal.address,
constructorArguments: [staking.address],
})
}
main().then((res) => console.log(res ?? "\nScript finished.\n"))