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
1
vote
1answer
1k views

Solidity | Web3 | Subscribing events

I'm finding a way to subscribe the specific event in the Smart Contract and there is a web3.eth.subscribe to subscribe an event. [Web3.js 1.0.0] The web3.eth.subscribe function lets you subscribe ...
1
vote
1answer
307 views

How filter event based on a value?

I have this solidity event : event ValidateData( address professorAddr, address studentAddr, bytes32 data ); in Javascript I want watch the event only when the ...
1
vote
1answer
54 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 ...
0
votes
1answer
581 views

Subscribing to event using web3j

I'm trying to subscribe to a smart contract event from my java app using web3j. I deployed my contract to truffle, here it is: pragma solidity ^0.4.24; contract MyContract { string message; ...
0
votes
1answer
355 views

How to read past events from the blockchain? [duplicate]

I can read events as they happen with: const eventsWatch = myContract.allEvents(); eventsWatch.watch((err, res) => { if (err) return; console.log("Event:", res.event, res.args); ...
0
votes
0answers
31 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
1k views

Contracts will not compile using truffle with the “emit” keyword included in front of events [duplicate]

I notice there has been changes made to solidity and that the word emit is now to be used in front of event triggers (to distinguish from functions being called). However when I include these in ...
0
votes
2answers
716 views

Watch multiple contracts/events?

Is there a way to watch events from multiple contracts with just one watch-statement (something like [contract1.event, contract2.event, ...].watchAll() ) in Javascript? Code is just for illustration ...
1
vote
1answer
93 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
47 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
2answers
81 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 ...
0
votes
0answers
137 views

Unable to catch contract event using parity websockets

I have a contract deployed on ropsten which emits event when ether amount is deposited in it. I can see the event appearing in etherscan. this.web3Socket = new Web3(new Web3.providers....
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 ...
1
vote
1answer
115 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....
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... } } ...
-1
votes
1answer
152 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. ...
2
votes
1answer
309 views

Decrease polling interval for web3.myContract.myEvent()

The following seems to poll my Ethereum node every second: web3.eth.contract(contractAbi).at(contractAddress).allEvents(callback); Is there a way to decrease the polling interval?
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 ...
0
votes
2answers
620 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 ...
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 ...
38
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 ...
0
votes
0answers
39 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
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 ...
0
votes
1answer
95 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
33 views

Do events get emitted when calling selfdestruct()?

Are event emitted when a contract calls selfdestruct?
32
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 ...
2
votes
1answer
30 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
35 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 ...
3
votes
2answers
422 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)
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){...
1
vote
1answer
130 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 ...
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 ...
1
vote
0answers
81 views

Watch Events with same Name but different params

using web3@0.0.xx is there a way to get Events overloaded (with the same name, but different params) ? I found contract.Transfer[‘address,address,uint256,address,bytes’]({ fromBlock: 0, ...
0
votes
1answer
459 views

What does “_” mean before a variable name?

I'm a beginner, just recently started reading the docs for Solidity. I can't seem to find this anywhere on google. What does the underscore mean when placed with the indexed keyword? Examples: _from ...
0
votes
1answer
27 views

Complete a transaction outside of Solidity

Example for my e-commerce site: uint public PO; function () { emit Purchase(PO++, msg.sender, msg.value, msg.data); // first param is indexed } The code above is for illustrative purpose only. ...
1
vote
1answer
185 views

Decoding Contract Log's “Data” field With eth-abi Throws Error: “Padding bytes were not empty: b'0x0000000000'”

I used this guide to create the code below. I suspect the error is somewhat related to the encoding processes I do to the strings, as that is the only place where I deviate from the guide. Here is my ...
0
votes
1answer
132 views

How to set a timer in web3 event watcher? [closed]

I have a web3 event watcher set up in a Javascript file as such: var a; contract.events.allEvents(function(error, event){ if (event.event == "Set") { a = event.returnValues['val']; } });...
0
votes
2answers
295 views

Write data or emit Event?

My contract has data that is only for front-ends to read (the contract will never need to reference it again). Is there any reason to write that data to the blockchain, or can Events just be emitted ...
2
votes
1answer
746 views

Web3 events not working

As per the web3 doc, I'm using following code to watch the events from a contract: contractInstance.eNonIssueDeposits({}, {fromBlock: 0, toBlock: 'latest'}, (error, result) => { if (!error) { ...
1
vote
1answer
503 views

Listen to solidity events server-side

I have a following contract: pragma solidity ^0.4.17; contract FileDetail { struct File{ string fileName; string fileHash; } File[] private files; event Uploaded( string ...
1
vote
1answer
134 views

NewEventDTO is not a valid Event Type

The solidity code pragma solidity ^0.4.24; event NewEvent(uint32 tag, uint32 idx); My Nethereum code public class NewEventDTO { [Parameter("uint32", "tag", 1, false)] public uint Tag { get; ...
0
votes
1answer
74 views

Are the parameters fromBlock and toBlock of getPastEvents() and events.MyEvent() inclusive or exclusive of the block number?

Using Web3, are the parameters fromBlock and toBlock of getPastEvents() and events.MyEvent() inclusive or exclusive of the block number?
0
votes
1answer
107 views

Cann`t deploy contract using pragma solidity 4.21 (after solidity 4.20)

I cant call me a pro at all. Rather newbie than pro, wishing to learn and develop. I`m sincerely asking you to help me. I have the token and crowdsale contract (testing) which I deploy and initialize ...
-1
votes
1answer
59 views

Capture Solidity Emit Events without Web3 — E.g., Calling via Postman

Is there some way to capture Solidity Emit Events without the use of Web3? For example, I am calling via Postman JSON RPC eth_sendTransaction. How to capture the returned results?
0
votes
1answer
35 views

Are events only useful for the frontend components?

I'm seeing more and more ways as I learn where functions can be run on the client side. I'm looking at events. Does the Ethereum client (say, Metamask) load all the events from a contract when I open ...
3
votes
1answer
717 views

Filtering events by contract address and sender address

I need to watch events by two parameters: address of token contract and sender address. I found how to watch contract address, but not sure how to watch also by sender address? Shoud I specify address ...
0
votes
0answers
58 views

can't read past event logs

const event = contractInst.Transfer({},{fromBlock: 0, toBlock: 'latest'}); events.get(function (error, result) { if (!error) { console.log(result); } }); The get ...
1
vote
0answers
94 views

Parity warp sync doesn't return event logs

Our Dapp uses events as a form of storage. For connection to blockchain we use local Parity node. A couple of days ago I needed to resync it after the server failure. After the resync all methods ...
0
votes
0answers
214 views

Listen to filtered events using web3js 0.19 (provided by infura)

I am working on a uport dApp. uPort by default uses web3 from rinkeby.infura.io which is web3 version 0.19. So no WebSocket available. I tried ZeroClientProvider but that leads to this error: Error ...
1
vote
0answers
105 views

Filtering blocks on basis of transaction logs in web3j

I want to filter blocks on the basis of a log present inside transactions. How can I do that? I don't have any contract address and want to filter all the blocks generated by all the contracts. ...