github.com/InjectiveLabs/sdk-go@v1.53.0/examples/chain/tokenfactory/5_MsgChangeAdmin/example.go (about) 1 package main 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "os" 7 8 tokenfactorytypes "github.com/InjectiveLabs/sdk-go/chain/tokenfactory/types" 9 "github.com/InjectiveLabs/sdk-go/client" 10 chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 "github.com/InjectiveLabs/sdk-go/client/common" 12 rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 ) 14 15 func main() { 16 network := common.LoadNetwork("testnet", "lb") 17 tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 18 if err != nil { 19 panic(err) 20 } 21 22 senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 23 os.Getenv("HOME")+"/.injectived", 24 "injectived", 25 "file", 26 "inj-user", 27 "12345678", 28 "f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3", // keyring will be used if pk not provided 29 false, 30 ) 31 32 if err != nil { 33 panic(err) 34 } 35 36 clientCtx, err := chainclient.NewClientContext( 37 network.ChainId, 38 senderAddress.String(), 39 cosmosKeyring, 40 ) 41 if err != nil { 42 fmt.Println(err) 43 return 44 } 45 clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 46 47 chainClient, err := chainclient.NewChainClient( 48 clientCtx, 49 network, 50 common.OptionGasPrices(client.DefaultGasPriceWithDenom), 51 ) 52 53 if err != nil { 54 panic(err) 55 } 56 57 message := new(tokenfactorytypes.MsgChangeAdmin) 58 message.Sender = senderAddress.String() 59 message.Denom = "factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test" 60 // This is the zero address to remove admin permissions 61 message.NewAdmin = "inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49" 62 63 // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg 64 response, err := chainClient.AsyncBroadcastMsg(message) 65 66 if err != nil { 67 panic(err) 68 } 69 70 str, _ := json.MarshalIndent(response, "", " ") 71 fmt.Print(string(str)) 72 }