How to use local binance smart chain lightclient to access the blockchain with web3 js

0 votes

I have downloaded and launched the light client node.

./lightd --chain-id "Binance-Chain-Tigris" --node tcp:// I[2021-03-25|03:19:19.040] Connecting to source HTTP client... I[2021-03-25|03:19:19.041] Constructing Verifier... I[2021-03-25|03:19:19.041] lite/proxy/NewVerifier()... module=lite/proxy chainID=Binance-Chain-Tigris rootDir=.binance-lite client=WSEvents I[2021-03-25|03:19:19.098] DBProvider.LatestFullCommit()... module=lite label=trusted.mem chainID=Binance-Chain-Tigris minHeight=1 maxHeight=9223372036854775807 I[2021-03-25|03:19:19.098] DBProvider.LatestFullCommit()... module=lite label=trusted.lvl chainID=Binance-Chain-Tigris minHeight=1 maxHeight=9223372036854775807 I[2021-03-25|03:19:19.099] DBProvider.LatestFullCommit() found latest. module=lite label=trusted.lvl height=1 I[2021-03-25|03:19:19.100] Starting proxy... I[2021-03-25|03:19:19.697] Starting RPC HTTP server on

I can see that the proxy is started. I use the following line of code to set up the web3:-

const httpsUrl = process.env.HTTPS_URL const wssUrl = process.env.WSS_URL const jsonRpcUrl = process.env.JSON_RPC_URL const web3 = Helpers.initWeb3(httpsUrl) const web3Socket = Helpers.initWeb3Socket(wssUrl)

Then I want to connect to a smart contract in order to see the events being emitted.

let factoryContract = Helpers.initContract(web3Socket, factoryABI, factoryAddress) trackPairCreatedEvent(factoryContract) function trackPairCreatedEvent(factoryContract) { trackEvent(, handlePairCreatedEvent ) } function trackEvent(event, callback) { event .on('data', callback) .on('error', console.error) }

I can see that node has received the WS connection

I[2021-03-25|03:27:17.455] New websocket connection remote= I[2021-03-25|03:27:17.455] Starting wsConnection remote= impl=wsConnection

But the node.js process the crashes with an error

[25.03.2021 03:21.34.630] [ERROR] Error: Returned error: Method not found at Object.ErrorResponse (/Users/ok/Workspace/aimbot/node_modules/web3-core-helpers/lib/errors.js:28:19) at Object.callback (/Users/ok/Workspace/aimbot/node_modules/web3-core-requestmanager/lib/index.js:303:36) at /Users/ok/Workspace/aimbot/node_modules/web3-providers-ws/lib/index.js:114:45 at Array.forEach (<anonymous>) at WebsocketProvider._onMessage (/Users/ok/Workspace/aimbot/node_modules/web3-providers-ws/lib/index.js:102:69) at W3CWebSocket._dispatchEvent [as dispatchEvent] (/Users/ok/Workspace/aimbot/node_modules/yaeti/lib/EventTarget.js:115:12) at W3CWebSocket.onMessage (/Users/ok/Workspace/aimbot/node_modules/websocket/lib/W3CWebSocket.js:234:14) at WebSocketConnection.<anonymous> (/Users/ok/Workspace/aimbot/node_modules/websocket/lib/W3CWebSocket.js:205:19) at WebSocketConnection.emit (node:events:376:20) at WebSocketConnection.processFrame (/Users/ok/Workspace/aimbot/node_modules/websocket/lib/WebSocketConnection.js:554:26) at /Users/ok/Workspace/aimbot/node_modules/websocket/lib/WebSocketConnection.js:323:40 at processTicksAndRejections (node:internal/process/task_queues:75:11) { data: null }

Everything works perfectly when I used the URLs provider by ANKR (same as infura in ETH), but I don't understand why an error is thrown when I try to use the local light node?

Apr 6, 2022 in Blockchain by Soham
• 9,700 points

1 answer to this question.

0 votes

So the answer is that I was trying to connect using "Binance Chain" light node which is not EVM compatible, in order to connect to BSC Geth must be used according to

Hope this helps!

Enroll in Blockchain Course to learn from the expert!

answered Apr 12, 2022 by Rahul
• 9,670 points

Related Questions In Blockchain

0 votes
1 answer
0 votes
1 answer

How to prevent the smart contract from being modified and deployed in the blockchain network?

To expand on Matthew's answer, each state ...READ MORE

answered Jul 6, 2018 in Blockchain by aryya
• 7,450 points
0 votes
1 answer

How to access member functions of smart contract using web3?

I have implemented a similar feature and ...READ MORE

answered Aug 13, 2018 in Blockchain by slayer
• 29,350 points
0 votes
2 answers

How do I interact with a smart contract on a private network through web3.js

I found a blog that explains how ...READ MORE

answered Aug 20, 2018 in Blockchain by slayer
• 29,350 points
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,450 points
0 votes
1 answer
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP