Solana RPC API手册

getTokenSupply

Returns the total supply of an SPL Token type.

请求参数

  • <string> - Pubkey of token Mint to query, as base-58 encoded string
  • <object> - (optional) Commitment

响应结果

The result will be an RpcResponse JSON object with value equal to a JSON object containing:

  • amount: <string> - the raw total token supply without decimals, a string representation of u64
  • decimals: <u8> - number of base 10 digits to the right of the decimal place
  • uiAmount: <number | null> - the total token supply, using mint-prescribed decimals DEPRECATED
  • uiAmountString: <string> - the total token supply as a string, using mint-prescribed decimals

示例代码

请求:

curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
  {"jsonrpc":"2.0", "id":1, "method":"getTokenSupply", "params": ["3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E"]}

响应:

{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 1114
    },
    "value": {
      "amount": "100000",
      "decimals": 2,
      "uiAmount": 1000,
      "uiAmountString": "1000",
    }
  },
  "id": 1
}