@appliedblockchain/parity-revert-reason
v1.0.3
Published
Small function and tests for retrieving Solidity revert reason from require()
Downloads
12
Maintainers
Readme
Get EVM revert reason on Parity
(if stated, as in require(false, "Message"))
web3.js has a Debug module and debug.getTransactionTrace
but this will call a JSON-RPC API only implemented in Geth, not Parity.
For Parity, one has to call trace_rawTransaction.
For more info: https://github.com/paritytech/parity-ethereum/issues/9887.
It should probably use RLP.decode() but can't get it to work.
Usage
const { throwWithRevertReason } = require('@appliedblockchain/parity-revert-reason')
const method = 'myMethod'
const args = []
const contract = new web3.eth.Contract(abi, address)
const txParams = {...}
const tx = await web3.eth.signTransaction(txParams)
await web3.eth.sendSignedTransaction(tx.raw).catch(async () => {
const fallbackErrMsg = `Transaction ${method}(${inspect(args)}) (nonce: ${txParams.nonce}) failed.`
await throwWithRevertReason(web3, tx.raw)
})throwWithRevertReason(web3, rawTxHash[, fallbackMsg])
Params:
web3Web3 instance (only tested with v1.0.0-beta.37)rawTxHashEithertx.rawif usingweb3.eth.signTransactionortx.rawTransactionif usingweb3.eth.accounts.signTransactionfallbackMsgError message to be thrown if the trace yielded no parseable content.
Returns:
Promise<Error>Rejected Promise with either the transaction Revert message or thefallbackMsg.
Run the tests
docker run --rm -d -p 8545:8545 appliedblockchain/parity-solo:v4.0.0
npm test
