github.com/InjectiveLabs/sdk-go@v1.53.0/examples/chain/bank/query/8_DenomsMetadata/example.go (about) 1 package main 2 3 import ( 4 "context" 5 "encoding/json" 6 "fmt" 7 8 "github.com/InjectiveLabs/sdk-go/client" 9 "github.com/cosmos/cosmos-sdk/types/query" 10 11 chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 "github.com/InjectiveLabs/sdk-go/client/common" 13 rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 15 "os" 16 ) 17 18 func main() { 19 network := common.LoadNetwork("testnet", "lb") 20 tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 21 if err != nil { 22 panic(err) 23 } 24 25 senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 26 os.Getenv("HOME")+"/.injectived", 27 "injectived", 28 "file", 29 "inj-user", 30 "12345678", 31 "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 32 false, 33 ) 34 35 if err != nil { 36 panic(err) 37 } 38 39 clientCtx, err := chainclient.NewClientContext( 40 network.ChainId, 41 senderAddress.String(), 42 cosmosKeyring, 43 ) 44 45 if err != nil { 46 panic(err) 47 } 48 49 clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 50 51 chainClient, err := chainclient.NewChainClient( 52 clientCtx, 53 network, 54 common.OptionGasPrices(client.DefaultGasPriceWithDenom), 55 ) 56 57 if err != nil { 58 panic(err) 59 } 60 61 pagination := query.PageRequest{Limit: 10} 62 ctx := context.Background() 63 64 res, err := chainClient.GetDenomsMetadata(ctx, &pagination) 65 if err != nil { 66 fmt.Println(err) 67 } 68 69 str, _ := json.MarshalIndent(res, "", " ") 70 fmt.Print(string(str)) 71 72 }