Questions tagged [events]

Solidity events and logging problems. Events allow the convenient usage of the EVM logging facilities, which in turn can be used to “call” JavaScript callbacks in the user interface of a dapp, which listen for these events.

Filter by
Sorted by
Tagged with
51
votes
2answers
15k views

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? Can we use it other places ie outside of events? ...
46
votes
2answers
27k views

What is an Event?

What is an Event? Are they only used in Solidity? How are events defined? How are events initiated? Is there a standard term for an event's invocation (do you say an event "happened", "was called",...
37
votes
6answers
33k views

How do you get a json file (ABI) from a known contract address?

I want to watch a Solidity contract using the Mist browser. I know how to do that and it needs the address and the json. I have the address, but I don't have the json. I do have the source code. Can ...
35
votes
3answers
9k views

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

Background on Events: https://github.com/ethereum/wiki/wiki/Solidity-Features Events allow the convenient usage of the EVM logging facilities. Events are inheritable members of contracts. When they ...
31
votes
6answers
14k views

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

The event parser in web3 provides a nice parsing functionality for events, and I use it for logging all events to a file, but it's very difficult to use for looking at individual events for a ...
29
votes
5answers
18k views

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

How can I access a log stored in one of the tx of the contract via web3? Code example: event newtest(string indexed name, uint indexed idlevel,string indexed multib, string objmulti, uint objnm); ...
29
votes
1answer
10k views

What are event topics?

I know that indexed arguments index the values for those arguments so that filtering will be faster. But what are topics? And what are they used for? I know that signature of an event is a topic. ...
29
votes
4answers
4k views

How can a DApp detect a fork or chain reorganization using web3.js or additional libraries?

Take an example of a voting DApp. A user clicks on a vote button, then behind the scenes a transaction gets mined on the blockchain, and finally the DApp tells the user their vote has been recorded. ...
25
votes
2answers
3k views

Is it a good practice to log an event every time I throw in Solidity?

In Solidity (0.3.2) I am aware that there is no way to throw specific exceptions. (Everything is an invalid JUMP error.) It seems beneficial to have a way to log specific errors. Does it make sense to ...
25
votes
5answers
14k views

web3: How do I get past events of myContract.myEvent?

