小编For*_*Wiz的帖子

如何使用Web3.js库将服务器连接到币安智能链?

我正在尝试将 ExpressJS 中的小型服务器 Web 应用程序连接到 BSC 区块链,但没有成功。

根据我的理解,Web3 库提供了所有必需的内容,我可以通过调用进行连接

new Web3(new Web3.providers.HttpProvider(urlToRpcNode))

按照这个,我将以下内容放入我的函数中,该函数充当 Web3 对象 init:

return new Web3(new Web3.providers.HttpProvider(https://bsc-dataseed1.binance.org));

根据 BscScan,给定的参数是 BSC 的 RPC 节点的 URL https://bscscan.com/apis#rpc

不幸的是,等待这个调用只会永远卡住并且不会返回任何内容。

我究竟做错了什么?任何帮助表示赞赏。

编辑:

我找到了币安文档的另一个链接,其中概述了连接 BSC 的具体流程。他们是这样做的:

const web3 = new Web3('https://bsc-dataseed1.binance.org:443');

https://docs.binance.org/smart-chain/developer/create-wallet.html#connect-to-bsc-network

不幸的是,这给了我同样的结果。

ethereum web3js binance binance-chain

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

binance ×1

binance-chain ×1

ethereum ×1

web3js ×1