New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@appliedblockchain/parity-revert-reason

Package Overview
Dependencies
Maintainers
13
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appliedblockchain/parity-revert-reason

Small function and tests for retrieving Solidity revert reason from require()

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
13
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 03 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc