Replies: 7 comments 2 replies
-
Just figured out a way to do this with ethers js: |
Beta Was this translation helpful? Give feedback.
-
I wasn't planning to add these into the standard Block object, since they are very rarely used and I'm not sure all backends support them. What are you using them for? I could certainly have my mind changed, I've just never found a use for them. Also, it is not safe to use the The |
Beta Was this translation helpful? Give feedback.
-
I'm working on a project in which I need to verify a transaction hash included in a transaction root of a block. I couldn't find transactionsRoot key which intuitively should be there in a block so I started finding for a workaround to get it.
Sure that it is not used at all most of the time. But I think we can add instructions in the docs for those developers who might need that data, how can they get the info they need depending on node whether they'll get it or not.
Oh thanks for pointing this wrong practice, I was facing this issue with blockTag but couldn't figure it out earlier. |
Beta Was this translation helpful? Give feedback.
-
@ricmoo Would it be possible to re-open this issue ? |
Beta Was this translation helpful? Give feedback.
-
I think this could be given a second thought. In the rpc specs they do mention these fields. Though I agree that the use case for these projects is very very niche (like maybe doing some L2 stuff), they are anyway present in response whenever a get block request is done. Though I don't think this is a blocker or urgent at all, but it could be nice to have. Opening so that we won't miss to reconsider it.
@paouvrard You may go by the hacky way mentioned in #667 (comment) |
Beta Was this translation helpful? Give feedback.
-
Thank you @zemse this worked well.
|
Beta Was this translation helpful? Give feedback.
-
I may add some of these back in for v6, but likely won't make this change for v5. As an extra note, you can do something akin to: const rawBlock = await provider.send(
'eth_getBlockByNumber',
[ethers.utils.hexValue(blockNumber), true]
);
const fullBlock = provider.formatter.blockWithTransactions(rawBlock);
fullBlock.stateRoot = provider.formatter.hash(rawBlock.stateRoot);
// etc. This will help keep the block largely normalized for the other properties. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am working on a block explorer project with ethers.js, experiencing that some data is not being outputted (specifically transaction and state roots). I tried the same with web3.js and could see these details.
getBlock from web3.js (https://web3js.readthedocs.io/en/v1.2.4/web3-eth.html#id51)
The ethers.js getBlock gives the following output
I also saw #276 which is closed, so I created a new one.
Beta Was this translation helpful? Give feedback.
All reactions