dgf-prototype/ethereum/scripts/deploy.js

36 lines
1.2 KiB
JavaScript

const { ethers } = require('hardhat');
const fs = require('fs');
const contractAddresses = require('contract-config/addresses.json');
const contractAddressesWritePath = '../contract-config/addresses.json';
const network = process.env.HARDHAT_NETWORK;
async function main() {
const dao = await ethers.deployContract('DAO');
await dao.waitForDeployment();
console.log(`DAO deployed to ${dao.target}`);
contractAddresses[network].DAO = dao.target;
const WORK1_PRICE = ethers.parseEther('0.001');
const work1 = await ethers.deployContract('Work1', [dao.target, WORK1_PRICE]);
await work1.waitForDeployment();
console.log(`Work1 deployed to ${work1.target}`);
contractAddresses[network].Work1 = work1.target;
fs.writeFileSync(contractAddressesWritePath, JSON.stringify(contractAddresses, null, 2));
console.log('Wrote file', fs.realpathSync(contractAddressesWritePath));
fs.copyFileSync('./artifacts/contracts/DAO.sol/DAO.json', '../contract-config/DAO.json');
fs.copyFileSync('./artifacts/contracts/Work1.sol/Work1.json', '../contract-config/Work1.json');
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});