create account

Ethereum events and reading past events by devrajsinghrawat

View this thread on: hive.blogpeakd.comecency.com
· @devrajsinghrawat ·
$0.07
Ethereum events and reading past events
## WHAT THE HACK ARE EVENTS
• Events are a mechanism which let the world know about the state change
happening with in a blockchain.
• This information plays an important role for processing further steps in process .i.e. information update on a dApp or execute next step in business process
• Log entries represent the result of events having fired from a smart contract.

## HOW TO GET THE FISH OUT
• Any receivers which are interested on events from a smart contract can listen the Ethereum node over JSON-
RPC OR WS
• This can be either a locally hosted node or can utilized a public hosted node like INFURA.

Ex:
/** HTTP provider using Infura**/

const provider = 'https://mainnet.infura.io/v3/<API - Key>'
const web3 = new Web3(new Web3.providers.HttpProvider(provider));

/** Websocket provider using Infura**/
const provider = 'wss://mainnet.infura.io/ws';
const web3 = await new Web3(new Web3.providers.WebsocketProvider(provider));

• One who has missed the train to capture the real time event logs can also get the fish out using reading the past event logs using web3js methos getPastEvents

Example : myContract.getPastEvents(event[, options][, callback])

Code Sample is reading ***event bidRevealed*** from ENS smart contract hosted on ethereum blockchain 

![image.png](https://ipfs.busy.org/ipfs/QmWjPM8CoHhN1YNci8xN5YSHVsrprDPmapLGd1D1zMrB3g)

Sample code Repo
https://github.com/devrajsinghrawat/Web3nSolidity/tree/master/eventScan
👍  , , , , ,
👎  
properties (23)
authordevrajsinghrawat
permlinkethereum-events-and-reading-past-events
categorybusy
json_metadata{"community":"busy","app":"busy/2.5.6","format":"markdown","tags":["busy","ethereum","solidity","events","devd-learning-blog"],"users":[],"links":["https://mainnet.infura.io/v3/<API","https://github.com/devrajsinghrawat/Web3nSolidity/tree/master/eventScan"],"image":["https://ipfs.busy.org/ipfs/QmWjPM8CoHhN1YNci8xN5YSHVsrprDPmapLGd1D1zMrB3g"]}
created2019-05-10 06:47:00
last_update2019-05-10 06:47:00
depth0
children1
last_payout2019-05-17 06:47:00
cashout_time1969-12-31 23:59:59
total_payout_value0.052 HBD
curator_payout_value0.015 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,453
author_reputation2,616,899,923,169
root_title"Ethereum events and reading past events "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id84,588,692
net_rshares132,105,219,399
author_curate_reward""
vote details (7)
@minnowsupport ·
<p>Congratulations!  This post has been upvoted from the communal account, @minnowsupport, by DevD from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows.  Please find us at the <a href="https://discord.gg/HYj4yvw"> Peace, Abundance, and Liberty Network (PALnet) Discord Channel</a>.  It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.</p> <p>If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=102530.639667%20VESTS">50SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=205303.639667%20VESTS">100SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=514303.639667%20VESTS">250SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=1025303.639667%20VESTS">500SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=2053030.639667%20VESTS">1000SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=10253030.639667%20VESTS">5000SP</a>. <br><strong>Be sure to leave at least 50SP undelegated on your account.</strong></p>
properties (22)
authorminnowsupport
permlinkre-ethereum-events-and-reading-past-events-20190510t075716z
categorybusy
json_metadata"{"app": "beem/0.20.20"}"
created2019-05-10 07:57:15
last_update2019-05-10 07:57:15
depth1
children0
last_payout2019-05-17 07:57:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,687
author_reputation148,902,805,319,183
root_title"Ethereum events and reading past events "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id84,592,492
net_rshares0