solana-go/rpc/examples/getSlotLeaders/getSlotLeaders.go

32 lines
457 B
Go
Raw Normal View History

2021-07-27 07:26:14 -07:00
package main
import (
"context"
"github.com/davecgh/go-spew/spew"
"github.com/gagliardetto/solana-go/rpc"
)
func main() {
2021-07-27 08:55:40 -07:00
endpoint := rpc.TestNet_RPC
2021-07-27 07:26:14 -07:00
client := rpc.New(endpoint)
recent, err := client.GetRecentBlockhash(
context.TODO(),
2021-07-28 14:52:51 -07:00
rpc.CommitmentFinalized,
2021-07-27 07:26:14 -07:00
)
if err != nil {
panic(err)
}
out, err := client.GetSlotLeaders(
context.TODO(),
uint64(recent.Context.Slot),
10,
)
if err != nil {
panic(err)
}
spew.Dump(out)
}