Reputation: 417
With Truffle we get a nice wrapper for contracts. But it has one feature making me headaches:
Example from documentation:
MetaCoin.at(contract_address).then(function(instance) {
coin = instance;
return coin.sendCoin(account_two, 3, {from: account_one});
}).then(function(result) {
// This code block will not be executed until truffle-contract has verified
// the transaction has been processed and it is included in a mined block.
// truffle-contract will error if the transaction hasn't been processed in 120 seconds.
})
This raises four questions:
function(result, error)
) or the whole thing (.then( function(result) {...} ).catch(e)
)? I can't test it locally with Ganache.Especially problem #1 is causing me a headache.
Upvotes: 1
Views: 972
Reputation: 82563
The timeout is solely a truffle thing. The network does not time out, and when developing an app with web3 or similar wrappers, you simply keep listening until the tx is miner, or the page is closed.
When you make a transaction in web3, you will receive the txhash as part of the response, even before it is mined. You can display that to the user, along with a pending status, and use Web3's filters to set a listener for a callback when it is mined, without running into timeout issues.
Upvotes: 1