Ethers.js: Support getBlock parameter for returning full transaction objects

Created on 19 Aug 2018  路  2Comments  路  Source: ethers-io/ethers.js

Without this feature I couldn't use this library for retrieving all block transactions since calling getTransation for all transactions in a block is inefficient.

discussion enhancement

Most helpful comment

This is available in 4.0.0.-beta.14. Please let me know if you have any issues with it.

Thanks! :)

All 2 comments

This is something we have been considering adding. The issue is that only certain backends support it. We have two options:

1) Backends that do not support full blocks, return an error.
2) Backends that do not support full blocks, calls fetchTransaction for each transaction hash.

I'm leaning towards 1, since 2 would likely result in a soft-ban from Etherscan when using the EtherscanProvider.

You can, for now, accomplish this by using the JsonRpcProvider.send directly (however, the block is not parsed):

var provider = new ethers.providers.JsonRpcProvider();
provider.send('eth_getBlockByHash', [ blockHash, true ]).then((block) => {
    console.log(block);
});

I'll add this for the v4 release, because it is certainly very useful when processing blocks.

This is available in 4.0.0.-beta.14. Please let me know if you have any issues with it.

Thanks! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GFJHogue picture GFJHogue  路  3Comments

ricmoo picture ricmoo  路  3Comments

pcowgill picture pcowgill  路  3Comments

ricmoo picture ricmoo  路  3Comments

naddison36 picture naddison36  路  3Comments