solidity.ts 445 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
import { ethers } from 'ethers'

export const decodeSolidityRevert = (revert: string) => {
  const iface = new ethers.utils.Interface([
    {
      inputs: [
        {
          internalType: 'string',
          name: 'message',
          type: 'string',
        },
      ],
      name: 'Error',
      outputs: [],
      stateMutability: 'nonpayable',
      type: 'function',
    },
  ])

  return iface.decodeFunctionData('Error', revert)[0]
}