I'm trying to connect my small server web app in ExpressJS to the BSC blockchain, but without success.
As per my understanding, the Web3 library provides all the required stuff under the hood, and I can connect by calling
new Web3(new Web3.providers.HttpProvider(urlToRpcNode))
By following this, I put the following into my function, which serves as a Web3 object init:
return new Web3(new Web3.providers.HttpProvider(https://bsc-dataseed1.binance.org));
According to BscScan, the given argument is the URL to the RPC Node for BSC https://bscscan.com/apis#rpc.
Unfortunately, awaiting this call just gets stuck forever and doesn't return anything.
What am I doing wrong? Any help is appreciated.
Edit:
I found another link to Binance Docs, where it outlines the specific process for connecting to BSC. Here is how they do it:
const web3 = new Web3('https://bsc-dataseed1.binance.org:443');
https://docs.binance.org/smart-chain/developer/create-wallet.html#connect-to-bsc-network
Unfortunately, this gives me the same result.
Few months later, I remembered asking this. I ended up using an external RPC node provider (fe. QuickNode, Ankr, Infura).
I don't have my exact code on hand, but I know that the steps were as follows:
https://mynode2241235.ankr.com/
, let's call that LINK
from now.Web3
connection code snippet and just modified it by putting this LINK
as an HttpProvider
, so sth like this:const instance = new Web3(new Web3.providers.HttpProvider(LINK));