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.

From http://solidity.readthedocs.io/en/develop/contracts.html?highlight=events#events

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.

Events are inheritable members of contracts. When they are called, they cause the arguments to be stored in the transaction’s log - a special data structure in the blockchain. These logs are associated with the address of the contract and will be incorporated into the blockchain and stay there as long as a block is accessible (forever as of Frontier and Homestead, but this might change with Serenity). Log and event data is not accessible from within contracts (not even from the contract that created a log).

SPV proofs for logs are possible, so if an external entity supplies a contract with such a proof, it can check that the log actually exists inside the blockchain (but be aware of the fact that ultimately, also the block headers have to be supplied because the contract can only see the last 256 block hashes).

Up to three parameters can receive the attribute indexed which will cause the respective arguments to be searched for: It is possible to filter for specific values of indexed arguments in the user interface.

If arrays (including string and bytes) are used as indexed arguments, the Keccak-256 hash of it is stored as topic instead.

The hash of the signature of the event is one of the topics except if you declared the event with anonymous specifier. This means that it is not possible to filter for specific anonymous events by name.

All non-indexed arguments will be stored in the data part of the log.

864 questions
6
votes
0 answers

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: 'latest' }); songAddedEvent.watch(function…
6
votes
1 answer

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.
Daniel
  • 163
  • 1
  • 6
5
votes
2 answers

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() public { owner = msg.sender; } function…
The Burger King
  • 350
  • 3
  • 13
4
votes
2 answers

dYdX event log signature hash

dYdX has an event called LogDeposit(address indexed accountOwner, uint256 accountNumber, uint256 market, BalanceUpdate update, address from) within their SoloMargin contract. I am trying to get the signature hash for this using the following code:…
Brandon
  • 43
  • 3
4
votes
2 answers

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 to imply that logs dont last forever due to…
Mark Oland
  • 43
  • 2
3
votes
1 answer

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.getPastLogs, but the dilemma here is that what values to…
Miao ZhiCheng
  • 232
  • 1
  • 13
3
votes
1 answer

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?
hohoho
  • 293
  • 1
  • 2
  • 10
3
votes
2 answers

When should a protocol should emit an event?

I understand that a protocol can emit events for any of the following reasons: Make it easier to do a data migration in the future (ie, copy-pasting storage mappings is much easier with events) Store data that a smart contract doesn't need to…
Patrick Collins
  • 11,186
  • 5
  • 44
  • 97
2
votes
1 answer

Event result documentation

The current documentation does not go into detail about the structure of the result returned by an event. In this thread and this question, there are mentions about the fields of the result returned by an event listener but where is the…
Sebi
  • 5,294
  • 6
  • 27
  • 52
2
votes
1 answer

Why raise a Created event in a Smart Contract constructor?

Reading through the Bancor code I see this: function SmartToken(string _name, string _symbol, uint8 _decimals) public ERC20Token(_name, _symbol, _decimals) { NewSmartToken(address(this)); } What is the purpose of raising an event in the…
Elie Steinbock
  • 564
  • 1
  • 4
  • 11
2
votes
2 answers

How long can events be retrieved for?

Does anyone know how long events can be retrieved for? I have events on the Kovan contract at 0x86e5b6d7648b8b994886aeb98e2b4770675e608d and it appears I can no longer retrieve events older than 14 days? The code I'm using is as follows. Both get…
chuacw
  • 306
  • 4
  • 13
2
votes
0 answers

When I was testing a contract using ethers V6, I tried to read events from a transaction receipt and got an error

TypeError: Cannot read properties of undefined (reading '0') const hre = require("hardhat"); const main = async () => { const rsvpContractFactory = await hre.ethers.getContractFactory("Web3RSVP"); const rsvpContract = await…
web3游民
  • 21
  • 1
1
vote
1 answer

Will event be emitted on failed transaction?

require(address(0) != address) _mint(address, 1) emit(address, some_other_info) If any part fails and transaction fails in general, will the event be emitted? Can the same event be emitted multiple times? Should I keep track of it? How safe is it?…
good_evening
  • 157
  • 1
  • 10
1
vote
0 answers

Need help understanding Events

Here's an example from solidity docs: [SOLIDITY] contract ClientReceipt { event Deposit( address indexed _from, bytes32 indexed _id, uint _value ); function deposit(bytes32 _id) { Deposit(msg.sender, _id,…
manidos
  • 4,298
  • 3
  • 31
  • 55
1
vote
1 answer

List of ALL Ethereum Contract Events, for ex: Transfer, Mint, etc

A very simple question, yet couldn't find a simple answer. Where can I find a list of all event types such as Transfer, Mint, etc? Is this stored anywhere, for ex: online database or historically within a Geth or Parity archive node? Thanks
keennay
  • 59
  • 1
  • 5
1
2