Open
Conversation
update go-events.md
Contributor
|
So far so good, can we additionally add some golang and js examples of polling and watching events? |
|
I just create a new method |
|
Ref PR: loomnetwork/go-loom#383 |
added go and js examples
pathornteng
suggested changes
May 29, 2019
updating the go example
Contributor
|
Good work so far! It'd be better if you could include a full code snippet that compiles, so change the example to: package main
import (
"encoding/json"
"github.com/loomnetwork/go-loom/client"
)
type MyEvent struct {
Owner string
Method string
Addr []byte
}
func main() {
rpcClient := client.NewDAppChainRPCClient("default", "http://plasma.dappchains.com:80/rpc", "http://plasma.dappchains.com:80/query")
fromBlock := uint64(5216300)
toBlock := uint64(5216320)
result, err := rpcClient.GetContractEvents(fromBlock, toBlock, "")
if err != nil {
panic(err)
}
for _, event := range result.Events {
var decodedEvent MyEvent
if err := json.Unmarshal(event.EncodedBody, &decodedEvent); err != nil {
panic(err)
}
}
}2 things:
|
gakonst
suggested changes
May 29, 2019
Contributor
gakonst
left a comment
There was a problem hiding this comment.
Change as per above comment
updated the go example
Collaborator
Author
Updated the example.
|
Collaborator
Author
|
@pathornteng Could you help? |
Contributor
|
Not super high priority but when we get a chance lets see if we can fix this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
update go-events.md