Commit 3d214db1 authored by yann300's avatar yann300

use ethers to decode revert reason

parent c0297d9d
'use strict'
var ethJSABI = require('ethereumjs-abi')
var ethers = require('ethers')
module.exports = {
/**
......@@ -86,7 +86,8 @@ module.exports = {
var returnData = txResult.result.vm.return
// It is the hash of Error(string)
if (returnData && (returnData.slice(0, 4).toString('hex') === '08c379a0')) {
var reason = ethJSABI.rawDecode(['string'], returnData.slice(4))[0]
var abiCoder = new ethers.utils.AbiCoder()
var reason = abiCoder.decode(['string'], returnData.slice(4))[0]
msg = `\tThe transaction has been reverted to the initial state.\nReason provided by the contract: "${reason}".`
} else {
msg = `\tThe transaction has been reverted to the initial state.\nNote: The constructor should be payable if you send value.`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment