Replies: 5 comments 15 replies
-
It's hard to overstate how important the migration to native BigInt will be for the ecosystem. Ethers 6 can play a big role in that. Ideally, Ethers.js should simply return BigInts by default. If not, there should at least be a way to opt in to it. BigInt is widely supported in all modern browsers. Node 12 will be End-Of-Life on April 30th 2022. Node 14 and Node 16 already support native BigInt. |
Beta Was this translation helpful? Give feedback.
-
I had a long response to this, but while reviewing some of my research notes and updating them, found that many of the bottlenecks have become less of a hurdle, some even recently. First off, let me just say I would LOVE to move to ES2020 BigInt. Numbers and maths are hard, and have plenty of room for mistakes. The ethers BigNumber library has been a lot of work to keep happy and keep the people who use it as happy as possible. It is also a tonne of code that exists, merely so people can add two numbers together in a way that is safe. One issue still lies with Goja which does have a Pull Request open, but it looks like there may be issues with it. But this is one the main points of my resistance: ethers is used in many places, in various platforms and environments. For example, if it were to move to BigInt, ethers would no longer work in Geth, which uses Goja. But with community assistance, these areas can be improved for everyone. :) Regardless, I've added a poll to my twitter, in case anyone wishes to comment in a more impromptu fashion. :) |
Beta Was this translation helpful? Give feedback.
-
@ricmoo Can I build ethers 6 and give it a try? I'd love to! Maybe even in production in some minor contract interactions. I would love to code to support BigInts. |
Beta Was this translation helpful? Give feedback.
-
fwiw using a library like JSBI shows minimal overhead https://gist.github.com/sambacha/e96b6248a068e76d542aa922358c2b13 edit: you can get more info here about the perf. diff https://bugs.chromium.org/p/v8/issues/detail?id=11515 |
Beta Was this translation helpful? Give feedback.
-
It was a good decision to use BigNumber in the past to support different environments. But by now most environments support native bigint's (or theoretically could use the ethers@5 or use transpiler). And the performance penalty is very annoying, even if you don't use BigNumber for calculations. For example when you request big arrays of numbers from blockchain ethers parse all of them to BigNumber's. |
Beta Was this translation helpful? Give feedback.
-
Hello.
I would like ethers smart contract instances to return the
BigInt
native type for the numeric values instead ofBigNumber
. Are there plans to shift out of BigInt? Or maybe make it configurable likecontractInstance.numberFormat = 'BigInt'
or similar.(Meanwhile I have created a small helper to recursively convert resulting values to BigInt.)
Beta Was this translation helpful? Give feedback.
All reactions