How to use the web3-eth-abi.default function in web3-eth-abi

To help you get started, we’ve selected a few web3-eth-abi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github celo-org / celo-monorepo / packages / notification-service / src / blockscout / decode.ts View on Github external
function decodeTransferLog(log: Log): Transfer | null {
  if (!log || !log.topics || !log.data) {
    console.error('Invalid transfer log:', log)
    return null
  }

  /**
   * Decode using the parameter signture for an ERC20 Transfer event
   * For unknown reasons, blockscout includes an extra unknown param in the log's topics list
   * Including this unknown param in the input list or decoding won't work
   */
  try {
    // @ts-ignore
    const decodedLog: any = Web3EthAbi.default.decodeLog(
      [
        {
          indexed: true,
          name: 'unknown',
          type: 'address',
        },
        {
          indexed: true,
          name: 'from',
          type: 'address',
        },
        {
          indexed: true,
          name: 'to',
          type: 'address',
        },