github.com/InjectiveLabs/sdk-go@v1.53.0/examples/explorer/3_Blocks/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  	explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer"
    10  )
    11  
    12  func main() {
    13  	network := common.LoadNetwork("mainnet", "lb")
    14  	explorerClient, err := explorerclient.NewExplorerClient(network)
    15  	if err != nil {
    16  		panic(err)
    17  	}
    18  
    19  	ctx := context.Background()
    20  	res, err := explorerClient.GetBlocks(ctx)
    21  	if err != nil {
    22  		fmt.Println(err)
    23  	}
    24  
    25  	str, _ := json.MarshalIndent(res, "", " ")
    26  	fmt.Print(string(str))
    27  }