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
5
votes
3answers
4k views

Indexed Event with string not getting logged

I am facing a strange issue in my solidity smart contract using events. I created the event in 2 ways as below:- 1. event Event1(string assetName, address toAdd); 2. event Event1(string indexed ...
5
votes
3answers
2k views

Can't access to contract functions via web3.py

I have already created contract and deployed to ethereum mainnet. Now I wanna read logs. But I can't as calling print(contract_instance.address) and contract_instance.eventFilter('Transfers') show me ...
5
votes
3answers
1k views

How to properly catch events using MochaJs

Good day, I'm using mochajs to test my Solidity code using truffle and testrpc. In my contract I got the following event and function: contract store{ event MoneyIn (address _from, uint256 ...
5
votes
3answers
754 views

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

I have a smart contract with an event. event NewContractCreated(address _callerAddress, address _newContractAddress); I know how to actively listen for new events: var newContractEvent = ...
5
votes
2answers
2k views

Alternative to filter.watch()

Here's a scenario: Dapp backend connects to a remote Ethereum node using external HTTP RPC: const web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/janNFDJkMgDfan")); Dapp ...
5
votes
2answers
182 views

My contract is not emitting events

This is my contract: pragma solidity ^0.4.22; contract Test { event Deposit( address indexed from, uint amt ); event Withdrawal( address indexed to, uint amt ); address owner; constructor()...
5
votes
1answer
121 views

How trustless and secure are Events?

How trustless and secure are Events? They are part of the consensus as they are generated out of a smart contract code. so in theory they are trustless and secure. But they are not stored on chain or ...
5
votes
1answer
108 views

Getting event history takes a really long time or doesn't work at all

I'm having trouble getting a history of events. I'm unsure if I am misunderstanding how events work, if I'm coding wrong, or if it has anything to do with the recent Ethereum attacks slowing down the ...
5
votes
3answers
2k views

Subscription sample using websockets or IPC?

So I was using the web3 API from the NodeJS 'web3' module very happily and it works very well (it uses HTTP transport AFAIU). But now I want to receive events from the server (without polling), and ...
5
votes
1answer
1k views

Etherscan: Effectively paginate `Event Logs` result

I am using Etherscan API for various Ethereum details. I need to find out the tokens transferred from a token original contract (let's say A) address to a particular address(let's say B). For this ...
5
votes
1answer
310 views

Filtering logs for entries greater than a specific value

I know that you can filter logs in web3 by topic using: web3.eth.filter({ topics: ["0x00..."] }).watch(console.log) Is it possible to filter for a topic value greater than a given value?
5
votes
1answer
1k views

How do geth and parity handle notifying clients of events after reorgs?

If you set up an event listener with Geth (I assume also with Parity) you get notifications when a particular event shows up in the event logs. Sometimes a reorg will happen, and the block where that ...
5
votes
1answer
258 views

Cannot catch every event (logs) from contract - catch a couple of random events instead

My contract has a transaction which fires an event. I was able to catch every event when I was sending transactions manually. But now I'm sending 100 transactions in cycle and get only 2..5 events. ...
4
votes
3answers
3k views

do I need to use ws provider in order to watch events?

I am using web3 version 1.0 version 26, however I can't receive any events from ganache-cli and testrpc. this.Contract.events.Created({},{ fromBlock: 0, toBlock: 'latest' }, function(error, event){...
4
votes
2answers
68 views

Do logs/events last forever?

https://thegraph.com/ seems to rely on the assumption that events will last forever. But this post: https://www.reddit.com/r/ethereum/comments/a2ocy6/full_notes_from_fridays_eth_1x_sync_call/ seems ...
4
votes
2answers
4k views

why does new emit event syntax give compiler error

This example returns syntax errors when the emit keyword is used. emit AuctionEnded(highestBidder, highestBid); This is the doc where the example code is. http://solidity.readthedocs.io/en/develop/...
4
votes
1answer
7k views

How to listen to events using Web3 v1.0?

I have a problem when listening for events from my contract. Code js : var Web3 = require('web3'); var abi = '...'; var contractAddress = '0x62e7Dd1Af52d5A08D401b1e156cC4CB1d2f89d57'; var eventName =...
4
votes
2answers
36 views

Block archived event inside blockchain

I want to write a gambling smart contract, that will be based on time (on block number in the ethereum blockchain). What is the best way to do some work when current network block will archive some ...
4
votes
1answer
613 views

web3: are event/filter results guaranteed to be sorted by block number?

I see that the results of past events which I get via MyContract.MyEvent({}, { fromBlock: 0, toBlock: 'latest' }).get((error, results) => { console.log(JSON.stringify(results)); }); are ...
4
votes
1answer
188 views

solidity-coverage adds extra events which make unit-test fail

It seems that when using the latest solidity-coverage (0.5.11), truffle (5.0.0-next.25) ganache-cli (6.2.4-beta.1) and solc (0.5.0) additional events / logs are emitted during tests which make the ...
4
votes
1answer
1k views

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

I read the following in Andreas Olofsson's answer: Events can also be filtered by the hash of the transaction that generated the event Would someone please post an example of how to do this with ...
4
votes
2answers
219 views

Logging errors in the fallback function

In the code I return any Ether sent by mistake to contract C with the throw; statement inside the fallback function. I also want to make a log of this occasion. The following code doesn't work(throw; ...
4
votes
1answer
298 views

List holders and tokens for an ERC-721 contract

Given a contract, I want to map the holders to their token ids. For example, the contract 0xFBeef911Dc5821886e1dda71586d90eD28174B7d is an ERC-721 contract for KnownOriginDigitalAsset. Etherscan ...
4
votes
4answers
1k views

Web3.js/1.0: How to wait/loop until new event show up like watch()?

On Web3.js/1.0 there is no watch() function for the contracts to retrieve events. I have followed the following guide, web3.eth.Contract - Events - getPastEvents - example, and answer to retrieve ...
4
votes
1answer
85 views

Are logs a reliable place to store data long-term?

Are logs a reliable place to store data long-term? From the documentation: "These logs are associated with the address of the contract and will be incorporated into the blockchain and stay there as ...
4
votes
2answers
2k views

How to expose Enum in Solidity contract?

If you create a contract with a function like: contract MyContract { enum MyEnum { Foo, Bar } event ThingHappened(MyEnum indexed _e) function foo(MyEnum _e) { // Code, code code... } } ...
4
votes
1answer
238 views

web3.py createFilter: filter => SyntaxError: positional argument follows keyword argument

Web3.py version 4.2.1 geth version: 1.8.0-unstable I have followed web3.py guide for filtering. Through the contract instance api: event_filter = mycontract.events.myEvent.createFilter(fromBlock='...
4
votes
1answer
146 views

Paging through log of events

I'm trying to use log events to show the transactions from newest to oldest. The problem is that line like this contractHandle.allEvents({ fromBlock: startingBlock, toBlock: 'latest' }) ...
4
votes
1answer
72 views

Different outputs on event log subscription

These are the two ways I found to track events on the Ethereum blockchain. One of them doesn't contain the data I need. Why not? Way 1 does NOT contain the data I need Result: subscription = web3wss....
4
votes
1answer
1k views

How to decode event log info from contract?

I have structure of event in my Solidity code like event test(address investor, uint256 priceinWei). I make a request to etherscan to get all logs from contract on specific addres and get { '...
4
votes
1answer
50 views

Can client updates / upgrades be pushed over the ETH network?

Is it possible for ETH clients to securely receive a live push notification/version update like the way OSX, MacOS does? What are the pros and cons? : ) There could be a contract filter to gain ...
4
votes
1answer
988 views

Are events in a contract triggered after that particular transaction is mined?

Let's say I have an event notify() in a function called buy(). event notify(); buy(){ //... notify(); } Problem here is that my the notify watch handle is triggered only after that ...
4
votes
0answers
305 views

Problem with multiple event listeners, duplicated event triggers

In my app i have multiple listeners (watchers) on different events of same contract. Nothing complicated. let songAddedEvent = instance.SongAdded({}, { fromBlock: 'latest', toBlock: '...
4
votes
1answer
730 views

Events not being detected in Nethereum

I have a function in one contract that looks like this: //Events event RequestReceived(bytes s); event WorldCreated(bytes32 indexed worldName, address indexed sender, address result ); ...
4
votes
0answers
411 views

Event and/or watch does not work

I have a contract for a simple bidding scenario as below: pragma solidity ^0.4.9; /* Contract accepting biddings during 30 minutes */ contract SimpleBidding { address contractOwnersAccount; ...
4
votes
2answers
458 views

Is it possible for a function to wait for another users approval?

I have a simple function in contract x that subtracts a value from contract y, is it possible to have contract x send a message to the user of contract y and set a condition that untill user confirms ...
4
votes
0answers
474 views

sendTransaction and events not working in NodeJS app

I have a contract deployed on the testnet, I can do the following within geth: reference.transfer.sendTransaction(bob, 467, {from:me}) However I can't do this within my node console (with web3 etc. ...
3
votes
2answers
425 views

Does it make a difference to index an event with one parameter?

Is there any difference between the two? event NewEvent(address addr) event NewEvent(address indexed addr)
3
votes
2answers
751 views

Truffle test, logs do not include an emitted event

I am calling a contract function which emits an event in a transaction. This transaction should include the event and is typically visible via: const receipt = await contractInstance.someFunction() ...
3
votes
1answer
280 views

Does the address of an event get automatically indexed?

I understand that I can add indexed to a param in my event and it should speed up the retrieval of events later on. I also know that 'address' comes back from these .filter.get() requests and ...
3
votes
1answer
896 views

web3: Do I need to `get` past events and `watch` future events separately?

As discussed before I managed to get past events via myContract.myEvent({}, { fromBlock: 0, toBlock: 'latest' }).get((error, results) => { But it seems that for future events I need to watch for ...
3
votes
2answers
1k views

Monitoring events from multiple contracts

I'm working on a project that allows users to automatically deploy a specific contract that I created. It's important for the system to be able to listen to specific events (for example, new ...
3
votes
2answers
2k views

How to convert Hexadecimal values into readable format?

I'm using etherscan API to fetch the event logs: http://api-ropsten.etherscan.io/api?module=logs&action=getLogs&fromBlock=3147081&toBlock=latest&address=...
3
votes
1answer
115 views

Are event logs still accessible after selfdestruct?

Are event logs still retrievable for a contract after selfdestruct? Does fast sync or full sync in geth have any effect on this? Basically, it looks like it would be useful to Ethereum if my ...
3
votes
2answers
130 views

Why does having multiple functions with events prevent proper execution?

I am relatively new to Ethereum, so I apologize if there is an obvious answer to this question. I am running a private blockchain to test contracts on. I have a very simple one, where there is one ...
3
votes
1answer
272 views

Using new operator and TypeError: Cannot read property 'event' of undefined

Here's the code: I compile these two contracts together and deploy Bar contract. After deploying it I have a contract account address where it has been deployed on the blockchain: ...
3
votes
2answers
3k views

How do you get events from a function in another contract?

I have two contracts : // contract #1 contract eXample { // intizializer function eXample{ ..... } //creating the Event event MyEvent(uint x,uint y,uint z); function doSomething{ ........
3
votes
1answer
88 views

What is the standard for listening to ERC20 events?

Hi I am a bit confused here. The official EIP documentation states that event Transfer(address indexed _from, address indexed _to, uint256 _value) is how the Transfer event should look like. If I ...
3
votes
4answers
207 views

Can anyone explain what is the main purpose of events in solidity and when to use it?

pragma solidity ^0.4.24; contract assignment2{ event ageread(address,int); function getage(address peridentifier) public returns(uint){ human = mystruct("adam",10); //using struct mystruct ...
3
votes
2answers
1k views

How to Listen to Contract Events in Drizzle

Let's take the example of the SimpleStorage contract that comes with the truffle box drizzle-box How can we listen to the event StorageSet and console.log it to the JS console? drizzleOptions.js ...