Truffle: Events do not fire

Created on 30 Aug 2019  路  9Comments  路  Source: trufflesuite/truffle

- [x] I've asked for help in the Truffle Gitter before filing this issue.

Issue

Events in deployed contracts do not fire.

Steps to Reproduce

  1. truffle migrate --reset (in order to make sure that the contracts are deployed without errors)
  2. Call any function, in any of the contracts, which emits an event.
  3. Events are like they do not exist in the contracts' code.

The only way to see the events fire, is through Remix or Etheratom etc. where I redeploy the contract without Truffle.
For example, if I just press "Deploy" in Remix, call a function which has an emit in its code and run it, everything works as expected (see here for an example).

But, if I press "Deploy at address" and set the address as my, already deployed (from truffle migrate --reset, contract's address, then I receive this.

There are no error messages. Anything.
Ganache's Events tab just stays empty.

Here is a picture of one of my contracts' deployment.

Code Example

Here is a very simple example with an event that I am using in one of my contracts:

contract someContract {
  event newEvent(address indexed);
  function someFunc(address _address) public {
    new SomeContract(_address);
    emit newEvent(_address);
  }
}

Things That I Have Already Tried

  • Reinstalled Nodejs/npm

  • Tried in a different operating system (WIndows 10)

  • Tried to use Truffle's Pet-Shop Box - Added some events and the same issue exists

  • Tried using ganache-cli

One more thing that I'd like to mention, which I do not think that it has to do with my issue in any way, is that I can run Ganache Gui only by doing a:
sudo ./Ganache.

Environment

  • Operating System: Ubuntu 18.04 (same issues with Windows 10)
  • Ethereum client: Ganache 2.1.0
  • Truffle version (truffle version): 5.0.31
  • node version (node --version): 8.10.0
  • npm version (npm --version): 3.5.2

All 9 comments

I think this may have been fixed in Truffle v5.0.33 (this PR). Could you try upgrading and let us know?

I think this may have been fixed in Truffle v5.0.33 (this PR). Could you try upgrading and let us know?

Updated to [email protected]
Nothing changed. Here is a screenshot with the output in Ganache.

Here is my truffle-config file:

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // to customize your Truffle configuration!
  contracts_build_directory: path.join(__dirname, "app/src/contracts"),
  networks: {
    development: {
      host: '127.0.0.1',
      port: 8545,
      network_id: '*'
    },
  },
  compilers: {
     solc: {
       version: "0.5.10"
     }
  }
};

@davidmurdoch is this something you're aware of?

btw @GeorgePals your image links don't work (getting 401 Unauthorized)

btw @GeorgePals your image links don't work (getting 401 Unauthorized)

Oops. Sorry. Fixed it.

Edit:
Here is the migrated .json file of a contract.

Update:
I tried using this tutorial that I found in the "truffle-assertions" package.

It passed the test without any errors.

I also tried to reproduce the problem through Remix.
So, I just added a simple:
event maxBet(uint256);

and changed getMaxBet() function to:

    function getMaxBet() public returns (uint256) {
        emit maxBet(address(this).balance);
        return address(this).balance / 100;
    }

and it worked. I don't really know how or why Remix now had the event in its logs (I used "Deploy at address" and put the truffle's migration of the contract address as the address). (Check screenshot here)

The only issue, is that the event can not be seen in Ganache (see screenshot here).

Okay, now I really do not know what is the problem.
I will try to furthermore investigate the issue.

@GeorgePals, this issue should be fixed in Ganache UI's latest beta. Do you mind giving this beta version a shot and letting me know if it does indeed fix the issue.


Previously, Truffle was (erroneously) including the event's signature in the event's ABI, and Ganache at some point began relying on the event's .signature property in order to filter events. Truffle fixed the issue, but it took me a while to figure out what happened and then finally apply a fix within Ganache. I'll likely release this latest beta to stable next week (pending the outcome of Hurricane Dorian, as I might be it's path and could lose power this week :-) ).

Just checked the latest beta of Ganache and everything seems to work flawlessly.
Finally! I can see all the events.

The only _issue_, is that I still don't have the same output logs on Remix when I just deploy and deploy at address (but everything is okay - data is stored in the blockchain, I have already checked this).
If you think that this is okay, you may close the issue.

Thank you @gnidan and @davidmurdoch.

@GeorgePals there's probably something we can do here to make this more clear, but for now I'm just going to close this issue. Glad to hear your problem has been solved! Thanks for raising it!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EmanHerawy picture EmanHerawy  路  3Comments

rotcivegaf picture rotcivegaf  路  3Comments

timothywangdev picture timothywangdev  路  3Comments

maximilianh picture maximilianh  路  3Comments

tcurdt picture tcurdt  路  3Comments