Created
September 1, 2022 17:11
-
-
Save helderjnpinto/5fca2f3b7826aa359bb761ca49524386 to your computer and use it in GitHub Desktop.
ethers decode revertReason besu ethereum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { revertReason } = await ethers.provider.send('eth_getTransactionReceipt', [error.transaction.hash]) | |
const output = revertReason.slice(2) | |
const strLen = parseInt(output.slice(8 + 64, 8 + 128), 16) | |
const reason = ethers.utils.toUtf8String('0x' + output.slice(8 + 128, 8 + 128 + (strLen * 2))) | |
console.log('🚀 ~ reason', reason) | |
console.log('with abi decoder', ethers.utils.defaultAbiCoder.decode(['string'], ethers.utils.hexDataSlice(revertReason, 4))[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment