Hey guys,
Anyone else having trouble connecting to the BSC archive endpoint? See the example below.
#!/usr/bin/env python3
import requests
import json
endpoint_bsc = (
"https://speedy-nodes-nyc.moralis.io/REMOVED/bsc/mainnet/archive"
)
endpoint_ava = "https://speedy-nodes-nyc.moralis.io/REMOVED/avalanche/mainnet/archive"
headers = {"content-type": "application/json"}
payload = {"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 83}
r = requests.post(endpoint_ava, data=json.dumps(payload), headers=headers, verify=False)
print(json.loads(r.text))
r = requests.post(endpoint_bsc, data=json.dumps(payload), headers=headers, verify=False)
print(json.loads(r.text))
$ python3 test_bsc.py
{'jsonrpc': '2.0', 'id': 83, 'result': '0x99eb76'}
Traceback (most recent call last):
File "/Users/billy_boy/test_bsc.py", line 16, in <module>
print(json.loads(r.text))
File "/usr/local/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The JSONDecodeError at the end is because the response failed from the BSC endpoint.