I have a factory contract which has a function which returns a new contract:
contract AddOrRemoveAdminVotingBuilder
{
function build(
address pPlatform,
address pAdminManager
)
external
returns(address)
{
return address(
new AddOrRemoveAdminVoting(
pPlatform,
pAdminManager
)
);
}
}
I'm trying to receive the address from my website script with web3. The usual async function call returns txhash.
Tried this:
votingBuilders[0].build(platform.address, adminManagerAddress, function(error, result)
{
let txhash = result;
console.log("tx: " + txhash);
let interval = setInterval(function()
{
web3.eth.getTransactionReceipt(txhash, function(error, result)
{
if(!error && result !== null)
{
if(result["status"] == "0x0") // fail
{
}
else if(result["status"] == "0x1") // success
{
incomingVotes.push(result);
console.log(result);
clearInterval(interval);
}
}
});
}, 1000);
});
This code puts the successfuly mined transaction to an array. But how can I get the return address of newly created cotract from the return value?