Solana JSON RPC 请求超时
Solana JSON RPC requests time out
我正在尝试使用文档 (https://docs.solana.com/developing/clients/jsonrpc-api) 中的 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
为钱包地址
我又遇到超时错误: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}
除了当你 运行 时插槽编号会更高。
我正在尝试使用文档 (https://docs.solana.com/developing/clients/jsonrpc-api) 中的 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
为钱包地址
我又遇到超时错误: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}
除了当你 运行 时插槽编号会更高。