1.0.3 • Published 6 years ago

@appliedblockchain/parity-revert-reason v1.0.3

Weekly downloads
-
License
LGPL-3.0
Repository
github
Last release
6 years ago

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

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago