getTokenAccountBalance RPC 方法

返回 SPL Token 账户的代币余额。

$ curl https://api.devnet.solana.com -s -X \
> POST -H "Content-Type: application/json" -d '
> {
> "jsonrpc": "2.0",
> "id": 1,
> "method": "getTokenAccountBalance",
> "params": [
> "7fUAJdStEuGbc3sM84cKRL6yYaaSstyLSU4ve5oovLS7",
> {
> "commitment": "finalized"
> }
> ]
> }
> '

params

stringrequired

要查询的 Token 账户的 pubkey,使用 base-58 编码的字符串。

objectoptional

包含以下字段的配置对象:

result

Response
{
"jsonrpc": "2.0",
"result": {
"context": { "slot": 1114 },
"value": {
"amount": "9864",
"decimals": 2,
"uiAmount": 98.64,
"uiAmountString": "98.64"
}
},
"id": 1
}
object

结果将是一个包含以下内容的 JSON 对象:

有关返回数据的更多详细信息,请参阅 Token Balances Structure 中的响应,该响应与 getBlock 的结构类似。

Is this page helpful?