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

web3.eth.getBlockTransactionCount do not return any response #2369

Closed
LuiJunYe opened this issue Feb 11, 2019 · 4 comments · Fixed by #2390
Closed

web3.eth.getBlockTransactionCount do not return any response #2369

LuiJunYe opened this issue Feb 11, 2019 · 4 comments · Fixed by #2390
Labels
Bug Addressing a bug

Comments

@LuiJunYe
Copy link

All issues which aren't created with this template will get immediately closed.

Expected behavior

web3.eth.getBlockTransactionCount will return the total transaction count for the block

Actual behavior

Error return from nodejs and do not receive any total transaction count from the web3.

Steps to reproduce the behavior

  1. Simply get the block number from ropsten
  2. Put the block number inside the web3.eth.getBlockTransactionCount
  3. console.log the result

Error Logs

Error: Node error: {"code":-32602,"message":"missing value for required argument 1"} at Function.validate (C:\xampp\htdocs\xcoin-btc\node_modules\web3-providers\dist\web3-providers.cjs.js:349:18) at C:\xampp\htdocs\xcoin-btc\node_modules\web3-providers\dist\web3-providers.cjs.js:462:57 at process._tickCallback (internal/process/next_tick.js:68:7) (node:13152) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

Versions

web3 ^1.0.0-beta.46
node v10.15.0
ropsten testnet

@OFRBG
Copy link

OFRBG commented Feb 11, 2019

Testing with

const Web3 = require('web3');

const web3 = new Web3('https://ropsten.infura.io/metamask');

web3.eth.getBlockNumber().then(async (block) => {
  const txCount = await web3.eth.getBlockTransactionCount(block);
  /* ^^^ throws ^^^ */

  console.log(txCount);
});

I believe these two are the guilty lines.

https://github.com/ethereum/web3.js/blob/35ebbcacbecc75a6cac033fc648d0091e0235a83/packages/web3-core-method/src/methods/block/GetBlockTransactionCountMethod.js#L32-L34

https://github.com/ethereum/web3.js/blob/35ebbcacbecc75a6cac033fc648d0091e0235a83/packages/web3-core-method/src/methods/block/GetBlockTransactionCountMethod.js#L44-L46


Unless I'm missing something, these should instead call eth_getBlockTransactionCountByNumber and eth_getBlockTransactionCountByHash respectively.

@LuiJunYe
Copy link
Author

Thanks. Is there any work around on getting the block transaction count?

@OFRBG
Copy link

OFRBG commented Feb 11, 2019

You could try to get all the transactions and count, use ethers.js, do a direct request to the nodes, or modify your local web3 package. Otherwise, wait for the fix 😿.

@nivida
Copy link
Contributor

nivida commented Feb 11, 2019

Thanks for submitting this issue. I‘ll test and fix it asap (I just destroyed my macbook with mouth rinse hopefully I can repair it today or I have to buy a new one asap)

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

Successfully merging a pull request may close this issue.

3 participants