-
Notifications
You must be signed in to change notification settings - Fork 103
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
Eventexample #593
base: main
Are you sure you want to change the base?
Eventexample #593
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @alex-sumner, sorry for the delay.
Great job, thank you! Left some comments
|
||
Steps: | ||
1. Rename the ".env.template" file located at the root of the "examples" folder to ".env" | ||
1. Uncomment, and assign your Ethereum mainnet endpoint to the `RPC_PROVIDER_URL` variable in the ".env" file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change "Ethereum" to "Starknet".
Also, could you change this example to use a testnet smart contract? It'll be smoother for the user to use only one RPC provider for all their example interactions without the need to change it.
|
||
// create an EventFilter that specifies which events we want | ||
eventFilter := rpc.EventFilter{ | ||
FromBlock: rpc.BlockID{Number: fromBlock}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change it to use the rpc.WithBlockNumber
function, that way we don't need the FROM/TO_BLOCK variables
var events []rpc.EmittedEvent | ||
|
||
// read all the events emitted by the contract in this range of blocks | ||
events = readEvents(eventsInput, provider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code is great, but we can make things simpler for new users. What about the first thing we do is call a single event using only starknet.go functions and basic types and print out that event info?
After this first part, we continue to show a more complex interaction (involving multiple calls, pagination, loops...).
Let's use the "readEvents" and "buildKeyFilter" only in this second part
Also, could you change these READMEs to include this example? |
Example code for reading event logs, as called for in issue #578