Documentation Index
Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
Use this file to discover all available pages before exploring further.
返回与提供的公钥关联的账户的所有信息。
包含以下可选字段的配置对象:
查询网络时使用的 commitment 级别:
processed:最新区块(未确认)
confirmed:超级多数确认
finalized:超级多数最终确认
账户数据的编码格式:
base58
base64
base64+zstd
jsonParsed(仅限某些账户类型)
请求账户数据的切片:
offset: number - 起始位置(以字节为单位)
length: number - 返回的字节数
如果请求的账户不存在,返回 null。否则返回包含以下内容的对象:
data
[string, string] | object
账户的数据。格式取决于 encoding 参数:
- 如果编码为 base58/base64,则为
[string, encoding] 元组
- 如果编码为 “jsonParsed”,则为解析后的 JSON 对象
代码示例
基本请求
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 | 请求的账户不存在 |