@appliedblockchain/parity-revert-reason

1.0.3 • Public • Published

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:

  • web3 Web3 instance (only tested with v1.0.0-beta.37)
  • rawTxHash Either tx.raw if using web3.eth.signTransaction or tx.rawTransaction if using web3.eth.accounts.signTransaction
  • fallbackMsg Error message to be thrown if the trace yielded no parseable content.

Returns:

  • Promise<Error> Rejected Promise with either the transaction Revert message or the fallbackMsg.

Run the tests

docker run --rm -d -p 8545:8545 appliedblockchain/parity-solo:v4.0.0

npm test

/@appliedblockchain/parity-revert-reason/

    Package Sidebar

    Install

    npm i @appliedblockchain/parity-revert-reason

    Weekly Downloads

    2

    Version

    1.0.3

    License

    LGPL-3.0

    Unpacked Size

    12.8 kB

    Total Files

    4

    Last publish

    Collaborators

    • ilogico
    • ewan-sims-applied-blockchain
    • lanreayobamidele
    • andyharr15
    • aditya.gupta.appliedblockchain
    • geoffreychalk
    • brunoneves-devops
    • samfcmc
    • tiagorvmartins
    • kjack83
    • losceicco
    • ruisereno
    • telmof
    • andremfaria
    • lbltavaresab
    • ztadic91
    • pedrolino
    • alisson-diniz-ab
    • juniorerico
    • diogopalhais
    • gabspeck
    • ab-ci
    • andycampbell92
    • mirek
    • danchmelo
    • seromenho
    • kennypt
    • zeluisping
    • pmcleite-ab
    • filipepedro
    • mnikolaus
    • bertola
    • lpalmeida
    • lslima91