{"id":15646341,"url":"https://github.com/paulrberg/evm-bn","last_synced_at":"2025-04-30T12:07:49.270Z","repository":{"id":49777750,"uuid":"368952476","full_name":"PaulRBerg/evm-bn","owner":"PaulRBerg","description":"Convert fixed-point numbers to ethers big numbers and vice-versa.","archived":false,"fork":false,"pushed_at":"2023-04-13T09:42:08.000Z","size":2880,"stargazers_count":49,"open_issues_count":3,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-25T07:41:51.899Z","etag":null,"topics":["bignumber","blockchain","ethereum","ethersjs","evm"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PaulRBerg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://gitcoin.co/grants/1657/PaulRBerg-open-source-engineering","github":"PaulRBerg"}},"created_at":"2021-05-19T17:39:08.000Z","updated_at":"2024-11-06T16:34:01.000Z","dependencies_parsed_at":"2024-10-03T12:24:06.560Z","dependency_job_id":"028b4a70-b978-42a4-ae29-a1a184f3e9f6","html_url":"https://github.com/PaulRBerg/evm-bn","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulRBerg%2Fevm-bn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulRBerg%2Fevm-bn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulRBerg%2Fevm-bn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulRBerg%2Fevm-bn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PaulRBerg","download_url":"https://codeload.github.com/PaulRBerg/evm-bn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242650897,"owners_count":20163610,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bignumber","blockchain","ethereum","ethersjs","evm"],"created_at":"2024-10-03T12:12:30.551Z","updated_at":"2025-03-09T05:30:34.787Z","avatar_url":"https://github.com/PaulRBerg.png","language":"TypeScript","funding_links":["https://gitcoin.co/grants/1657/PaulRBerg-open-source-engineering","https://github.com/sponsors/PaulRBerg"],"categories":[],"sub_categories":[],"readme":"# Evm Bn [![GitHub Actions][gha-badge]][gha] [![Coverage][codecov-badge]][codecov] [![Styled with Prettier][prettier-badge]][prettier] [![License: MIT][license-badge]][license]\n\n[gha]: https://github.com/PaulRBerg/evm-bn/actions\n[gha-badge]: https://github.com/PaulRBerg/evm-bn/actions/workflows/ci.yml/badge.svg\n[codecov]: https://codecov.io/gh/PaulRBerg/evm-bn\n[codecov-badge]: https://codecov.io/gh/PaulRBerg/evm-bn/branch/main/graph/badge.svg\n[prettier]: https://prettier.io\n[prettier-badge]: https://img.shields.io/badge/Code_Style-Prettier-ff69b4.svg\n[license]: https://opensource.org/licenses/MIT\n[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg\n\nEvm Bn is a utility for converting between stringified fixed-point numbers and\n[Ethers.js](https://github.com/ethers-io/ethers.js) BigNumbers, as well as the reverse process. It is particularly\nuseful for projects based on the Ethereum Virtual Machine (EVM), given that 1 ETH is equivalent to 1e18 wei.\n\n- Accepts scientific notation.\n- Limits the precision to 78 digits.\n- Enforces 60 integer digits and 18 fractional digits.\n- Designed to be used alongside\n  [@ethersproject/bignumber](https://github.com/ethers-io/ethers.js/tree/master/packages/bignumber).\n- Slices the fractional digits automatically at position `n + 1` and above, with `n` the number of decimals, rounding\n  down in the process.\n\n## Install\n\n```sh\n$ pnpm add evm-bn\n```\n\n## Usage\n\n### To Bn\n\n```ts\nimport type { BigNumber } from \"@ethersproject/bignumber\";\nimport { toBn } from \"evm-bn\";\n\n// 3141500000000000000\nconst foo: BigNumber = toBn(\"3.1415\");\n\n// 115792089237316195423570985008687907853269984665640564039457584007913129639935\nconst bar: BigNumber = toBn(\"115792089237316195423570985008687907853269984665640564039457.584007913129639935\");\n\n// 100000000000000\nconst baz: BigNumber = toBn(\"100e6\", 6);\n```\n\n### From Bn\n\n```ts\nimport type { BigNumber } from \"@ethersproject/bignumber\";\nimport { fromBn } from \"evm-bn\";\n\n// 3.1415\nconst foo: BigNumber = fromBn(BigNumber.from(\"3141500000000000000\"));\n\n// 115792089237316195423570985008687907853269984665640564039457.584007913129639935\nconst bar: BigNumber = fromBn(\n  BigNumber.from(\"115792089237316195423570985008687907853269984665640564039457584007913129639935\"),\n);\n\n// 100000000\nconst baz: BigNumber = fromBn(BigNumber.from(\"100000000000000\"), 6);\n```\n\n## Contributing\n\nFeel free to dive in! [Open](https://github.com/PaulRBerg/evm-bn/issues/new) an issue,\n[start](https://github.com/PaulRBerg/evm-bn/discussions/new) a discussion or submit a PR.\n\n### Set Up\n\nClone the repositories and install the dependencies:\n\n```sh\n$ pnpm install\n```\n\nNow you can start making changes.\n\n## License\n\nThis project is licensed under MIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulrberg%2Fevm-bn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulrberg%2Fevm-bn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulrberg%2Fevm-bn/lists"}