Hot answers tagged

57 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 ...
user avatar
47 votes

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

Logs are part of the transaction receipts. They are generated by the clients when executing transactions and stored alongside the blockchain to allow retrieving them. Logs are not part of the ...
user avatar
44 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 ...
user avatar
  • 7,549
41 votes

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

Do this: You'll need to pull code from web3, and it works best if your frontend is bundled using something like webpack or browserify: var SolidityCoder = require("web3/lib/solidity/coder.js"); var ...
user avatar
  • 1,039
34 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,...
user avatar
  • 77.9k
31 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 ...
user avatar
  • 77.9k
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 ...
user avatar
  • 31.3k
23 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. ...
user avatar
  • 851
23 votes
Accepted

Can a contract listen to events of another contract?

A contract cannot listen to events of another contract. From Solidity docs: Log and event data is not accessible from within contracts (not even from the contract that created a log). web3.js ...
user avatar
  • 77.9k
23 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 ...
user avatar
22 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, ...
user avatar
20 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 ...
user avatar
  • 77.9k
19 votes
Accepted

Ethereum event log maximum size

Most of the answers for what's possible are in the Yellow Paper. From Equation 20, page 5: A log entry, O, is a tuple of a logger’s address, Oa , a series of 32-bytes log topics, Ot, and some ...
user avatar
  • 77.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 ...
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: '...
user avatar
  • 423
15 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 ...
user avatar
14 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 ...
user avatar
  • 4,161
13 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 ...
user avatar
  • 77.9k
11 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 ...
user avatar
  • 831
11 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(...
user avatar
  • 7,599
11 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 ...
user avatar
  • 616
9 votes
Accepted

Given a contract address, can I determine when the contract was deployed?

The consensus blockchain doesn't contain any easily queryable information to figure out the creation time of a contract based solely on its address. If you have the hash of the transaction that ...
user avatar
9 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#...
user avatar
8 votes

Ethereum event log maximum size

The size limit of one event is a function of the block's gas limit, which as of now tends to be around 3,145,192 (i.e., the first seven digits of pi). According to Jonathan Patrick, logging costs 76 ...
user avatar
  • 1,302
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 ...
user avatar
8 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 ...
user avatar
7 votes
Accepted

How to decode Log.Data in Go

go-ethereum abi package in Oct 2017 got the update to unpack event output. Initially it was only able to unpack method output. All functionality is delivered through the abi.ABI object. To use it you ...
user avatar
7 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 ...
user avatar
  • 1,186
6 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 ...
user avatar
6 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 ...
user avatar
  • 8,622

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