becrypto/migrations/9_deploy_stake.js
2023-11-28 11:14:31 +08:00

42 lines
1.4 KiB
JavaScript

const base = require("../scripts/base");
const ERC721Staking = artifacts.require("stake/ERC721Staking");
module.exports = async function (deployer, network, accounts) {
await deployer.deploy(ERC721Staking);
const stakeInstance = await ERC721Staking.deployed();
if (stakeInstance) {
console.log("ERC721Staking successfully deployed.");
console.log("address: " + stakeInstance.address);
}
base.updateArray({
name: "ERC721Staking",
type: "logic",
json: "assets/contracts/ERC721Staking.json",
address: stakeInstance.address,
network,
});
let cfgs = base.loadData({ network });
const gacha = cfgs.find((c) => c.name === "Gacha").address
const testHERO = cfgs.find((c) => c.name === "TestHERO").address
const nfts = [
gacha,
testHERO,
];
for (let i = 0; i < nfts.length; i++) {
await stakeInstance.updateERC721Support(nfts[i], true);
console.log(`success add erc721 support for ${nfts[i]}`);
}
const DAYSECONDS = 24 * 60 * 60;
const periods = [
30 * DAYSECONDS, // 1 month 2592000
90 * DAYSECONDS, // 3 months 7776000
180 * DAYSECONDS, // 6 months 15552000
360 * DAYSECONDS, // 1 year 31104000
720 * DAYSECONDS, // 2 years 62208000
];
for (let i = 0; i < periods.length; i++) {
await stakeInstance.updatePeriods(periods[i], true);
console.log(`success add period ${periods[i]}`);
}
};