I understand how the below web3js code block works, adapted from here:
https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethcontract
But how does one save the contract address programmatically? One could, I suppose, open a file and persist it within the callback, but not that. =:)
And I don't believe the myContractReturned identifier helps us; given the asynchronous nature of JavaScript (not to mention the mining delay). How does one even use that?
It's kind of an academic question (because there's no guarantee an address will even be generated), but curious as to what friends in the community have done (or thought). Thank you!
--
var myContractReturned = MyContract.new(param1,param2, {
from:mySenderAddress,
data:bytecode,
gas:gasEstimate},
function(error, myContract){
if(!error) {
if(!myContract.address) {
// Step-1: Runs on contract submission/deployment.
console.log(myContract.transactionHash)
}
else {
// Step-2: Runs after contract is deployed.
console.log(myContract.address)
}
}
});