Skip to main content

decodeLog

Callable

  • decodeLog<ReturnType>(inputs: readonly AbiParameter[] | AbiParameter[], data: string, topics: string | string[]): ReturnType

  • Decodes ABI-encoded log data and indexed topic data.

    @example
    let res = web3.eth.abi.decodeLog(
    [
    {
    type: "string",
    name: "myString",
    },
    {
    type: "uint256",
    name: "myNumber",
    indexed: true,
    },
    {
    type: "uint8",
    name: "mySmallNumber",
    indexed: true,
    },
    ],
    "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000748656c6c6f252100000000000000000000000000000000000000000000000000",
    [
    "0x000000000000000000000000000000000000000000000000000000000000f310",
    "0x0000000000000000000000000000000000000000000000000000000000000010",
    ]
    );
    > {
    '0': 'Hello%!',
    '1': 62224n,
    '2': 16n,
    __length__: 3,
    myString: 'Hello%!',
    myNumber: 62224n,
    mySmallNumber: 16n
    }

    Type parameters

    Parameters

    • inputs: readonly AbiParameter[] | AbiParameter[]

      A AbiParameter input array. See the Solidity documentation for a list of types.

    • data: string

      The ABI byte code in the data field of a log.

    • topics: string | string[]

      An array with the index parameter topics of the log, without the topic[0] if its a non-anonymous event, otherwise with topic[0]

    Returns ReturnType

    • The result object containing the decoded parameters.