I have 2 hardhat scripts
1) deployment
2) add liquidity
I want to export the contract address from the deployment script and require it in my liquidity script. I've placed the export statement in the main() function of the deployment scripts but when I require it in the liquidity script it seems to run the main() function of the deployment script.
What's the best way to go about this? Should the export statement be placed outside of the main() function?
Here's my scripts: https://github.com/fondofdogs/MoonSafe/tree/main/scripts
Jul 15, 2022, 9:28 AM
what i would do is to save in a json file the contract address and then import that json file from the second script
something like
let fs =require('fs')
fs.writeSync('file.json',JSON.stringify({address:theContractAddress}))
let fs =require('fs')
fs.writeSync('file.json',JSON.stringify({address:theContractAddress}))
and then from the second script
let data_from_json = require('./file.json')
data_from_json.address // here's the updated address
let data_from_json = require('./file.json')
data_from_json.address // here's the updated address
so every time you run the first script it will remove the old contract address and add the last one
Jul 15, 2022, 10:26 AM
Thats perfect, thanks!
Jul 15, 2022, 11:00 AM