0

My event fires, but the last parameter is never logged. It appears as if it doesn't even exist. Here is my solidity code:

pragma solidity >=0.5.6;

contract EventTest {
  event marketCreated(address[] virtualShareAddresses, address market, uint256 indexed endTime, string description, string extraInfo);//categorical
  event marketCreated(address[2] virtualShareAddresses, address market, uint256 indexed endTime, string description, string extraInfo);//binary
  event marketCreated(address[2] virtualShareAddresses, address market, uint256 indexed endTime, string description, string extraInfo, int256 _minPrice, int256 _maxPrice, uint256 _numTicks);//scalar


  function createYesNoMarket(
    uint256 _endTime,
    string memory _description,
    string memory _extraInfo
    ) public payable returns (bool) 

  {
    address[2] memory virtualShareAddresses;
    address newMarket = address(0);
    virtualShareAddresses[0] = address(1);
    virtualShareAddresses[1] = address(2);
    emit marketCreated(virtualShareAddresses, address(newMarket), _endTime, _description, _extraInfo);
    return true;
  }
}

here's how I'm calling the event with web3.js:

contract.methods.createYesNoMarket(1575158400, "Will it rain on Friday in Sacramento California?", "foo").send({from: '0x5680CA2e3b4F8bC043aCeB31837c89DbA8bFBa75', gas: 6000000}, (error, hash) => {
  console.log(hash)
  console.log(error)
})

and here's my event.returnValues logged to the console:

{ '0': 
   [ '0x0000000000000000000000000000000000000001',
     '0x0000000000000000000000000000000000000002' ],
  '1': '0x0000000000000000000000000000000000000000',
  '2': BigNumber { _hex: '0x5de30280' },
  '3': 'Will it rain on Friday in Sacramento California?',
  endTime: BigNumber { _hex: '0x5de30280' },
  virtualShareAddresses: 
   [ '0x0000000000000000000000000000000000000001',
     '0x0000000000000000000000000000000000000002' ],
  market: '0x0000000000000000000000000000000000000000',
  description: 'Will it rain on Friday in Sacramento California?' }

As you can see the extraInfo field is never logged. Anyone know why this is?

  • Use indexed for each important parameter. You can use it at most 3 times per event declaration, so choose wisely. – goodvibration May 4 at 20:34
1

You are using event log overloading and arrays in the event log.

From superficial testing, I found it works as expected if you drop either of those features.

If you comment out the logs that aren't actually used in this test then things improve.

pragma solidity >=0.5.6;

contract EventTest {
  //event marketCreated(address[] virtualShareAddresses, address market, uint256 indexed endTime, string description, string extraInfo);//categorical
  event marketCreated(address[2] virtualShareAddresses, address market, uint256 indexed endTime, string description, string extraInfo);//binary
  //event marketCreated(address market, uint256 indexed endTime, string description, string extraInfo, int256 _minPrice, int256 _maxPrice, uint256 _numTicks);//scalar


  function createYesNoMarket(
    uint256 _endTime,
    string memory _description,
    string memory _extraInfo
    ) public payable returns (bool) 

  {
    address[2] memory virtualShareAddresses;
    address newMarket = address(0);
    virtualShareAddresses[0] = address(1);
    virtualShareAddresses[1] = address(2);
    emit marketCreated(virtualShareAddresses, address(newMarket), _endTime, _description, _extraInfo);
    return true;
  }
}

In Remix the log is exactly as expected:

[
    {
        "from": "0xba8dc1a692093d8abd34e12aa05a4fe691121bb6",
        "topic": "0x723cfaf3d6cd591c1439c0b9b08b74eaa46598df92bd434a707f33f48fa8bbd8",
        "event": "marketCreated",
        "args": {
            "0": [
                "0x0000000000000000000000000000000000000001",
                "0x0000000000000000000000000000000000000002"
            ],
            "1": "0x0000000000000000000000000000000000000000",
            "2": "1575158400",
            "3": "Will it rain on Friday in Sacramento California?",
            "4": "foo",
            "virtualShareAddresses": [
                "0x0000000000000000000000000000000000000001",
                "0x0000000000000000000000000000000000000002"
            ],
            "market": "0x0000000000000000000000000000000000000000",
            "endTime": "1575158400",
            "description": "Will it rain on Friday in Sacramento California?",
            "extraInfo": "foo",
            "length": 5
        }
    }
]

With event overloading, there seems to be difficulty interpreting the log:

[
    {
        "from": "0x9876e235a87f520c827317a8987c9e1fde804485",
        "data": "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000003057696c6c206974207261696e206f6e2046726964617920696e2053616372616d656e746f2043616c69666f726e69613f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003666f6f0000000000000000000000000000000000000000000000000000000000",
        "topics": [
            "0x723cfaf3d6cd591c1439c0b9b08b74eaa46598df92bd434a707f33f48fa8bbd8",
            "0x000000000000000000000000000000000000000000000000000000005de30280"
        ]
    }
]

Event overloading should work. It can be shown to work if the array element is removed:

contract EventTest {
  // event marketCreated(address market, uint256 indexed endTime, string description, string extraInfo);//categorical
  event marketCreated(address market, uint256 indexed endTime, string description, string extraInfo);//binary
  event marketCreated(address market, uint256 indexed endTime, string description, string extraInfo, int256 _minPrice, int256 _maxPrice, uint256 _numTicks);//scalar


  function createYesNoMarket( ...

    emit marketCreated(address(newMarket), _endTime, _description, _extraInfo);

That also works as expected:

    [
    {
        "from": "0xde6a66562c299052b1cfd24abc1dc639d429e1d6",
        "topic": "0x0d1dda2dfb9ffa94623e4da9d1b79c3d2f94286cf597898c7cb8551e2971b988",
        "event": "marketCreated",
        "args": {
            "0": "0x0000000000000000000000000000000000000000",
            "1": "1575158400",
            "2": "Will it rain on Friday in Sacramento California?",
            "3": "foo",
            "market": "0x0000000000000000000000000000000000000000",
            "endTime": "1575158400",
            "description": "Will it rain on Friday in Sacramento California?",
            "extraInfo": "foo",
            "length": 4
        }
    }
]

So, even though arrays are okay, and even though event overloading is okay, there does appear to be a problem using those features together. This is possibly a candidate for an issue report, or possibly someone will chime in with a known reason why these features are mutually exclusive.

Hope it helps.

  • Thanks! I'll file an issue report for this if nobody chimes in in about it the next few days... – skrrrraaaa May 5 at 16:34
  • Thanks for voting and accepting. I hope you don't mind. I edited the question title to possibly draw more eyeballs to the interesting issue. – Rob Hitchens - B9lab May 5 at 19:38
  • anything that answers my question is fine by me – skrrrraaaa May 5 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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