github.com/InjectiveLabs/sdk-go@v1.53.0/examples/exchange/accounts/9_Rewards/example.go (about) 1 package main 2 3 import ( 4 "context" 5 "encoding/json" 6 "fmt" 7 8 "github.com/InjectiveLabs/sdk-go/client/common" 9 exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 accountPB "github.com/InjectiveLabs/sdk-go/exchange/accounts_rpc/pb" 11 ) 12 13 func main() { 14 network := common.LoadNetwork("testnet", "lb") 15 exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 if err != nil { 17 panic(err) 18 } 19 20 ctx := context.Background() 21 accountAddress := "inj1rwv4zn3jptsqs7l8lpa3uvzhs57y8duemete9e" 22 epoch := int64(1) 23 24 req := accountPB.RewardsRequest{ 25 Epoch: epoch, 26 AccountAddress: accountAddress, 27 } 28 29 res, err := exchangeClient.GetRewards(ctx, &req) 30 if err != nil { 31 fmt.Println(err) 32 } 33 34 str, _ := json.MarshalIndent(res, "", " ") 35 fmt.Print(string(str)) 36 }