Module: Solana::Ruby::Kit::Rpc::Api::GetTokenSupply
- Extended by:
- T::Helpers, T::Sig
- Included in:
- Client
- Defined in:
- lib/solana/ruby/kit/rpc/api/get_token_supply.rb
Overview
Fetch the total supply of an SPL Token mint. Mirrors TypeScript's GetTokenSupplyApi.getTokenSupply.
Instance Method Summary collapse
Instance Method Details
#get_token_supply(token_mint, commitment: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/solana/ruby/kit/rpc/api/get_token_supply.rb', line 23 def get_token_supply(token_mint, commitment: nil) config = {} config['commitment'] = commitment.to_s if commitment result = transport.request('getTokenSupply', [token_mint, config].tap { |a| a.pop if a.last.empty? }) slot = Kernel.Integer(result['context']['slot']) raw = result['value'] value = { amount: raw['amount'], decimals: Kernel.Integer(raw['decimals']), ui_amount: raw['uiAmount'], ui_amount_string: raw['uiAmountString'] } RpcTypes::RpcContextualValue.new(slot: slot, value: value) end |