You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scenario: Create a transaction that calls a contract's method that throws an error.
The sendTransaction/sendSignedTransaction call, internally ends in a call to provider's send/sendAsync. The result object in the callback contains the error message, like "VM exception.... revert" but the code builds an ErrorResponse object with only the message.
Although transaction hash is returned in result.result, it is discarded.
The text was updated successfully, but these errors were encountered:
Same problem here. I need transaction hash from sendTransaction but is seems the only way to get it is monkeypatching RequestManager.prototype.send like this
if (!Jsonrpc.isValidResponse(result)) {
return callback(errors.InvalidResponse(result));
}
if ('result' in result) {
return callback(null, result.result);
}
if (result && result.error) {
return callback(errors.ErrorResponse(result));
}
It works, but monkeypatching is ugly and uses undocumented internals. It would be nice to have more straitforward way to get transaction hash from sendTransaction call.
New promievents API could allow to receive both 'transactionHash' and 'error' events and let the caller decide how to handle such situations.
You are able to get the transaction hash if you use the EventEmitter API instead of the Promise API from the PromiEvent we provide. Be aware that you can't combine the EventEmitter and the Promise.
Scenario: Create a transaction that calls a contract's method that throws an error.
The
sendTransaction/sendSignedTransaction
call, internally ends in a call to provider'ssend/sendAsync
. The result object in the callback contains the error message, like "VM exception.... revert" but the code builds anErrorResponse
object with only the message.Although transaction hash is returned in
result.result
, it is discarded.The text was updated successfully, but these errors were encountered: