Crypto Miner
Crypto Miner

Reputation: 125

How to get pending transactions on BSC

I am trying to get pending transactions from the mempool on BSC using a websocket - the same way I was getting pending transactions on the Ethereum network:

web3Ws = new Web3(new Web3.providers.WebsocketProvider(WEBSOCKET_PROVIDER_LINK));
web3Ws.eth.subscribe('pendingTransactions', function (error, result)

When working with Ethereum, I set WEBSOCKET_PROVIDER_LINK to be wss://${NETWORK}.infura.io/ws/v3/${PROJECT_ID}, but I don't know how to create WebSocket to get pending transactions on BSC.

What provider link can I use to get pending transactions on BSC?

Upvotes: 10

Views: 15880

Answers (1)

BananaNeil
BananaNeil

Reputation: 10782

I think you're looking for https://getblock.io/nodes/bsc

Once you get an API key, you can use this websocket address:

wss://bsc.getblock.io/mainnet/?api_key=API_KEY

I just implemented it, and it seems to be working for me!

UPDATE:

I have had better success with this service: https://www.quicknode.com

GetBlock worked for me, but would sometimes get a little out of sync with the network.

Upvotes: 6

Related Questions