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

What does the indexed keyword do?

What does the "indexed" keyword do in the below line of code? I'm guessing it just tells the event object that the following input should be logged? The indexed parameters for logged events ...
BokkyPooBah's user avatar
  • 40.3k
22 votes

What does the indexed keyword do?

The indexed keyword helps you to filter the logs to find the wanted data. thus you can search for specific items instead getting all the logs. in general : event <Identifier>(<parameters>...
Badr Bellaj's user avatar
  • 18.8k
15 votes
Accepted

Why use filters - eth_getLogs vs eth_newFilter

eth_getLogs returns an array of filter logs. You pass in the parameters - e.g. fromBlock, toBlock, etc. - you want to discriminate against. These are the same parameter used by eth_newFilter. ...
Richard Horrocks's user avatar
13 votes
Accepted

How can I create a listener for new transaction with Ethereum RPC calls?

Filters work a little bit different. Filters require LOGs to be emitted from an EVM execution (i.e. a contract). Solidity makes this easy for you by allowing you to fire events (compiled events ...
Jeffrey W.'s user avatar
  • 1,939
11 votes
Accepted

Filters: what's "latest" and "pending"?

Latest means the latest block that is already inside your own chain. All transactions contained within can be considered successfully executed. Security wise of course there can be reorgs, but in ...
Péter Szilágyi's user avatar
9 votes
Accepted

How do I retrieve the Voted events from TheDAO?

Thank you @BokkyPooBah for the general idea, but the final code is a bit different from what you wrote. The prototype to subscribe an event in solidity is (I'm using web3): SolidityEvent.prototype....
Paul Exchange's user avatar
8 votes

How can I trigger a PHP script when a transaction is received?

If you are not familiar with node.js but with PHP and the ethereum architecture, I recommend you to have a look on the RPC API: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter In ...
Denis's user avatar
  • 911
7 votes

How do I retrieve the Voted events from TheDAO?

EDIT 03/06/2016 Corrected this example, adding {} as the first parameter to theDAO.Voted(...) as suggested by @Pablo Yabo. Added code sample to filter for Voted events from selected address(es) and/...
BokkyPooBah's user avatar
  • 40.3k
7 votes

Mistake when using web3.eth.filter() and filter.get()

When I started working on Ethereum even I was having issues similar to this and I learned the hard way. I will share what I learned from my mistakes and hope you don't end up doing the same. Answer ...
farhankhwaja's user avatar
6 votes

filter indexed events from browser using web3.js

Here I am listing an example how I have applied event filter In this example I have used the candidate name as a filter parameter. Secondly it is looking from block 0 to latest. Hope this helps. ...
Susmit's user avatar
  • 1,804
6 votes

Using web3.eth.filter

From the documentation watch will only look for state changes, i.e. only new blocks added from the last time geth was running will be reported. We found it somewhat unreliable, if there was a chain ...
Ismael's user avatar
  • 30.5k
5 votes

How to watch for 12th confirmation with web3 filters

Answering own question. const Web3 = require('web3') let web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")) let account = '0x05430f5201585c2601bb75d9658007202864c993' let ...
fooboo's user avatar
  • 91
5 votes

How can I read log/events that have been triggered in the past?

You should be able to specify the period (in block no) to watch. According the documentation here fromBlock: Number|String - The number of the earliest block (latest may be given to mean the most ...
Greg Jeanmart's user avatar
5 votes
Accepted

Retrieving logs using filter is not working?

You can find an open issue in the Infura Git We're working on finding a solution to this which can provide the functionality createFilter/getLogs was providing in a way which is scalable and secure....
niksmac's user avatar
  • 9,673
5 votes

Cannot create filter on Infura via web3.py

Infura doesn't support filters. Per https://api.infura.io/v1/jsonrpc/ropsten/methods (from the documentation, these are the supported methods: { "get": [ "web3_clientVersion", "net_version"...
user19510's user avatar
  • 28.1k
5 votes
Accepted

Python 3 How to make Event Filter via createFilter web3.py v4.2.1

You can use the following method in web3py to get events: myfilter = mycontract.eventFilter('EventName', {'fromBlock': 0,'toBlock': 'latest'}); eventlist = myfilter.get_all_entries() eventlist will ...
Jaime's user avatar
  • 8,350
4 votes
Accepted

Asynchronously querying the block chain

Unfortunately, there is no filter provided to parse the confirmed transactions without going through a block first i.e., you can trigger a filter (and execute call_async_method()) whenever there is a ...
galahad's user avatar
  • 3,920
4 votes
Accepted

Why cannot catch events retrospectively using filter (eth_newFilter)?

TestRPC doesn't support past events unfortunately. You could try using a private Geth chain as detailed here.
bozzle's user avatar
  • 896
4 votes
Accepted

How do I filter an event by the hash of the transaction that generated the event?

So this can be done by watching for contract events, optionally from a specified sender, and then filtering the result by the transaction hash. Here's an example using web3.js: const Web3 = require('...
matthew's user avatar
  • 579
4 votes
Accepted

How to use eth_newFilter to get pending incoming transactions to a contract?

eth_newFilter is used to receive and filter Ethereum logs. Logs are produced when a transaction is included in a block, hits a smart-contract and generates a log, which is not what you want. You may ...
Julien Marchand's user avatar
4 votes
Accepted

how can I categorize the transactions based on the method they call to transfer and non-transfer transactions using web3?

The function identifier is what will allow you to define transfer vs non transfer function. Basically, it is the first 4 bytes of the call data. Take this transaction which did a USDC transfer. The ...
hroussille's user avatar
  • 7,721
3 votes

filter indexed events from browser using web3.js

In your specific case that would be: var myEvent = contract.myEvent({id: 1}); myEvent.watch((error, result) => { var data = result["args"]["data"]; var id = result["args"]["id"]; // ...
CeesV's user avatar
  • 33
3 votes
Accepted

Are both the eth_newFilter from/to fields inclusive?

A quick whirlwind tour of the filter code... (Instead of simply running some tests to output some logs.) When we create a new filter the order of events is as follows. NewFilter() in ./eth/filters/...
Richard Horrocks's user avatar
3 votes
Accepted

What's the maximum number of filters geth can hold and what happens when this maximum is met?

[Disclaimer: My answer is based on reading the code.] From the filters code - filter.go and, more importantly, filter_system.go - there doesn't appear to be an imposed limit. The filterId variable ...
Richard Horrocks's user avatar
3 votes

How to check if a filter has timed out?

Just checked. In current Geth (v1.5.7), eth_getFilterChanges returns {"jsonrpc":"2.0","id":168,"result":[]} when there is no changes. {"jsonrpc":"2.0","id":168,"error":{"code":-32000,"message":"...
PH88's user avatar
  • 131
3 votes
Accepted

Events in failed transactions

yes it will not be logged because everything gets reverted. check it yourself : pragma solidity ^0.4.2; contract token { event ev(uint256 v); function test(uint256 v){ if (v==1){ ...
Badr Bellaj's user avatar
  • 18.8k
3 votes
Accepted

web3.eth.getFilterChanges(web3_filter.filter_id) throws 'filter not found'

Summary The node (geth) is deleting the filter, maybe due to inactivity, so returns filter not found for that ID. Why? Informally, filters work over json-rpc work like so: Send to node: "Create a ...
carver's user avatar
  • 6,381
3 votes
Accepted

Listing filters in geth. Do they timeout and expire?

Can I go to the geth console and list all the registered filters (in case I forget them or just for other reasons)? AFAIK there is no way to list the installed filters, at least with the exposed ...
ivicaa's user avatar
  • 7,519
2 votes

Filters: what's "latest" and "pending"?

For ideas on a "reference implementation", see: How can a DApp detect a fork or chain reorganization using web3.js or additional libraries? You probably also want to know: What number of ...
eth's user avatar
  • 85.9k
2 votes
Accepted

What is 'the last add pending transaction' in web3 filter?

From a question about pending: Pending is the collection of transactions that can be executed by the network (that your own node knows about), but have not yet been done so. If your node sends ...
eth's user avatar
  • 85.9k

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