2024-03-06 16:50:59 -06:00
|
|
|
const { ethers } = require('hardhat');
|
2024-03-17 11:48:05 -05:00
|
|
|
const fs = require('fs');
|
|
|
|
|
2024-03-17 13:35:51 -05:00
|
|
|
const contractAddresses = require('../contract-addresses.json');
|
2024-03-17 12:06:06 -05:00
|
|
|
|
2024-03-17 11:48:05 -05:00
|
|
|
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}`);
|
2024-03-17 11:48:05 -05:00
|
|
|
contractAddresses[network].DAO = dao.target;
|
2024-03-18 14:03:53 -05:00
|
|
|
fs.copyFileSync('./artifacts/contracts/DAO.sol/DAO.json', '../client/src/assets/DAO.json');
|
2024-03-04 19:33:06 -06:00
|
|
|
|
2024-03-18 14:03:53 -05:00
|
|
|
const deployWorkContract = async (name, price) => {
|
|
|
|
const contract = await ethers.deployContract('Work1', [dao.target, price]);
|
|
|
|
await contract.waitForDeployment();
|
|
|
|
console.log(`${name} deployed to ${contract.target}`);
|
|
|
|
contractAddresses[network][name] = contract.target;
|
|
|
|
fs.copyFileSync(`./artifacts/contracts/${name}.sol/${name}.json`, `../client/src/assets/${name}.json`);
|
|
|
|
};
|
2024-03-04 19:33:06 -06:00
|
|
|
|
2024-03-18 14:03:53 -05:00
|
|
|
await deployWorkContract('Work1', ethers.parseEther('0.001'));
|
|
|
|
await deployWorkContract('Onboarding', ethers.parseEther('0.001'));
|
2024-03-17 11:48:05 -05:00
|
|
|
|
2024-03-17 13:35:51 -05:00
|
|
|
fs.writeFileSync('../client/src/contract-addresses.json', JSON.stringify(contractAddresses, null, 2));
|
|
|
|
console.log('Wrote file', fs.realpathSync('../client/src/contract-addresses.json'));
|
|
|
|
|
|
|
|
fs.writeFileSync('./contract-addresses.json', JSON.stringify(contractAddresses, null, 2));
|
|
|
|
console.log('Wrote file', fs.realpathSync('./contract-addresses.json'));
|
2024-03-17 12:30:12 -05:00
|
|
|
|
2024-03-17 13:24:49 -05:00
|
|
|
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;
|
|
|
|
});
|