5 当我想获取bsc mempool 中完整的tx,报错:too many arguments, want at most 1

我通过websockets发送: '{"id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions", true]}'

而且应该得到完整的交易细节而不是哈希值。

但得到的是错误: {"error":{"code":-32602,"message":"too many arguments, want at most 1"},"id":1,"jsonrpc":"2.0"} 如果我发送: { jsonrpc: '2.0',method: 'eth_subscribe',params:['newPendingTransactions'],id: 1} 则正常得到TX的哈希值。 为啥会是这样呢 ?

Python代码如下:

import asyncio
import json
from websockets import connect

ws_url = 'wss://bsc.getblock.io/xxxxxx/mainnet/'

async def get_event():
    async with connect(ws_url) as ws:
        await ws.send(
            '{"id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions", true]}')
        subscription_response = await ws.recv()
        print(subscription_response)

        while True:
            try:
                message = await asyncio.wait_for(ws.recv(), timeout=15)
                response = json.loads(message)
                print(response)
                pass
            except:
                pass

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    while True:
        loop.run_until_complete(get_event())
请先 登录 后评论

最佳答案 2023-06-08 06:23

那个true 参数,需要比较新版本的geth 才能支持,bsc 抄代码抄的比较早,自己分支有没有合并这个特性,所以不支持true 这个参数。

eth 就能支持。

请先 登录 后评论

其它 2 个回答

Tiny熊 - 布道者
  擅长:智能合约,以太坊
请先 登录 后评论
链人
请先 登录 后评论
  • 3 关注
  • 0 收藏,1201 浏览
  • fryyyyyy 提出于 2023-06-06 21:59

相似问题