From 75df2677caa955ed3d62eac18e3c6a1fad2103b7 Mon Sep 17 00:00:00 2001 From: Dan Forbes Date: Mon, 9 Sep 2024 06:39:29 -0700 Subject: [PATCH] feat(docs): upgrade-bn (#7232) 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.