Solana JSON RPC请求超时



我试图使用文档中的API示例(https://docs.solana.com/developing/clients/jsonrpc-api)从Solana区块链查询信息。我使用:

curl https://api.mainnet-beta.solana.com:8899 -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBalance",
"params": [
"KEY"
]
}
'

每当我运行这个,我得到一个超时错误:

curl: (7) Failed to connect to api.mainnet-beta.solana.com port 8899: Timed out
curl: (3) [globbing] unmatched brace in column 1
curl: (6) Couldn't resolve host 'jsonrpc'
curl: (6) Couldn't resolve host '2.0,'
curl: (6) Couldn't resolve host 'id'
curl: (6) Couldn't resolve host '1,'
curl: (6) Couldn't resolve host 'method'
curl: (6) Couldn't resolve host 'getBalance,'
curl: (6) Couldn't resolve host 'params'
curl: (3) [globbing] bad range specification in column 2
curl: (6) Couldn't resolve host 'Key'
curl: (3) [globbing] unmatched close brace/bracket in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 1

我在这里做错了什么吗?谁能解释一下为什么这不起作用?我还尝试了Python:

import requests
import json
url = "https://api.mainnet-beta.solana.com:8899"
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "getBalance",
"params": [
"KEY"
]
}
response = requests.post(url, json=payload).json()
print(response)

KEY是钱包地址

和I另一个超时错误:https://pastebin.com/38BC2xds。有人请解释为什么这不起作用,我需要做什么来解决它?

访问主集群时不需要端口号,因此您可以尝试:

$ curl https://api.mainnet-beta.solana.com -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"getBalance", "params":["83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"]}'

应该给出如下内容:

{"jsonrpc":"2.0","result":{"context":{"slot":101535695},"value":0},"id":1}

除了运行时槽号会更高。

相关内容

  • 没有找到相关文章

最新更新