跳转到主要内容

参数

此方法不需要任何参数。

响应

result
object

代码示例

基本请求

curl http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getIdentity"
}'

使用 web3.js

import { Connection } from '@solana/web3.js';

const connection = new Connection('http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
const identity = await connection.getIdentity();
console.log(identity);

使用 Python

from solana.rpc.api import Client

client = Client("http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY")
response = client.get_identity()
print(response)

注意事项

  1. 返回您所连接的验证者节点的身份公钥
  2. 用于识别您正在与哪个节点通信
  3. 响应是即时的,因为它从节点的配置中读取
  4. 可用于验证是否连接到预期的节点

最佳实践

  1. 在排查节点连接问题时使用此方法
  2. 将返回的身份与预期的节点身份进行比较以进行验证
  3. 适当处理网络错误并重试