Reputation: 371
I'm new to blockchain. My question is how can I get binance blockchain info without explorers (get block by number, get transaction by hash)? ETH has tools such as geth
or web3
where I can simply make a eth.getTransaction(hash)
or eth.getBlock(number)
requests and get any transaction/block info. Binance has API but as far as I understand you can get info only for your wallet. Are there any official tools for binance blockchain? Where have explorers got binance blockchain info?
Upvotes: 0
Views: 1618
Reputation: 104
You can use most of the same tools, such as web3. Just use the binance as the provider (JS):
// mainnet
const web3 = new Web3('https://bsc-dataseed1.binance.org:443');
// testnet
const web3 = new Web3('https://data-seed-prebsc-1-s1.binance.org:8545');
In python you have to add middlewear:
from web3 import Web3
from web3.middleware import geth_poa_middleware
web3 = Web3(Web3.WebsocketProvider(
"wss://bsc-ws-node.nariox.org:443",
websocket_timeout=60,
))
web3.middleware_onion.inject(geth_poa_middleware, layer=0)
Upvotes: 1