bnb-chain / go-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to send max amount BNB?

elvis-hp opened this issue · comments

commented

Hi everyone, I need send max amount, so how to send maximum amount? I don't know how to get a fee for the transaction.
I'm using go-sdk.
thanks!

send, err := client.SendToken([]msg.Transfer{{toAccAddress, []types.Coin{{nativeSymbol, amount}}}}, true)

commented

I got the function, thanks all!

func (bs *BinanceService) GetFees() ([]interface{}, error) {

	c := basic.NewClient(bs.conf.BinanceConfig.API_URL)

	qp := map[string]string{}
	resp, code, err := c.Get("/fees", qp)

	var fees []interface{}

	if err != nil {
		if code == http.StatusNotFound {
			return fees, nil
		}
		return nil, err
	}

	if err := json.Unmarshal(resp, &fees); err != nil {
		return nil, err
	}

	return fees, err

}