I use the following JS code to get notified of Solidity events and it works well for incoming new events: myContract.myEvent().watch((error, result) => { if (error) console.log('Error in ...
24
votes
1answer
2k views

Is searching data stored in event logs prohibitively slow?

Augur uses event logs to store data that never needs to be accessed on-contract, since it is about 10x cheaper than on-contract storage. However, I've noticed that retrieving event logs (e.g., using ...
21
votes
3answers
21k views

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

Sometimes it would be really helpful to be able to see string representations of variable values in the Geth console, like of argument values in functions. Can I somehow print them to the Geth console?...
20
votes
5answers
17k views

How to listen for contract events in JavaScript tests?

I'm trying to trigger events in my solidity contract to output some debug information in my javascript tests. However the events seem to get never caught. That's the relevant contract code: pragma ...
20
votes
1answer
2k views

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

I've seen this forum post about using Ethereum as an event store: Events in Solidity, using blockchain as eventstore. However, it doesn't seem conclusive. For instance it says: I confirmed with ...
19
votes
3answers
12k views

What does the Web3 “BigNumber not a base 16 number Error” mean

Is there a known problem with parsing events containing strings in Truffle/Web3? I'm using truffle with the following simple contract contract Board { string foo; event Shout(); event ...
15
votes
2answers
2k views

How do I retrieve the Voted events from TheDAO?

This question was asked by @Pablo Yabo in the comment section of the question How can I view The DAO proposals including the current voting status?.
14
votes
3answers
3k views

How to check events in Truffle Tests?

What's the best way to check that events were fired in a Truffle test?
14
votes
2answers
3k views

Can a contract listen to events of another contract?

I read that to listen to events you need to use web3.js. Are there other ways of doing it? Can a contract even somehow listen to events of another contract? Thanks!
10
votes
2answers
3k views

Ethereum event log maximum size

I'm thinking of storing some data in logs by emitting events but I cannot easily find the answers to the following questions: What is the total size limit of one event? Can I store lots of string32 ...
10
votes
3answers
4k views

Confused by internal transactions

Let's say contract A has function F. If someone uses a regular account to call A::F a transaction is laid down on the blockchain. That transaction is easily found on EtherScan for example. If a ...
10
votes
1answer
664 views

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

Ideally the solution would use web3, but other solutions are acceptable. Motivation: Event lookups can be passed fromBlock field. If I know the block a contract was created, I can more accurately do ...
10
votes
4answers
476 views

How to watch log for all instances of a specific type of contract?

Attaching a watcher for every instance of a contract is not a good idea in terms of memory and CPU. So is there a way to watch for events from all instances of a contract i.e., by registering a single ...
9
votes
2answers
3k views

How to implement events in solidity

I have an error whenever I add the event line for EVM logging and to notify anyone listening that this transfer took place. function sendCoin(address receiver, uint amount) returns (bool sufficient) {...
9
votes
2answers
333 views

Why do I get serialization errors in calling events?

I have put some events in my contracts like this event TokenTransfer(address indexed sender,address indexed receiver,uint32 indexed num_tokens); event ExceptionEvent(uint16 indexed retcode,address ...
8
votes
2answers
2k views

What is topics[0] in Event logs?

Here's a snapshot from etherscan.io
8
votes
1answer
576 views

Will I be able to get past contract events through rpc if I use geth --fast?

Or in other words, will geth --fast download the events logs?
8
votes
2answers
2k views

contract event not firing in web3 node console

It appears my events are not being fired in my node application when I transact the contract in the ethereum wallet gui. I deployed a custom contract via ethereum-wallet I have fired up geth attach ...
8
votes
2answers
628 views

Why do public and external functions emit strings differently in event logs?

Producing the logs When the same event is logged with the same string argument, the data in the transaction receipt is different, depending on whether the function was external or public. pragma ...
8
votes
1answer
377 views

Cheapest way to store a hash for proof of publication

Can someone help me how to use events/logs for proof of publication? The way I understand it, I send a transaction with the metadata I want "proof of publication" for, to a contract. The contract does ...
8
votes
1answer
564 views

Filtering on events of the entire blockchain not possible in testrpc via truffle

A contract I wrote has an event in its constructor. Since I want to find it back in the logs it doesn't seem possible to start listening to the latest block. Because the event is already 'fired' ...
7
votes
1answer
3k views

Current methods to send encrypted messages from contracts

I am trying to understand if there currently exists a method to send a message from a contract to another contract or a private address? What would the Solidity code for this look like? Perhaps events ...
7
votes
1answer
648 views

What are limitations of Event arguments?

Are there any limitation on the amount of arguments that can be send in an event? I have a function in which I want to trigger event that has 12 arguments of which 6 arguments are arrays. I get Stack ...
7
votes
2answers
2k views

How to write transaction logs into a text file in geth?

I have made a contract which generates a public event on blockchain that will notify client about a transaction. To listen to the event I have written following snippet in geth console: var event = ...
7
votes
1answer
1k views

Event result parameters and arguments in console

I read about using events from this source http://solidity.readthedocs.io/en/latest/contracts.html#events I used a simple multiply contract: contract test1{ uint a; event event_res(string msg,...
7
votes
2answers
3k views

Web3j listening to events

I'm tinkering with web3j and most of the things that I want to do succeed, however I seem to not be able to listen to events. I've extended the ballot.sol contract you get with remix by adding an ...
7
votes
2answers
1k views

Problem accessing array inside struct

Dealing with the code below: contract myContract { struct myStruct{ bytes32 name; bool active; uint[] changes; } myStruct[2] myStr; uint[] steps; Event ...
7
votes
2answers
977 views

What's the best way currently to get events to a Go app that uses go-ethereum?

I have generated and used Go bindings to deploy a few contracts and that worked very well, but I see events are not implemented yet. Is this work discussed somewhere? I'd like to understand what ...
6
votes
4answers
2k views

Proving the Existence of Logs to the Blockchain

To preface this: I'm not entirely sure this question makes any sense. Just a thought I had that I wanted to check the feasibility of. I'm pretty sure it is possible to use a Merkle proof to show that ...
6
votes
1answer
2k views

Why use filters - eth_getLogs vs eth_newFilter

It seems to me eth_getLogs is much simpler than eth_newFilter + eth_getFilterLogs. eth_getLogs has no need for installation, got same parameters, catches events retrospectively. What are use cases ...
6
votes
2answers
2k views

How can I use “eth_sendTransaction” to invoke a contract and get logs?

I have deployed: contract test { function multiply(uint a) returns(uint d) { return a * 7; } } I can call the contract with "eth_call" : mpsp@ubuntu-slave2:~$ curl http:...
6
votes
1answer
388 views

Are events emitted from a contract synchronously?

Does anyone know how events emitted from a contract? I can't seem to find an authoritative answer while googling and I am kind of worried that they are synchronous.
6
votes
4answers
1k views

Duplicate events firing in a Web3 listener

I'm experimenting with plugging Ethereum into a React web application, using this nice tutorial repo as a basis (thanks to uzyn): https://github.com/uzyn/ethereum-webpack-example-dapp I'm connecting ...
6
votes
1answer
285 views

Do events only work on an instance of a contract?

Does a contract address have to specified to watch for an event? Or, can I register an event handler for every time contracts of a certain type are transacted?
6
votes
2answers
4k views

watching all the events of a contract (geth): 'cannot find event for log undefined: undefined'

I am trying to watch all events of a contract with many events. The following code is supposed to do just that: var events = myContract.allEvents(); events.watch(function(error, event){ if (...
6
votes
1answer
295 views

What are the benefits of using events over dedicated indexed variable?

Good day. I'm trying to grasp the concept of events in the EVM and I just can't understand what is the incentive of using events. Why not just use a dedicated public index that will hold information? ...
6
votes
1answer
297 views

Do we really need smart-contracts for duplicable/replayable business logic or will event/logging suffice?

I have not found any place where this topic is well covered. I've been playing around with smart-contracts and trying to figure out what advantages an smart-contract has over plain logging of input ...
6
votes
1answer
1k views

How can i setup a web3 webservice that listens for events from my smart contract?

I have a smart contract that broadcasts events to web3 clients, upon each event being broadcast, the listening client makes a tx call to my contract. I would like to set up an 'always on' event ...
6
votes
3answers
7k views

Listen to blockchain events in js

I want all js clients to react on new event being stored to blockchain: contract MainContract{ event Evt(address indexed _sender,string jsn); function deposit(string jsn) returns (int256) { ...
6
votes
1answer
800 views

How do I get event logs in transaction receipt, when I trigger event defined in other contract?

I'm trying to trigger event defined in another contract and get the event logs in transaction receipt but it's not working this way - Base Contract -- pragma solidity ^0.4.0; contract DataStore { ...
6
votes
2answers
1k views

How to access contract events through RPC?

I'm trying to figure out how to log events happening in a contract at a private Ethereum network. It looks like Events are the way to go. However, I can't seem to find any good example of how to ...