I am using Rivet WebSockets RPC call with web3.py to get pending transactions in Ethereum mempool.


This is the code I have used so far. But the call returns an error

from web3 import Web3, HTTPProvider
import statistics

rivet = 'wss://b9e4817100b74cd3b72e486fd79d4a06.eth.ws.rivet.cloud/'
web3 = Web3(Web3.WebsocketProvider(rivet))

pending_transactions = web3.provider.make_request("eth_subscribe", 

Error: {'jsonrpc': '2.0', 'id': 0, 'error': {'code': -32602, 'message': 'non-array args'}}

What is wrong here? How can I proceed. Need help!

  • the subscription mechanism doesn't work for getting ALL transactions from tx pool as they arrive to it. However there is a backend funcitonality implemented (github.com/ethereum/go-ethereum/blob/…), so you can extend it yourself by modifying Geth
    – Nulik
    Aug 16 at 19:26
  • the pending transaction functionality in Ethclient is only for getting your own pending transactions, but not everybody's transactions
    – Nulik
    Aug 16 at 19:27
  • you either get all transaction on each RPC request or modify geth to work in subscription mode
    – Nulik
    Aug 16 at 19:28
  • Thank you for clarifying how subscribe works. I was looking for something similar to parity_pendingTransactions which returns an array of pending transactions in the mempool. In rivet, I find only eth_pendingTransactions method which returns pending transactions from my node.
    – sijo0703
    Aug 17 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.