Handling large integers is a common need in blockchain development, especially when dealing with cryptocurrencies like Ethereum where numbers can get extremely large. ethers.js, a popular JavaScript library for interacting with the Ethereum blockchain, has long supported this functionality using BigNumber
. In ethers.js version 6, BigNumber
now comes from the bignumber.js
library, which offers more robust and feature-rich capabilities for handling large integers.
In this section, we will walk through how to work with BigNumber
in ethers.js version 6, including creating instances, performing arithmetic operations, comparisons, and conversions.