10

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?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Crypto Miner
  • 125
  • 1
  • 2
  • 5
  • What provider are you using in `WEBSOCKET_PROVIDER_LINK`? (Censor any sensitive data such as API keys if you share the full URL.) ... It seems your provider currently support only Ethereum network, not BSC. – Petr Hejda Mar 23 '21 at 09:22
  • Thanks for your reply. I used 'wss://${NETWORK}.infura.io/ws/v3/${PROJECT_ID}' on Ethereum. I don't know how to create WebSocket to get pending transactions on BSC. What provide link do I have to use on BSC? If you know about that, Please help me. – Crypto Miner Mar 23 '21 at 09:37
  • Infura only provides data for Ethereum and Filecoin. You need to find a provider that provides data for Binance Smart Chain. – Petr Hejda Mar 23 '21 at 10:19
  • 2
    yes. you are right. But I can't find that provider. Could you teach me what is that provider? – Crypto Miner Mar 23 '21 at 10:38

1 Answers1

6

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.

BananaNeil
  • 10,322
  • 7
  • 46
  • 66
  • Honestly that helped me alot, but the details are very limited comparing pending transactions over completed transactions. Do you have an idea how I could get more into detail? I'm trying for over two weeks now. – Chris S. Apr 19 '22 at 11:30