Skip to content

Go bindings to the dfuse.io Streaming APIs.

License

Notifications You must be signed in to change notification settings

Duncan-Ultra/eosws-go

This branch is 4 commits behind dfuse-io/eosws-go:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1e40901 · Oct 29, 2021

History

34 Commits
Apr 23, 2019
Oct 29, 2021
Nov 8, 2018
Jan 25, 2019
Nov 2, 2018
Apr 23, 2019
Nov 27, 2018
May 9, 2019
Oct 16, 2018
Oct 11, 2019
Mar 4, 2019
Nov 15, 2018
Apr 23, 2019
Jan 25, 2019
Oct 16, 2018
Oct 10, 2018
Oct 10, 2018
Nov 15, 2018
Nov 27, 2018

Repository files navigation

eosws Go bindings (from the dfuse API)

Websocket consumer for the https://dfuse.io API on EOS networks.

Connecting

    jwt, exp, err := eosws.Auth("server_1234567....")
    if err != nil {
        log.Fatalf("cannot get auth token: %s", err.Error())
    }
    time.AfterFunc(time.Until(exp), log.Println("JWT is now expired, renew it before reconnecting client")) // make sure that you handle updating your JWT

	client, err := eosws.New("wss://mainnet.eos.dfuse.io/v1/stream", jwt, "https://origin.example.com")
    if err != nil {
        log.Fatalf("cannot connect to dfuse endpoint: %s", err.Error())
    }

Sending requests

	ga := &eosws.GetActionTraces{
		ga := &eosws.GetActionTraces{
			ReqID:      "myreq1",
			StartBlock: -5,
			Listen:     true,
		}
	}
	ga.Data.Accounts = "eosio"
	ga.Data.ActionNames = "onblock"
	err = client.Send(ga)
	if err != nil {
		log.Fatalf("error sending request")
    }

Reading responses

	for {
		msg, err := client.Read()
		errorCheck("reading message", err)

		switch m := msg.(type) {
		case *eosws.ActionTrace:
			fmt.Println(m.Data.Trace)
		default:
			fmt.Println("Unsupported message", m)
			break
		}
	}

Examples

See examples folder

About

Go bindings to the dfuse.io Streaming APIs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%