solana-go/rpc/getTokenSupply.go

29 lines
630 B
Go
Raw Normal View History

2021-07-02 04:50:14 -07:00
package rpc
import (
"context"
"github.com/gagliardetto/solana-go"
2021-07-02 04:50:14 -07:00
)
// GetTokenSupply returns the total supply of an SPL Token type.
func (cl *Client) GetTokenSupply(
ctx context.Context,
tokenMint solana.PublicKey, // Pubkey of token Mint to query
commitment CommitmentType, // optional
2021-07-02 04:50:14 -07:00
) (out *GetTokenSupplyResult, err error) {
params := []interface{}{tokenMint}
if commitment != "" {
params = append(params,
M{"commitment": commitment},
)
}
2021-07-20 12:29:06 -07:00
err = cl.rpcClient.CallForInto(ctx, &out, "getTokenSupply", params)
2021-07-02 04:50:14 -07:00
return
}
type GetTokenSupplyResult struct {
RPCContext
Value *UiTokenAmount `json:"value"`
}