dgf-prototype/ethereum/scripts/deploy.js

37 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-03-06 16:50:59 -06:00
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;
2024-03-04 19:33:06 -06:00
async function main() {
2024-03-06 16:50:59 -06:00
const dao = await ethers.deployContract('DAO');
await dao.waitForDeployment();
2024-03-04 19:33:06 -06:00
2024-03-06 16:50:59 -06:00
console.log(`DAO deployed to ${dao.target}`);
contractAddresses[network].DAO = dao.target;
2024-03-04 19:33:06 -06:00
2024-03-06 16:50:59 -06:00
const WORK1_PRICE = ethers.parseEther('0.001');
const work1 = await ethers.deployContract('Work1', [dao.target, WORK1_PRICE]);
await work1.waitForDeployment();
2024-03-04 19:33:06 -06:00
2024-03-06 16:50:59 -06:00
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));
2024-03-17 13:24:49 -05:00
fs.copyFileSync('./artifacts/contracts/DAO.sol/DAO.json', '../client/src/assets/DAO.json');
fs.copyFileSync('./artifacts/contracts/Work1.sol/Work1.json', '../client/src/assets/Work1.json');
console.log('Copied ABIs to', fs.realpathSync('../client/src/assets'));
2024-03-04 19:33:06 -06:00
}
// 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;
});