Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create example for get events from starknet #578

Open
thiagodeev opened this issue Jun 19, 2024 · 2 comments
Open

Create example for get events from starknet #578

thiagodeev opened this issue Jun 19, 2024 · 2 comments
Assignees

Comments

@thiagodeev
Copy link
Collaborator

There isn't any example about how to get a contract event from the starknet. It'll be good to include one in the 'examples' folder

@thiagodeev thiagodeev self-assigned this Jun 19, 2024
@alex-sumner
Copy link
Contributor

It would be great to have this as it's not that obvious to a newcomer. Here's my experience of it so far...

I can see the Events function on Provider and an example of calling it in events_test.go. I can also see that it takes an EventsInput that holds an EventFilter.

I'm struggling slightly with the Keys value to set on the EventFilter. It's a [][]*felt.Felt but what are the values in it? Presumably they identify which event types and which values of which keys I am interested in? But how is this info held in the array of arrays, and where do the identifying felt values for event type and key come from?

@thiagodeev
Copy link
Collaborator Author

thiagodeev commented Jul 3, 2024

Hi Alex. Thanks, it will be very helpful.
Take a look at this page in the starknet.js doc: https://www.starknetjs.com/docs/guides/events/#raw-response. The first "keys" value is the hash of the event name. You can get this value with the GetSelectorFromName starknet-go function.

Also, take a look at some emitted events of an ERC20 contract in voyager/starkscan to understand it better.
There's also this: https://docs.cairo-lang.org/hello_starknet/events.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants