ethers-rs/examples/big-numbers
DaniPopes 439a0c7de0
chore(deps): bump and use workspace dependencies (#2222)
* chore: update all deps

* chore: update dependabot

* chore: separate ethers package from workspace

* chore: package metadata

* chore: use package.*.workspace = true

* fix: docs.rs build

* chore: update examples manifests

* chore: use workspace dependencies for ethers-* crates

* fix: test

* chore: use workspace dependencies for all dependencies

* chore: pin rust-crypto

* chore: add license field to example crates

* fixes

* more fixes

* fix: test

* last fixes

* fix: wasm

* fix: docs.rs build

* fix

* fix: wasm-pack error

see also https://github.com/rustwasm/wasm-pack/issues/1238

* fix: wasm deps and example

* ci: update

* fix: wasm tests

* fix: eip712 tests

* fix: windows ci

* fix

* chore: update docsrs metadata

* chore: bump version to match crates.io

* chore: rm bad release.toml config

* chore: rm release.toml

bad configuration

* chore: add exclude to workspace

* fix: middleware

* fix: solc feature flags

* chore: run cargo upgrade

* chore: update deps

* chore: update remaining deps

* undo fix

* update lock

* bump yubi

* fix: update coins-* and fix spki breaking changes
2023-03-16 12:28:35 -07:00
..
examples docs: mdbook (#1994) 2023-01-03 15:18:38 +02:00
Cargo.toml chore(deps): bump and use workspace dependencies (#2222) 2023-03-16 12:28:35 -07:00
README.md refactor: examples (#1940) 2022-12-29 14:53:11 +02:00

README.md

Big numbers

Ethereum uses big numbers (also known as "bignums" or "arbitrary-precision integers") to represent certain values in its codebase and in blockchain transactions. This is necessary because the EVM operates on a 256-bit word size, which is different from the usual 32-bit or 64-bit of modern machines. This was chosen for the ease of use with 256-bit cryptography (such as Keccak-256 hashes or secp256k1 signatures).

It is worth noting that Ethereum is not the only blockchain or cryptocurrency that uses big numbers. Many other blockchains and cryptocurrencies also use big numbers to represent values in their respective systems.

Utilities

In order to create an application, it is often necessary to convert between the representation of values that is easily understood by humans (such as ether) and the machine-readable form that is used by contracts and math functions (such as wei). This is particularly important when working with Ethereum, as certain values, such as balances and gas prices, must be expressed in wei when sending transactions, even if they are displayed to the user in a different format, such as ether or gwei. To help with this conversion, ethers-rs provides two functions, parse_units and format_units, which allow you to easily convert between human-readable and machine-readable forms of values. parse_units can be used to convert a string representing a value in ether, such as "1.1", into a big number in wei, which can be used in contracts and math functions. format_units can be used to convert a big number value into a human-readable string, which is useful for displaying values to users.