Work with Events

How to work with contract events

About events

When contract emits an event, you can fetch it from blockchain or you can subscribe to it.

Events in blockchain are external outbound messages. In GraphQL API their msg_type is 2:

scr1.jpg

Query/subscribe to events

You can fetch events of you contract with this filter from graphql. Try it out in playground https://eri01.main.everos.dev/graphql:

Or subscribe to them:

Query/Subscribe with SDK

Let's assume our contract code is this:

We see that we have 1 event TextUpdated(helloText, textUpdateTime).

AppKit syntax

See the full sample here https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples/listen-and-decode

Query

To fetch all the events do this query. It uses low level api, AppKit does not provide query options for account yet.

Subscribe

To subscribe to new events do this. Don't forget to specify your own callback.

Decode

Check out core api documentation for more information.

Last updated