diff --git a/client/chain/chain.go b/client/chain/chain.go index 94927266..eecc5b9f 100644 --- a/client/chain/chain.go +++ b/client/chain/chain.go @@ -23,6 +23,7 @@ import ( log "github.com/xlab/suplog" "google.golang.org/grpc" "google.golang.org/grpc/metadata" + "math" "math/big" "net/http" "os" @@ -86,6 +87,7 @@ type ChainClient interface { DerivativeOrder(defaultSubaccountID eth.Hash, network common.Network, d *DerivativeOrderData) *exchangetypes.DerivativeOrder OrderCancel(defaultSubaccountID eth.Hash, d *OrderCancelData) *exchangetypes.OrderData + GetGasFee() (string, error) Close() } @@ -104,6 +106,7 @@ type chainClient struct { accNum uint64 accSeq uint64 gasWanted uint64 + gasFee string sessionCookie string sessionEnabled bool @@ -656,6 +659,22 @@ func (c *chainClient) runBatchBroadcast() { } } +func (c *chainClient) GetGasFee() (string, error) { + gasPrices := strings.Trim(c.opts.GasPrices, "inj") + + gas, err := strconv.ParseFloat(gasPrices, 64) + + if err != nil { + return "", err + } + + gasFeeAdjusted := gas * float64(c.gasWanted) / math.Pow(10, 18) + gasFeeFormatted := strconv.FormatFloat(gasFeeAdjusted, 'f', -1, 64) + c.gasFee = gasFeeFormatted + + return c.gasFee, err +} + func (c *chainClient) DefaultSubaccount(acc cosmtypes.AccAddress) eth.Hash { return eth.BytesToHash(eth.RightPadBytes(acc.Bytes(), 32)) } diff --git a/examples/chain/0_LocalOrderHash/example.go b/examples/chain/0_LocalOrderHash/example.go index dcaf9257..762f1357 100644 --- a/examples/chain/0_LocalOrderHash/example.go +++ b/examples/chain/0_LocalOrderHash/example.go @@ -16,6 +16,7 @@ func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -29,31 +30,37 @@ func main() { "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided false, ) + if err != nil { panic(err) } + // initialize grpc client + clientCtx, err := chainclient.NewClientContext( network.ChainId, senderAddress.String(), cosmosKeyring, ) + if err != nil { fmt.Println(err) } clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmRPC) + chainClient, err := chainclient.NewChainClient( clientCtx, network.ChainGrpcEndpoint, common.OptionTLSCert(network.ChainTlsCert), common.OptionGasPrices("500000000inj"), ) + if err != nil { fmt.Println(err) } - // build orders + // prepare tx msg defaultSubaccountID := chainClient.DefaultSubaccount(senderAddress) spotOrder := chainClient.SpotOrder(defaultSubaccountID, network, &chainclient.SpotOrderData{ @@ -81,16 +88,31 @@ func main() { msg1.Sender = senderAddress.String() msg1.Orders = []exchangetypes.DerivativeOrder{*derivativeOrder, *derivativeOrder} + // compute local order hashes orderHashes, err := chainClient.ComputeOrderHashes(msg.Orders, msg1.Orders) + if err != nil { fmt.Println(err) } - fmt.Println("computed spot order hashes", orderHashes.Spot) - fmt.Println("computed derivative order hashes", orderHashes.Derivative) + fmt.Println("computed spot order hashes: ", orderHashes.Spot) + fmt.Println("computed derivative order hashes: ", orderHashes.Derivative) + + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg, msg1) + if err != nil { fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/10_MsgBatchCancelDerivativeOrders/example.go b/examples/chain/10_MsgBatchCancelDerivativeOrders/example.go index 041ae47d..a4b2d12f 100644 --- a/examples/chain/10_MsgBatchCancelDerivativeOrders/example.go +++ b/examples/chain/10_MsgBatchCancelDerivativeOrders/example.go @@ -5,18 +5,19 @@ import ( "os" "time" - cosmtypes "github.com/cosmos/cosmos-sdk/types" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + cosmtypes "github.com/cosmos/cosmos-sdk/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -73,6 +74,7 @@ func main() { msg.Data = []exchangetypes.OrderData{*order} CosMsgs := []cosmtypes.Msg{msg} + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(CosMsgs...) if err != nil { @@ -80,4 +82,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/11_MsgBatchCreateSpotLimitOrders/example.go b/examples/chain/11_MsgBatchCreateSpotLimitOrders/example.go index f8cdd3b0..bac648cd 100644 --- a/examples/chain/11_MsgBatchCreateSpotLimitOrders/example.go +++ b/examples/chain/11_MsgBatchCreateSpotLimitOrders/example.go @@ -5,18 +5,19 @@ import ( "os" "time" + "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -76,20 +77,36 @@ func main() { msg.Orders = []exchangetypes.SpotOrder{*order} simRes, err := chainClient.SimulateMsg(clientCtx, msg) + if err != nil { fmt.Println(err) } + simResMsgs := common.MsgResponse(simRes.Result.Data) msgBatchCreateSpotLimitOrdersResponse := exchangetypes.MsgBatchCreateSpotLimitOrdersResponse{} msgBatchCreateSpotLimitOrdersResponse.Unmarshal(simResMsgs[0].Data) + if err != nil { fmt.Println(err) } + fmt.Println("simulated order hashes", msgBatchCreateSpotLimitOrdersResponse.OrderHashes) + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) + if err != nil { fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/12_MsgBatchCreateDerivativeLimitOrders/example.go b/examples/chain/12_MsgBatchCreateDerivativeLimitOrders/example.go index e4f434b2..2e12dfac 100644 --- a/examples/chain/12_MsgBatchCreateDerivativeLimitOrders/example.go +++ b/examples/chain/12_MsgBatchCreateDerivativeLimitOrders/example.go @@ -5,19 +5,20 @@ import ( "os" "time" - cosmtypes "github.com/cosmos/cosmos-sdk/types" + "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + cosmtypes "github.com/cosmos/cosmos-sdk/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -81,20 +82,36 @@ func main() { msg.Orders = []exchangetypes.DerivativeOrder{*order} simRes, err := chainClient.SimulateMsg(clientCtx, msg) + if err != nil { fmt.Println(err) } + simResMsgs := common.MsgResponse(simRes.Result.Data) msgBatchCreateDerivativeLimitOrdersResponse := exchangetypes.MsgBatchCreateDerivativeLimitOrdersResponse{} msgBatchCreateDerivativeLimitOrdersResponse.Unmarshal(simResMsgs[0].Data) + if err != nil { fmt.Println(err) } + fmt.Println("simulated order hashes", msgBatchCreateDerivativeLimitOrdersResponse.OrderHashes) + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) + if err != nil { fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/13_MsgIncreasePositionMargin/example.go b/examples/chain/13_MsgIncreasePositionMargin/example.go index 658b03d9..c4c8ca45 100644 --- a/examples/chain/13_MsgIncreasePositionMargin/example.go +++ b/examples/chain/13_MsgIncreasePositionMargin/example.go @@ -5,18 +5,19 @@ import ( "os" "time" - cosmtypes "github.com/cosmos/cosmos-sdk/types" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + cosmtypes "github.com/cosmos/cosmos-sdk/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -66,6 +67,7 @@ func main() { fmt.Println(err) } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { @@ -73,4 +75,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/15_MsgWithdraw/example.go b/examples/chain/15_MsgWithdraw/example.go index 5acb8119..a5c5fafd 100644 --- a/examples/chain/15_MsgWithdraw/example.go +++ b/examples/chain/15_MsgWithdraw/example.go @@ -5,18 +5,19 @@ import ( "os" "time" - sdktypes "github.com/cosmos/cosmos-sdk/types" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + sdktypes "github.com/cosmos/cosmos-sdk/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -66,6 +67,7 @@ func main() { fmt.Println(err) } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { @@ -73,4 +75,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/16_MsgSubaccountTransfer/example.go b/examples/chain/16_MsgSubaccountTransfer/example.go index 1e1c267f..925443fa 100644 --- a/examples/chain/16_MsgSubaccountTransfer/example.go +++ b/examples/chain/16_MsgSubaccountTransfer/example.go @@ -5,18 +5,19 @@ import ( "os" "time" - sdktypes "github.com/cosmos/cosmos-sdk/types" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + sdktypes "github.com/cosmos/cosmos-sdk/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -67,6 +68,7 @@ func main() { fmt.Println(err) } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { @@ -74,4 +76,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/17_MsgBatchUpdateOrders/example.go b/examples/chain/17_MsgBatchUpdateOrders/example.go index 1578efad..2c1ef9d0 100644 --- a/examples/chain/17_MsgBatchUpdateOrders/example.go +++ b/examples/chain/17_MsgBatchUpdateOrders/example.go @@ -5,19 +5,20 @@ import ( "os" "time" - cosmtypes "github.com/cosmos/cosmos-sdk/types" + "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + cosmtypes "github.com/cosmos/cosmos-sdk/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -99,6 +100,7 @@ func main() { msg.DerivativeMarketIdsToCancelAll = dmarketIds simRes, err := chainClient.SimulateMsg(clientCtx, msg) + if err != nil { fmt.Println(err) } @@ -111,9 +113,21 @@ func main() { fmt.Println("simulated derivative order hashes", MsgBatchUpdateOrdersResponse.DerivativeOrderHashes) + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) + if err != nil { fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/18_MsgBid/example.go b/examples/chain/18_MsgBid/example.go index d485557f..92772db8 100644 --- a/examples/chain/18_MsgBid/example.go +++ b/examples/chain/18_MsgBid/example.go @@ -5,18 +5,19 @@ import ( "os" "time" - sdktypes "github.com/cosmos/cosmos-sdk/types" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" auctiontypes "github.com/InjectiveLabs/sdk-go/chain/auction/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + sdktypes "github.com/cosmos/cosmos-sdk/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -69,6 +70,7 @@ func main() { fmt.Println(err) } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { @@ -76,4 +78,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/19_MsgGrant/example.go b/examples/chain/19_MsgGrant/example.go index 49a3572b..5726be10 100644 --- a/examples/chain/19_MsgGrant/example.go +++ b/examples/chain/19_MsgGrant/example.go @@ -5,16 +5,17 @@ import ( "os" "time" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -28,6 +29,7 @@ func main() { "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided false, ) + if err != nil { panic(err) } @@ -37,9 +39,11 @@ func main() { senderAddress.String(), cosmosKeyring, ) + if err != nil { fmt.Println(err) } + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmRPC) chainClient, err := chainclient.NewChainClient( @@ -48,6 +52,7 @@ func main() { common.OptionTLSCert(network.ChainTlsCert), common.OptionGasPrices("500000000inj"), ) + if err != nil { fmt.Println(err) } @@ -70,9 +75,21 @@ func main() { expireIn, ) + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) + if err != nil { fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/1_MsgSend/example.go b/examples/chain/1_MsgSend/example.go index 5ee9c719..8e217d97 100644 --- a/examples/chain/1_MsgSend/example.go +++ b/examples/chain/1_MsgSend/example.go @@ -5,18 +5,19 @@ import ( "os" "time" + "github.com/InjectiveLabs/sdk-go/client/common" + + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" sdktypes "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" rpchttp "github.com/tendermint/tendermint/rpc/client/http" - - chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -35,6 +36,8 @@ func main() { panic(err) } + // initialize grpc client + clientCtx, err := chainclient.NewClientContext( network.ChainId, senderAddress.String(), @@ -47,6 +50,8 @@ func main() { clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmRPC) + // prepare tx msg + msg := &banktypes.MsgSend{ FromAddress: senderAddress.String(), ToAddress: "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r", @@ -66,6 +71,7 @@ func main() { fmt.Println(err) } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { @@ -73,4 +79,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/20_MsgExec/example.go b/examples/chain/20_MsgExec/example.go index 92866673..1ec6b24d 100644 --- a/examples/chain/20_MsgExec/example.go +++ b/examples/chain/20_MsgExec/example.go @@ -5,21 +5,22 @@ import ( "os" "time" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - authztypes "github.com/cosmos/cosmos-sdk/x/authz" + "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authztypes "github.com/cosmos/cosmos-sdk/x/authz" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -33,6 +34,7 @@ func main() { "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided false, ) + if err != nil { panic(err) } @@ -46,6 +48,7 @@ func main() { "f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3", // keyring will be used if pk not provided false, ) + if err != nil { panic(err) } @@ -69,6 +72,7 @@ func main() { common.OptionTLSCert(network.ChainTlsCert), common.OptionGasPrices("500000000inj"), ) + if err != nil { fmt.Println(err) } @@ -105,9 +109,21 @@ func main() { Msgs: []*codectypes.Any{msg0Any}, } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) + if err != nil { fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/21_MsgRevoke/example.go b/examples/chain/21_MsgRevoke/example.go index b0858ad5..1b4a9f45 100644 --- a/examples/chain/21_MsgRevoke/example.go +++ b/examples/chain/21_MsgRevoke/example.go @@ -5,17 +5,18 @@ import ( "os" "time" - authztypes "github.com/cosmos/cosmos-sdk/x/authz" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + authztypes "github.com/cosmos/cosmos-sdk/x/authz" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -66,6 +67,7 @@ func main() { fmt.Println(err) } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { @@ -73,4 +75,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/22_MsgSendToEth/example.go b/examples/chain/22_MsgSendToEth/example.go index 198e908e..731be7c1 100644 --- a/examples/chain/22_MsgSendToEth/example.go +++ b/examples/chain/22_MsgSendToEth/example.go @@ -5,18 +5,19 @@ import ( "os" "time" - sdktypes "github.com/cosmos/cosmos-sdk/types" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" peggytypes "github.com/InjectiveLabs/sdk-go/chain/peggy/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + sdktypes "github.com/cosmos/cosmos-sdk/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -74,6 +75,7 @@ func main() { fmt.Println(err) } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { @@ -81,4 +83,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/23_MsgRelayPriceFeedPrice/example.go b/examples/chain/23_MsgRelayPriceFeedPrice/example.go index bfc25406..cc0ce7ab 100644 --- a/examples/chain/23_MsgRelayPriceFeedPrice/example.go +++ b/examples/chain/23_MsgRelayPriceFeedPrice/example.go @@ -5,18 +5,19 @@ import ( "os" "time" - cosmtypes "github.com/cosmos/cosmos-sdk/types" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" oracletypes "github.com/InjectiveLabs/sdk-go/chain/oracle/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + cosmtypes "github.com/cosmos/cosmos-sdk/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -69,6 +70,7 @@ func main() { fmt.Println(err) } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { @@ -76,4 +78,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/24_MsgRegisterAsDMM/example.go b/examples/chain/24_MsgRegisterAsDMM/example.go index bd3f6ab0..a5698dd0 100644 --- a/examples/chain/24_MsgRegisterAsDMM/example.go +++ b/examples/chain/24_MsgRegisterAsDMM/example.go @@ -5,17 +5,18 @@ import ( "os" "time" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -62,11 +63,21 @@ func main() { fmt.Println(err) } - for i := 0; i < 1; i++ { - err := chainClient.QueueBroadcastMsg(msg) - if err != nil { - fmt.Println(err) - } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + err = chainClient.QueueBroadcastMsg(msg) + + if err != nil { + fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/25_MsgDelegate/example.go b/examples/chain/25_MsgDelegate/example.go index b7cf16e9..10920449 100644 --- a/examples/chain/25_MsgDelegate/example.go +++ b/examples/chain/25_MsgDelegate/example.go @@ -5,18 +5,19 @@ import ( "os" "time" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" sdktypes "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -65,9 +66,21 @@ func main() { Denom: "inj", Amount: sdktypes.NewInt(1000000000000000000), // 1 INJ } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) + if err != nil { fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/26_MsgWithdrawDelegatorReward/example.go b/examples/chain/26_MsgWithdrawDelegatorReward/example.go index 25bb4d1b..ae8a918b 100644 --- a/examples/chain/26_MsgWithdrawDelegatorReward/example.go +++ b/examples/chain/26_MsgWithdrawDelegatorReward/example.go @@ -5,17 +5,18 @@ import ( "os" "time" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -61,9 +62,21 @@ func main() { msg.DelegatorAddress = senderAddress.String() msg.ValidatorAddress = "injvaloper14gy4acwjm96wd20awm9ar6j54lev5p7espy9ug" + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) + if err != nil { fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/2_MsgDeposit/example.go b/examples/chain/2_MsgDeposit/example.go index ad560973..3fd3b77b 100644 --- a/examples/chain/2_MsgDeposit/example.go +++ b/examples/chain/2_MsgDeposit/example.go @@ -5,12 +5,13 @@ import ( "os" "time" + "github.com/InjectiveLabs/sdk-go/client/common" + sdktypes "github.com/cosmos/cosmos-sdk/types" rpchttp "github.com/tendermint/tendermint/rpc/client/http" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" ) func main() { @@ -66,6 +67,7 @@ func main() { fmt.Println(err) } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { @@ -73,4 +75,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/3_MsgCreateSpotLimitOrder/example.go b/examples/chain/3_MsgCreateSpotLimitOrder/example.go index c69729f3..bff0c420 100644 --- a/examples/chain/3_MsgCreateSpotLimitOrder/example.go +++ b/examples/chain/3_MsgCreateSpotLimitOrder/example.go @@ -5,18 +5,19 @@ import ( "os" "time" + "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -78,20 +79,36 @@ func main() { msg.Order = exchangetypes.SpotOrder(*order) simRes, err := chainClient.SimulateMsg(clientCtx, msg) + if err != nil { fmt.Println(err) } + simResMsgs := common.MsgResponse(simRes.Result.Data) msgCreateSpotLimitOrderResponse := exchangetypes.MsgCreateSpotLimitOrderResponse{} msgCreateSpotLimitOrderResponse.Unmarshal(simResMsgs[0].Data) + if err != nil { fmt.Println(err) } - fmt.Println("simulated order hash", msgCreateSpotLimitOrderResponse.OrderHash) + fmt.Println("simulated order hash: ", msgCreateSpotLimitOrderResponse.OrderHash) + + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) + if err != nil { fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/4_MsgCreateSpotMarketOrder/example.go b/examples/chain/4_MsgCreateSpotMarketOrder/example.go index 6e384041..66fcc7ec 100644 --- a/examples/chain/4_MsgCreateSpotMarketOrder/example.go +++ b/examples/chain/4_MsgCreateSpotMarketOrder/example.go @@ -5,18 +5,20 @@ import ( "os" "time" + "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -84,14 +86,28 @@ func main() { simResMsgs := common.MsgResponse(simRes.Result.Data) msgCreateSpotMarketOrderResponse := exchangetypes.MsgCreateSpotMarketOrderResponse{} msgCreateSpotMarketOrderResponse.Unmarshal(simResMsgs[0].Data) + if err != nil { fmt.Println(err) } + fmt.Println("simulated order hash", msgCreateSpotMarketOrderResponse.OrderHash) + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) + if err != nil { fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/5_MsgCancelSpotOrder/example.go b/examples/chain/5_MsgCancelSpotOrder/example.go index 8990eae2..29586ff2 100644 --- a/examples/chain/5_MsgCancelSpotOrder/example.go +++ b/examples/chain/5_MsgCancelSpotOrder/example.go @@ -5,17 +5,18 @@ import ( "os" "time" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -64,6 +65,7 @@ func main() { fmt.Println(err) } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { @@ -71,4 +73,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/6_MsgCreateDerivativeLimitOrder/example.go b/examples/chain/6_MsgCreateDerivativeLimitOrder/example.go index 51d204f3..83efe047 100644 --- a/examples/chain/6_MsgCreateDerivativeLimitOrder/example.go +++ b/examples/chain/6_MsgCreateDerivativeLimitOrder/example.go @@ -5,19 +5,20 @@ import ( "os" "time" - cosmtypes "github.com/cosmos/cosmos-sdk/types" + "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + cosmtypes "github.com/cosmos/cosmos-sdk/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -81,20 +82,36 @@ func main() { msg.Order = exchangetypes.DerivativeOrder(*order) simRes, err := chainClient.SimulateMsg(clientCtx, msg) + if err != nil { fmt.Println(err) } + simResMsgs := common.MsgResponse(simRes.Result.Data) msgCreateDerivativeLimitOrderResponse := exchangetypes.MsgCreateDerivativeLimitOrderResponse{} msgCreateDerivativeLimitOrderResponse.Unmarshal(simResMsgs[0].Data) + if err != nil { fmt.Println(err) } + fmt.Println("simulated order hash", msgCreateDerivativeLimitOrderResponse.OrderHash) + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) + if err != nil { fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/7_MsgCreateDerivativeMarketOrder/example.go b/examples/chain/7_MsgCreateDerivativeMarketOrder/example.go index 4e9c911f..0c7f6263 100644 --- a/examples/chain/7_MsgCreateDerivativeMarketOrder/example.go +++ b/examples/chain/7_MsgCreateDerivativeMarketOrder/example.go @@ -5,19 +5,20 @@ import ( "os" "time" - cosmtypes "github.com/cosmos/cosmos-sdk/types" + "github.com/InjectiveLabs/sdk-go/client/common" "github.com/shopspring/decimal" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + cosmtypes "github.com/cosmos/cosmos-sdk/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -81,20 +82,36 @@ func main() { msg.Order = exchangetypes.DerivativeOrder(*order) simRes, err := chainClient.SimulateMsg(clientCtx, msg) + if err != nil { fmt.Println(err) } + simResMsgs := common.MsgResponse(simRes.Result.Data) msgCreateDerivativeMarketOrderResponse := exchangetypes.MsgCreateDerivativeMarketOrderResponse{} msgCreateDerivativeMarketOrderResponse.Unmarshal(simResMsgs[0].Data) + if err != nil { fmt.Println(err) } + fmt.Println("simulated order hash", msgCreateDerivativeMarketOrderResponse.OrderHash) + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) + if err != nil { fmt.Println(err) } + time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/8_MsgCancelDerivativeOrder/example.go b/examples/chain/8_MsgCancelDerivativeOrder/example.go index ca587144..999e9006 100644 --- a/examples/chain/8_MsgCancelDerivativeOrder/example.go +++ b/examples/chain/8_MsgCancelDerivativeOrder/example.go @@ -5,17 +5,18 @@ import ( "os" "time" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -64,6 +65,7 @@ func main() { fmt.Println(err) } + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(msg) if err != nil { @@ -71,4 +73,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") } diff --git a/examples/chain/9_MsgBatchCancelSpotOrders/example.go b/examples/chain/9_MsgBatchCancelSpotOrders/example.go index 3632555b..e97eff31 100644 --- a/examples/chain/9_MsgBatchCancelSpotOrders/example.go +++ b/examples/chain/9_MsgBatchCancelSpotOrders/example.go @@ -5,18 +5,19 @@ import ( "os" "time" - cosmtypes "github.com/cosmos/cosmos-sdk/types" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/InjectiveLabs/sdk-go/client/common" exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" - "github.com/InjectiveLabs/sdk-go/client/common" + cosmtypes "github.com/cosmos/cosmos-sdk/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) func main() { // network := common.LoadNetwork("mainnet", "k8s") network := common.LoadNetwork("testnet", "k8s") tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { fmt.Println(err) } @@ -73,6 +74,7 @@ func main() { msg.Data = []exchangetypes.OrderData{*order} CosMsgs := []cosmtypes.Msg{msg} + // AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg err = chainClient.QueueBroadcastMsg(CosMsgs...) if err != nil { @@ -80,4 +82,13 @@ func main() { } time.Sleep(time.Second * 5) + + gasFee, err := chainClient.GetGasFee() + + if err != nil { + fmt.Println(err) + return + } + + fmt.Println("gas fee:", gasFee, "INJ") }