New answers tagged

1

emitting Events makes use of a log storage, which as you've noted is a 4th form of contract information that is much cheaper than the other three kinds of accessible from solidity (memory, storage, stack). EVM nodes are not required to keep logs forever and can garbage collect old logs to save space. Dapps listening for these logs cannot rely on them being ...


1

The main difference is that events can't change state while variable assignation (SSTORE) can. State it one of the most important aspects of Ethereum contracts. State can be modified and it can be read. Emitting events does not modify any state (at least not any state which could influence contracts) and basically nobody has to care about the events - they ...


0

You can try out web sockets by adding the following in truffle-config.js file. networks: { development: { provider: function() { return new Web3.providers.WebsocketProvider("ws://localhost:7545"); }, network_id: "5777" } ... } You will have to import Web3.


1

From the Solidity documentation: If the event is declared as anonymous the topics[0] is not generated Unlike regular events, anonymous events do not contain an indexed keccak of their signature. Because of this they cannot be easily searched for, or decoded with certainty unless you have the specific contract ABI. To make an event anonymous, include the ...


1

You can do this by checking the timestamp of the block that the event was included in. For something like web3.js, you can use getBlock: web3.eth.getBlock(blockHashOrBlockNumber [, returnTransactionObjects] [, callback]) Additionally, you can include the timestamp in the event itself. It would look like this: pragma solidity ^0.5.5; contract MyEvetTest { ...


0

On top of Rosco's and Nick's answers, it could also be helpful to know the --show-events flag for debugging. You can use it like this: truffle test --show-events


0

If you are using ContractInstance.events.allEvents() there is a parameter 'fromBlock' which defaults to 'LatestBlock', so to get older events you should set a block number as a start point


1

Yes you can. I put the answer in plain and simple language, in case future people find this question. But your problem is most likely related to how you're filtering events.


1

You listen the event from the latest block so if your event is not in the latest one you don’t have any event. Try with fromBlock: 6039496 for example.


Top 50 recent answers are included