-
-
Save Daltonic/021ee2f4d05f4f7c1e80452e6fdd263f to your computer and use it in GitHub Desktop.
Event X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ethers } = require('hardhat') | |
const fs = require('fs') | |
async function deployContract() { | |
let contract | |
const servicePct = 5 | |
try { | |
contract = await ethers.deployContract('DappEventX', [servicePct]) | |
await contract.waitForDeployment() | |
console.log('Contracts deployed successfully.') | |
return contract | |
} catch (error) { | |
console.error('Error deploying contracts:', error) | |
throw error | |
} | |
} | |
async function saveContractAddress(contract) { | |
try { | |
const address = JSON.stringify( | |
{ | |
dappEventXContract: contract.target, | |
}, | |
null, | |
4 | |
) | |
fs.writeFile('./contracts/contractAddress.json', address, 'utf8', (error) => { | |
if (error) { | |
console.error('Error saving contract address:', err) | |
} else { | |
console.log('Deployed contract address:', address) | |
} | |
}) | |
} catch (error) { | |
console.error('Error saving contract address:', error) | |
throw error | |
} | |
} | |
async function main() { | |
let contract | |
try { | |
contract = await deployContract() | |
await saveContractAddress(contract) | |
console.log('Contract deployment completed successfully.') | |
} catch (error) { | |
console.error('Unhandled error:', error) | |
} | |
} | |
main().catch((error) => { | |
console.error('Unhandled error:', error) | |
process.exitCode = 1 | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment