diff --git a/script/12_deploy_fixed_reward_pool.ts b/script/12_deploy_fixed_reward_pool.ts new file mode 100644 index 0000000..69dcccd --- /dev/null +++ b/script/12_deploy_fixed_reward_pool.ts @@ -0,0 +1,41 @@ +import { ethers, upgrades } from 'hardhat'; +require('dotenv').config(); + +async function main() { + if (!process.env.DEVICE_NFT) { + console.log(`Please provide DEVICE_NFT address`); + return; + } + if (!process.env.START_BLOCK) { + console.log(`Please provide START_BLOCK`); + return; + } + if (!process.env.REWARD_PER_BLOCK) { + console.log(`Please provide REWARD_PER_BLOCK (unit: IOTX)`); + return; + } + + let owner = (await ethers.getSigners())[0].address; + if (process.env.OWNER) { + owner = process.env.OWNER; + } + + const ownedWeightedNFT = await ethers.deployContract('OwnedWeightedNFT', [process.env.DEVICE_NFT, owner]); + await ownedWeightedNFT.waitForDeployment(); + + const pool = await upgrades.deployProxy( + await ethers.getContractFactory('FixedRewardPool'), + [ownedWeightedNFT.target, process.env.START_BLOCK, ethers.parseEther(process.env.REWARD_PER_BLOCK)], + { + initializer: 'initialize', + }, + ); + await pool.waitForDeployment(); + + console.log(`FixedRewardPool for ${process.env.DEVICE_NFT} deployed to ${pool.target}`); +} + +main().catch(err => { + console.error(err); + process.exitCode = 1; +});