From 9e02d007acf899beec4271900b3eed994e67b38b Mon Sep 17 00:00:00 2001 From: Dan Forbes Date: Tue, 3 Sep 2024 12:19:18 -0400 Subject: [PATCH] feat(docs): upgrade-bn Add a section in "Upgrade from 1.x" for `BN` vs `BigInt` Closes #6705 --- .../1.x/web3_utils_migration_guide.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/docs/guides/web3_upgrade_guide/1.x/web3_utils_migration_guide.md b/docs/docs/guides/web3_upgrade_guide/1.x/web3_utils_migration_guide.md index 0b977890e6e..5282b720823 100644 --- a/docs/docs/guides/web3_upgrade_guide/1.x/web3_utils_migration_guide.md +++ b/docs/docs/guides/web3_upgrade_guide/1.x/web3_utils_migration_guide.md @@ -17,6 +17,18 @@ import web3Utils from 'web3-utils'; import * as web3Utils from 'web3-utils'; ``` +## No `BN` property + +The `web3-utils` package no longer includes a `BN` property for using the [the `bn.js` package](https://github.com/indutny/bn.js/) for working with (big) numbers. In 4.x, [the native JavaScript `BigInt` type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) is used. + +```ts +// 1.x +new Web3.utils.BN(1); + +// 4.x +BigInt(4); +``` + ## Unit conversion functions The `toWei` does not have an optional second parameter. You have to pass the source unit explicitly.