When I instantiate a contract with myContract.new() like this:
MyContract.new({ from: addr, data: code, gas: gas, gasPrice: price }, function (error, contract) {
if (!error) {
if (typeof contract.address != 'undefined') {
console.log("second call");
console.log('Confirmed. address: '
+ contract.address
+ ' transactionHash: '
+ contract.transactionHash);
} else {
console.log("first call");
}
} else {
console.log('geth callback error: ' + error);
}
});
.. the function gets called twice. First with the transaction hash (not shown) and the second with a contract address (shown).
Should I expect subsequent use of the contracts methods that are transactional to call the callback twice?
var myContract = MyContract.at(cAddr);
myContract.myFunction(par1, par2,
{ from: addr, data: code, gas: gas, gasPrice: price },
function (error, obj) {
if (error) {
console.log("whoops!");
} else {
console.log("myFunction called");
}
});
.newis still a transaction behind the scenes and is currently a special case where its callback is called twice; for a contract method you don't get called a second time and you need to check the receipt manually as you've said. – eth Jul 25 '16 at 03:55