Skip to content

Instantly share code, notes, and snippets.

@helderjnpinto
Created September 1, 2022 17:11
Show Gist options
  • Save helderjnpinto/5fca2f3b7826aa359bb761ca49524386 to your computer and use it in GitHub Desktop.
Save helderjnpinto/5fca2f3b7826aa359bb761ca49524386 to your computer and use it in GitHub Desktop.
ethers decode revertReason besu ethereum
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