参数
要查询的账户公钥(base-58 编码字符串)
包含以下可选字段的配置对象:
显示 config fields
显示 config fields
响应
如果请求的账户不存在,返回
null。否则返回包含以下内容的对象:显示 result fields
显示 result fields
代码示例
基本请求
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
{
"encoding": "base58"
}
]
}'
响应
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 430
},
"value": {
"data": ["", "base58"],
"executable": false,
"lamports": 5000000000,
"owner": "11111111111111111111111111111111",
"rentEpoch": 18446744073709551615,
"space": 0
}
},
"id": 1
}
带数据切片的请求
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
{
"encoding": "base64",
"dataSlice": {
"offset": 0,
"length": 64
}
}
]
}'
使用 web3.js
import { Connection, PublicKey } from '@solana/web3.js';
const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
const publicKey = new PublicKey('vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg');
const accountInfo = await connection.getAccountInfo(
publicKey,
'confirmed'
);
注意事项
-
jsonParsed编码仅适用于某些账户类型:- 质押账户
- 代币账户
- 代币铸造
- 代币元数据
-
使用
dataSlice时,数据字段将仅限于请求的切片。 - 账户数据的编码方式可能因拥有该账户的程序而异。
常见错误
| 错误码 | 消息 | 解决方案 |
|---|---|---|
| -32602 | Invalid param: WrongSize | 验证公钥是否有效 |
| -32602 | Invalid param: not base58 encoded string | 确保公钥是 base58 编码的 |
| -32007 | Account not found | 请求的账户不存在 |