github.com/InjectiveLabs/sdk-go@v1.53.0/examples/explorer/13_GetWasmContracts/example.go (about)

     1  package main
     2  
     3  import (
     4  	"context"
     5  	"encoding/json"
     6  	"fmt"
     7  
     8  	explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb"
     9  
    10  	"github.com/InjectiveLabs/sdk-go/client/common"
    11  	explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer"
    12  )
    13  
    14  func main() {
    15  	network := common.LoadNetwork("testnet", "lb")
    16  	explorerClient, err := explorerclient.NewExplorerClient(network)
    17  	if err != nil {
    18  		panic(err)
    19  	}
    20  
    21  	ctx := context.Background()
    22  
    23  	req := explorerPB.GetWasmContractsRequest{}
    24  
    25  	res, err := explorerClient.GetWasmContracts(ctx, &req)
    26  	if err != nil {
    27  		fmt.Println(err)
    28  	}
    29  
    30  	str, _ := json.MarshalIndent(res, "", " ")
    31  	fmt.Print(string(str))
    32  }