Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eth JSON-RPC: eth_subscribe should take 0 or 1 argument #1573

Closed
ychiaoli18 opened this issue Jan 27, 2023 · 0 comments
Closed

Eth JSON-RPC: eth_subscribe should take 0 or 1 argument #1573

ychiaoli18 opened this issue Jan 27, 2023 · 0 comments

Comments

@ychiaoli18
Copy link

Based on the doc, eth_subscribe should take 0 or 1 argument.

  • newHeads or pendingTransactions: take 0 argument
  • logs: takes 1 argument

Code to reproduce

Reproduce with wscat

Connected (press CTRL+C to quit)
> {"jsonrpc":  "2.0",  "id":  1,  "method":  "eth_subscribe",  "params":  ["newHeads"]}
< {"jsonrpc":"2.0","id":1,"error":{"code":-32602,"message":"wrong param count (method 'eth_subscribe'): 1 != 2"}}
Connected (press CTRL+C to quit)
> {"jsonrpc":  "2.0",  "id":  1,  "method":  "eth_subscribe",  "params":  ["newHeads", null]}
< {"jsonrpc":"2.0","result":1,"id":1}

Reproduce with web3.js

const Web3 = require('web3');

const host = '<RPC_endpoint'>;

const web3 = new Web3('ws://' + host + '/rpc/v0')

const subscription = web3.eth.subscribe('newBlockHeaders', function(error, result){
  console.log(error, result);
});

setInterval(() => {}, 1 << 30);

Returned error:
Error: Returned error: wrong param count (method 'eth_subscribe'): 1 != 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants