github.com/InjectiveLabs/sdk-go@v1.53.0/examples/explorer/14_GetWasmContractByAddress/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.GetWasmContractByAddressRequest{
    24  		ContractAddress: "inj1ru9nhdjtjtz8u8wrwxmcl9zsns4fh2838yr5ga",
    25  	}
    26  	res, err := explorerClient.GetWasmContractByAddress(ctx, &req)
    27  	if err != nil {
    28  		fmt.Println(err)
    29  	}
    30  
    31  	str, _ := json.MarshalIndent(res, "", " ")
    32  	fmt.Print(string(str))
    33  }