You can observe the behavior via the following contract which I've deployed to Polygon Mumbai at 0x33c059160280a45725d9509c120c6b30a44a61a4:

pragma solidity ^0.8.19;

contract EventWithCustomTypeArg
    struct Custom
        uint value;

    Custom private c;

    event CustomValueSet(Custom _c);
    event CustomValueSet(uint _value);

    function setCustomValue(uint _value) public
        c.value = _value;
        emit CustomValueSet(c);
        emit CustomValueSet(_value);

As you can see, I've executed the setCustomValue() function, passing it 5 as the argument. As a result, both the event CustomValueSet(Custom _c) and the event CustomValueSet(uint _value) have been emitted (in this order), but while the latter appears fully decoded/human-readable in the Tx Logs, the Custom argument, the argument value and the event name itself of the former are encoded: enter image description here

Why is that? I can imagine why the argument of the custom type appears encoded, but why isn't the event name human-readable, at least?

1 Answer 1


Polygonscan or other blockchain developers are not necessarily the most user-friendly way to decode complex blockchain data, such as the custom events data that you have there.

However, it is possible to decode the data using API providers, such as Moralis. You can use getContractEvents API here to do so. So simply you'll need to sign up and get Moralis API Key, then install Moralis SDK

npm install moralis

and copy the code as follows:

import Moralis from 'moralis';

try {
  await Moralis.start({
    apiKey: "YOUR_API_KEY"

  const response = Moralis.EvmApi.events.getContractEvents({
    "chain": "mumbai",
    "topic": "0xd43c5030eb09cb86062bca5370e1ef5ce38fdc025e9c26114b94d6d1cbdcd2ed",
    "address": "0x33C059160280A45725D9509C120c6B30A44A61A4",
    "anonymous": false,
    "inputs": [
        "components": [
            "internalType": "uint256",
            "name": "value",
            "type": "uint256"
        "indexed": false,
        "internalType": "struct EventWithCustomTypeArg.Custom",
        "name": "_c",
        "type": "tuple"
    "name": "CustomValueSet",
    "type": "event"

} catch (e) {

and the response should be the decoding of your event data like this

  "total": null,
  "page": 0,
  "page_size": 100,
  "result": [
      "transaction_hash": "0x1bbe419ef6c9ca5ce3dc452309f73fe80503d2f10672be165c6378fed47b7448",
      "address": "0x33c059160280a45725d9509c120c6b30a44a61a4",
      "block_timestamp": "2023-03-09T14:33:08.000Z",
      "block_number": "32902536",
      "block_hash": "0x078d29120118dbc93a05dd018ee97c6d6473476203407b4c0f90e1e38c5846cb",
      "data": {
        "_c": [

Hope this helps out! Let me know if you have any questions! 😊

P.S. I work at Moralis

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.