Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do smart contracts on NEAR have events or do I need to poll the chain to get data?

Tags:

nearprotocol

Do smart contracts have events now that I can set up listeners for or do I need to poll the chain manually to get data about them?

like image 963
Erik Trautman Avatar asked Oct 16 '25 05:10

Erik Trautman


1 Answers

There are no events right now on NEAR but you could do the following https://github.com/near-examples/erc-20-token/blob/master/contract/events.ts and in Rust https://github.com/near/docs/issues/362

Instead of native events we have a way to poll for changes in the contract's state. For example the events above for fungible tokens are implemented by using that.

Polling for events can be done via RPC https://docs.near.org/docs/api/rpc-experimental#example-of-data-changes and also we are finishing the indexing infrastructure so can later just run indexing node that will provide all this events (https://github.com/nearprotocol/nearcore/pull/2651)

like image 176
Erik Trautman Avatar answered Oct 19 '25 13:10

Erik Trautman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!