Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
18 views

Reading Ledger from etherscan API vs Emitting Events

Consider the following function from a solidity Contract: function createProduct(uint _price, string memory _desc) public payable{ emit UserLedgerUpdated(_desc, -1*int(msg.value)); } I want my ...
0
votes
2answers
28 views

Can we assume that Ethereum Events (aka Logs) are in-sequence

Lets consider a simple Contract that is to track a variable. A client App needs to access this variable's history to show a graph. I can create an Array inside the Contract, and push() the value ...
0
votes
1answer
18 views

How to get the timestamp from the latest event on the etherscan.io apis

How to get the timestamp from the latest event on a contract using the etherscan.io api ? I'm using the getLogs call this way: https://api.etherscan.io/api?module=logs&action=getLogs&...
0
votes
1answer
16 views

Logs and events: How are arguments of “watch” defined?

In order to watch an event we can use: var temp; eventx.watch (function(error, result){ temp = result.args.val.toNumber();}); Question 1: What is the role of: function(error, result){ temp = result....
0
votes
1answer
15 views

getting the latest holders address:balance for a smart contract

I managed to get all the transfer events from any given smart contract, but now I need to reduce that to current holder any idea how I would do this? Here is my code so far: import ERC20ABI from './...
0
votes
1answer
12 views

Truffle Exec Return Events

I have set up a JavaScript file that takes in my contract and executes the various functions and then returns the correct events. The file runs through 'truffle exec'. I am using the following line ...
1
vote
1answer
19 views

Event firing before data is actually set [Testnet]

Today I've faced the behavior similiar to this post. Event firing before data is actually set I'm getting events using infura and then checking for the state. I expect to read updated blockchain ...
1
vote
0answers
40 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: '...
0
votes
1answer
20 views

What is the change in smart contract when the 'chain reorganizations'?

Recently I learned about 'chain reorganization'. What is the change in smart contract when the 'chain reorganizations'? for example, contract Contract{ event LOG_Increase(); uint sum = 0; ...
1
vote
1answer
28 views

Emit event while require statement fails

I would like to be able to log a result of a condition: if(time > 5) { emit Result("time is larger than 5"); } else { emit Result("time is less than 5"); } This will work just fine, but ...
1
vote
2answers
53 views

Truffle Tests Events via JavaScript

I am testing my contract via the chai and truffle-assertions libraries from a JavaScript file and am testing if events return the correct values. I have an event called Message. In my function, the ...
0
votes
1answer
22 views

Web3.js event.get not firing, whereas event.watch gives correct values

I am trying to do a simple test for events. Following is solidity code. Values received from chgEvent.watch are always correct. But in chgEvent.get, results1 is empty. chgEvent.get does not get ...
1
vote
1answer
20 views

What is the difference between writing emit in an event and not using emit? [duplicate]

For example, event CoinTransfer(address sender, address receiver, uint amount); What is the difference between CoinTransfer(msg.sender, receiver, amount); and emit CoinTransfer(msg.sender, receiver, ...
1
vote
1answer
15 views

Accessing the Ethereum State Variables using web3js (Java Script)

I'm trying to run the below code to get the state variables using the getIdBytes method of the Smart Contract, and assign it to a java script array variable, but it doesn't seem to work. All I can ...
0
votes
0answers
19 views

Problem getting/subscribing events

I have the following function in my contract: function accept (uint x) public { ...Code... emit Time(now); } I send the next transaction calling a function in my contract and it ...
1
vote
1answer
32 views

How can we parse and deal with BigNumber (BN) args in Solidity events?

In the past, web3 events published numeric events like so: BigNumber { s: 1, e: 17, c: [ 1000 ] } } Now with web3.js 1.0, big numbers come down as objects like this: <BN: de0b6b3a7640000> ...
2
votes
1answer
25 views

Is there any point in adding msg.sender to an event?

I am asked to provide the value of msg.sender as part of an event emitted in a function. It is something like: contract MyContract { event MyEvent(address indexed sender, uint256 input, uint256 ...
1
vote
1answer
31 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() ...
0
votes
2answers
40 views

Solidity event function not appearing in web3

I have a contract with the following event (using 0.4.24): event UpdateProgress(bool _gameInProgress); I am registering the contract like this: import Web3 from 'web3'; import address from './...
0
votes
1answer
11 views

Should I maintain an array of all the valid keys in a given mapping?

I have a contract which maintains a map of valid wallets. In this map, the keys are wallet addresses and the values are wallet parameters: struct WalletParams { bool valid; uint x; uint ...
1
vote
1answer
19 views

How can a user be informed of the reason for a revert if there is no event log available?

I presume a typical case of smart contract use is purchasing tokens from a smart contract using Metamask. If the contract is at all complex (such as a tiered pricing sale with various caps) and a ...
0
votes
1answer
15 views

Subscribing to multiple Transfer events of various ERC20s

I need to suscribe to Transfer events of couple of different ERC20s in order to catch transfers to my contract. And here is the question: to catch all those events I need to create instance of each ...
1
vote
2answers
27 views

How to setup 'topics' for function getPastLogs ()?

Sir, I want to read the past event log by using getPastLogs(),but I got the whole log.I hope I can filter some log. I find I can setup the 'topics' in getPastLogs(),but it always fails. How ...
1
vote
0answers
58 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 ...
0
votes
1answer
21 views

About getPastLogs usage

"getPastLogs" can get past event log. I check the web3 documentation: fromBlock - Number|String: The number of the earliest block ("latest" may be given to mean the most recent and "pending" ...
0
votes
0answers
20 views

How to get past event log by Node.js?

I want to read past event log. My Node code is: const Web3 = require('web3'); const ethereumUri = 'http://192.168.2.17:8545'; let web3 = new Web3(); web3.setProvider(new web3.providers.HttpProvider(...
0
votes
1answer
24 views

Problem watching events without invoke functions in the Smart Contract

I have an event which is sent each time when a contract is deployed. It is launched in the constructor. I have a Dapp where I want to watch this event to send a tx each time that a smart contract is ...
1
vote
1answer
26 views

Event to track transactions on the backend

I'm currently developing a betting website built on top of Ethereum and am facing the following doubt. In my contract there is an event at the end of the placeBet function which tracks the summary of ...
1
vote
1answer
261 views

Uncaught Error: Returned values aren't valid, did it run Out of Gas?

I'm listening to events of my deployed contract. Whenever a transaction gets completed and event is fired receiving the response causes following error: Uncaught Error: Returned values aren't valid,...
0
votes
0answers
17 views

Events show up on mined, disappear after

I have a function that fires an event at the end, I have more than one that works like this to create some kind of lifecycle through events. I get the full event history for every event as excpected,...
1
vote
1answer
30 views

Using the same event name in different contracts

Suppose I have two different contracts, and I implement an event in each one of them. If I use the same event name in both contracts, will it make it more difficult (or even impossible) to filter the ...
0
votes
1answer
18 views

Web3js 1.0 events: closing the contract.events “socket”

My code is the following: contract.events.Deposit({}, function (err, event) { if (err) { console.error; } else { console.log(event.blockNumber); } }) .on('data', ...
0
votes
0answers
19 views

Automatic event emission after some particular time [duplicate]

e.g. -If a user calls a function "registration" to register and 2 days after the successful registration I want to emit an event that notifies the user. How can this be done?
0
votes
2answers
27 views

Indexed Variables On Event Not Being Decoded

I'm currently returning back all events with no filter and all the indexed variables are being returned but they are encoded. The other none indexed variables are visible and being retrieved fine and ...
1
vote
1answer
45 views

Scalability of using getPastLogs

In order to have a list of the instances of the same contracts created, one method used is to emit an event for each instance created. To query the events(or called logs), we can use web3.eth....
-1
votes
1answer
68 views

How to call Sell event and buy token function with help of web3.py?

I am new to ethereum block-chain. I created a ERC20 token and crow-sale smart contract in solidity. I also deployed these smart contract with the help of web3.py. I created a contract instance. ...
0
votes
0answers
18 views

Event handling through Api [duplicate]

This is my sample Contract which contains the event contract Partner{ event alert(string msg); struct partnerDetails { address pubKey; //Key bytes32 partnerName; } mapping (address =&...
1
vote
1answer
49 views

Getting all ERC721 transactions by an account

My approach here was to listen for Transfer event for a contract (e.g. Cryptokitties) filtered by the indexed from account. var contract = new web3.eth.Contract(kittyABI, kittyContractAddress, {from:...
1
vote
1answer
62 views

How to stop listening to all events of contract

I am using the JavaScript API in my truffle tests to get the events from the contract: https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-allevents const allEvents = instance....
0
votes
2answers
126 views

How to decode data parameter under logs in transaction receipt?

I went through many questions but I couldn't get my answer. web3 version -- 0.20.6 According to documentation event's parameters which are not indexed store in data parameter under logs. I want to ...
0
votes
0answers
25 views

How to read ALL logs of a certain event

When I read event logs like this: myContract.getPastEvents('myEventLogName', { fromBlock: 0, toBlock: 'latest' }) .then(function(events){ console.log(events) // same results as the ...
4
votes
2answers
32 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 ...
0
votes
1answer
69 views

Event handling confusing

Given is: pragma solidity ^0.4.24; contract changeSomVal{ address owner; bool test; event showBool(bool showBool); constructor() public { owner = msg.sender; } ...
1
vote
2answers
21 views

Do events get emitted when calling selfdestruct()?

Are event emitted when a contract calls selfdestruct?
1
vote
1answer
130 views

Solidity event listener

This web3js event listener is part of a Voting Dapp. The listener listens for a transactions and re-renders the page to show updates. listenForEvents: function() { App.contracts.Election.deployed()....
2
votes
1answer
21 views

Can ethereum logs be present while transaction is being mined, then disappear later?

Question about the ethereum blockchain: If I walk the blockchain like so: for block in blockchain: for transaction in block: receipt = getTransactionReceipt(transaction) for log ...
1
vote
0answers
30 views

What is the most preferred way to listen to events

After studying about solidity events, my understanding is that receiving an event doesn’t guarantees that the transaction is final. Transaction may yet to be included into the block. And even if it ...
1
vote
1answer
34 views

Events loading too slow

I have a dapp running on rinkeby at the moment, you can try it now on cryptogol.io, but I am facing a problem when reading events from the Blockchain. For example, yesterday I make the events happens, ...
2
votes
1answer
83 views

Reliable way of listening to events on frontend

I make a web application, that needs the events from my contract to initialize it's state. I was using infura websocket provider, but it seems to lag a lot and close the connections unexpectedly ...
1
vote
1answer
80 views

Contract calling own function emit event?

Does a contract calling a function defined within itself cause an Event to be emitted? Etherscan is not showing events emitted when a function is called using sendSignedTransaction(), despite the fact ...