Skip to main content
Share Your Experience: Take the 2024 Developer Survey
73 votes
Accepted

What are Solidity events and how they are related to topics and logs?

Topics are indexed parameters to an event. topic[0] always refers to the hash of the hash of the event itself, and can have up to 3 indexed arguments, which will each be reflected in the topics. EVM ...
Mikko Ohtamaa's user avatar
52 votes
Accepted

How does Ethereum make use of bloom filters?

Events in the ethereum system must be easily searched for, so that applications can filter and display events, including historical ones, without undue overhead. At the same time, storage space is ...
Nick Johnson's user avatar
  • 8,174
36 votes
Accepted

How to access the event log by knowing the contract address (web3)?

Take a look at web3.eth.filter and watch. Something like this: const filter = web3.eth.filter({ fromBlock: 0, toBlock: 'latest', address: contractAddress, topics: [web3.sha3('newtest(string,...
eth's user avatar
  • 85.9k
33 votes
Accepted

Are events permanently stored and reliably available to contracts in the future?

Firstly, events are not accessible to contracts. The simple answer is Yes, events are permanently stored. The nuanced answer is Yes, events are as permanent as the blockchain. It helps to realize ...
eth's user avatar
  • 85.9k
26 votes

What's the Solidity statement to print data to the console?

You are most likely looking for Events. Not only do they help with debugging, but they are useful in normal production code. Events are declared like functions, like so: event VoteCast(address voter, ...
Matthew Schmidt's user avatar
25 votes

How to make parity write logs?

More recent versions of Parity allow native log file creation: parity --log-file /path/to/parity.log And set the log level to error, warn, info, debug or trace, with: parity -lsync,tpc=trace Where ...
q9f's user avatar
  • 32.9k
25 votes

How can I view event logs for an ethereum contract?

To get event logs of the past, you can instantiate the event with a block range, and use the myEvent.get function to retrieve events. In your example, we could do something minimal like this: let ...
Travis Jacobs's user avatar
24 votes
Accepted

Is searching data stored in event logs prohibitively slow?

I will try to anwser your question. I worked on bloom filters in cpp-ethereum and Parity. will retrieving event logs become prohibitively slow as the blockchain becomes larger? Not necessarily. ...
debris's user avatar
  • 861
24 votes

Where do contract event logs get stored in the Ethereum architecture?

To help with @Peter's answer, it helps to realize what are events and logs. Events, logs, and event logs are usually Ethereum terms that are interchangeable (in some contexts a particular term is ...
eth's user avatar
  • 85.9k
18 votes
Accepted

What does Parity logs means?

Your ideas for the first few fields are correct. The remainder are as follows: 0 Mgas/s - million gas processed/s 13399+ - unverified queue size 0 - verified queue size #2360201 - last imported ...
Richard Horrocks's user avatar
17 votes
Accepted

from solidity: TypeError: Member "log" not found or not visible after argument-dependent lookup in type(library console)

You have this error, because console.sol doesn't accept struct type inside console.log method. You can see what types accept console.log in original smart contract code (here).
Antonio Carito's user avatar
16 votes

What's the Solidity statement to print data to the console?

EDIT: logX is deprecated and doesn't appear in Solidity 0.8+ documentation. The bellow example is only working if using Solidity up to version 0.7.6 and should now be replaced by Events or Solidity ...
Nicolas Massart's user avatar
16 votes

How do I parse the transaction receipt log with web3.js?

You can now use the web3.eth.abi.decodeLog function (web3 1.0). Example from the documentation: web3.eth.abi.decodeLog([{ type: 'string', name: 'myString' },{ type: 'uint256', name: '...
pors's user avatar
  • 443
15 votes
Accepted

How do I parse the transaction receipt log with web3.js?

Tim: Thanks so much for the pointer. You forced me to finally understand some of the internals of web3.js. I found a cleaner way to do this that covers all the corner cases of the actually fairly ...
Paul S's user avatar
  • 4,271
15 votes
Accepted

How do I decode the transaction's log with Web3.py?

From Web3.py documentation: myContract = web3.eth.contract(address=contract_address, abi=contract_abi) tx_hash = myContract.functions.myFunction().transact() receipt = web3.eth.getTransactionReceipt(...
alper's user avatar
  • 8,395
14 votes
Accepted

Proving the Existence of Logs to the Blockchain

Update: https://github.com/PISAresearch/event-proofs has some code. From its readme: Event proofs A POC to explore how Ethereum logs could be verified in a smart contract. Proofs are generated ...
eth's user avatar
  • 85.9k
14 votes

Find topic[0], topic[1], topic[2]

0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef is exactly sha3 hashing of event signature Transfer(address,address,uint256) - an ERC20 token event signature. Give a try to use ...
nhannguyen's user avatar
13 votes

How to access the event log by knowing the contract address (web3)?

Use .get instead of .watch with web3.eth.filter: contractAddress = "0x00.." web3.eth.filter({ address: contractAddress, from: 1, to: 'latest' }).get(function (err, result) { // callback code ...
k26dr's user avatar
  • 861
12 votes
Accepted

Truffle test, logs do not include an emitted event

Turns out transaction receipt logs only include events emitted in the context of the direct contract function being called. If the called function makes another call to a separate external contract ...
Shiri's user avatar
  • 796
11 votes

How can I view event logs for an ethereum contract?

For anyone using Web3 ^1.0.0, viewing contract events has changed slightly. To view contract events from the past, we now use (from https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#...
Zack McGinnis's user avatar
9 votes

Find topic[0], topic[1], topic[2]

topics[0] is the hash of the event signature, which in your case is Transfer(address,address,uint256) for an ERC20 Transfer event. If you take the keccak hash of that you can confirm. You've taken ...
benjaminion's user avatar
  • 9,297
9 votes
Accepted

What does "Topics" mean in "Event log"?

In a transaction receipt the fied topics correspond to your event arguments which are indexed in your smart contract. For all events you will find as first argument the hash of the event name, and ...
Lbrth_BoC's user avatar
  • 445
9 votes
Accepted

how to interpret event data ethereum

You could also use web3 directly using the web3.eth.abi.decodeParameters(typesArray, hexString) function: In your case it would look like this: web3.eth.abi.decodeParameters(['uint256', 'uint256', '...
MaKue's user avatar
  • 246
9 votes

myContract.events.MyEvent() vs web3.eth.subscribe('logs', ...);

They are both subscriptions to events, but filtered a little differently. myContract.events.MyEvent() will only return MyEvent events from the specific contract address that you used to create the ...
Steven V's user avatar
  • 1,471
9 votes
Accepted

Is it possible to read event logs on-chain?

You cannot: the Log and its event data is not accessible from within contracts, not even from the contract that created them (see the docs).
Nikolai Krivenko's user avatar
8 votes
Accepted

Is the LogsBloom in the block header the same as the Bloom filter in the Transaction Receipts Trie?

No, they are not the same thing. The Bloom filter in the transaction (R_b) contains only the logs from this transaction while the Bloom filter in the block header (H_b) contains the logs from all ...
ComandanteCheth's user avatar
8 votes

Find topic[0], topic[1], topic[2]

Check https://emn178.github.io/online-tools/keccak_256.html provide input Transfer(address,address,uint256) you will get output ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
CaptPython's user avatar
8 votes
Accepted

how to decode log event of my transaction log?

You can use function web3.eth.abi.decodeParameters, for example in your case: const Web3 = require('web3'); const web3 = new Web3(); const typesArray = [ {type: 'string', name: 'messanger'}, ...
goodvibration's user avatar
7 votes

Where do contract event logs get stored in the Ethereum architecture?

From the official documentation: https://solidity.readthedocs.io/en/v0.4.24/contracts.html#events Events are inheritable members of contracts. When they are called, they cause the arguments to be ...
Juan's user avatar
  • 193
7 votes
Accepted

What exactly is included in the bloom filters?

[I had to look at the code for this, so you might have to dig a bit more if the below isn't quite complete. (I think I've followed it correctly.) This is the Geth implementation.] The bloom filters ...
Richard Horrocks's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible