{"id":30703158,"url":"https://github.com/dfinity/icp-calculator","last_synced_at":"2026-03-16T18:04:26.034Z","repository":{"id":250866357,"uuid":"833739412","full_name":"dfinity/icp-calculator","owner":"dfinity","description":"A calculator of fees and costs for smart contracts on the Internet Computer Protocol (ICP)","archived":false,"fork":false,"pushed_at":"2025-08-25T07:53:32.000Z","size":240,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-26T19:11:46.620Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dfinity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-25T16:39:34.000Z","updated_at":"2025-07-22T19:37:26.000Z","dependencies_parsed_at":"2025-07-08T06:39:21.062Z","dependency_job_id":"38059da7-e54f-43d8-9c3b-dc858421e989","html_url":"https://github.com/dfinity/icp-calculator","commit_stats":null,"previous_names":["dfinity/icp-calculator"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/dfinity/icp-calculator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Ficp-calculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Ficp-calculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Ficp-calculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Ficp-calculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dfinity","download_url":"https://codeload.github.com/dfinity/icp-calculator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Ficp-calculator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273317765,"owners_count":25084037,"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","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-09-02T16:56:32.067Z","updated_at":"2026-03-16T18:04:26.007Z","avatar_url":"https://github.com/dfinity.png","language":"TypeScript","readme":"# icp-calculator\n\nThis repository contains a utility library that implements a calculator of fees\nand costs for smart contracts on the Internet Computer Protocol (ICP).\n\nCurrently it supports the following operations and resources:\n\n- **storage**: the cost to store some number of bytes for some period of time.\n- **message execution**: the cost to execute some number of instructions.\n- **message sending**: the cost to send some number of bytes as a message.\n- **HTTP outcalls**: the cost to make an HTTP outcall.\n- **canister creation**: the cost to create a canister.\n\nMore will be added in the future.\n\n## Installation\n\n```bash\n# with npm\nnpm install @dfinity/icp-calculator\n# with pnpm\npnpm add @dfinity/icp-calculator\n# with yarn\nyarn add @dfinity/icp-calculator\n```\n\n## Usage\n\nSee `src/index.spec.ts` for more examples of usage.\n\n```typescript\nimport {\n  calculators,\n  Direction,\n  Duration,\n  Mode,\n} from \"@dfinity/icp-calculator\";\nimport type { Bytes, Instructions } from \"@dfinity/icp-calculator\";\n\nconst $ = calculators().calculatorUSD;\nconst storage1mb = $.storage(1_000_000 as Bytes, Duration.fromDays(365));\nconst execute1b = $.execution(Mode.Replicated, 1_000_000_000 as Instructions);\nconst send1mb = $.message(\n  Mode.Replicated,\n  Direction.UserToCanister,\n  1_000_000 as Bytes,\n);\n\nexpect(storage1mb).toBeCloseTo(0.00494, 5);\nexpect(execute1b).toBeCloseTo(0.00053, 5);\nexpect(send1mb).toBeCloseTo(0.00265, 5);\n```\n\n## How it works\n\nThe main logic of the calculator is in `src/calculator.ts`.\nThe code there mirrors the replica code and it depends on the replica config, which is stored in `src/icp/config.json`.\nThe JSON config file is generated by the `icp_config` tool in the replica repository.\n\nThe JSON config file can be updated as follows:\n\n```\n# Check out `https://github.com/dfinity/ic` to `~/ic`\n# Check out `https://github.com/dfinity/icp-calculator` to `~/icp-calculator`\ncd ~/ic\nbazel run //rs/execution_environment/tools:icp_config -- --replica-version=rc--2024-07-25_01-30 --output=~/icp-calculator/src/icp/config.json\n```\n\n## Documentation\n\n`@dfinity/icp-calculator` exposes following types and functions:\n\n\u003c!-- TSDOC_START --\u003e\n\n### :toolbox: Functions\n\n- [calculators](#gear-calculators)\n\n#### :gear: calculators\n\nThe main export of the library. It returns cost calculators that operate in\ncycles and USD based on the given options.\n\n| Function      | Type                                              |\n| ------------- | ------------------------------------------------- |\n| `calculators` | `(options?: Options or undefined) =\u003e Calculators` |\n\nParameters:\n\n- `options`: - optional options to configure the calculators.\n\n[:link: Source](https://github.com/dfinity/icp-calculator/tree/main/src/index.ts#L64)\n\n\u003c!-- TSDOC_END --\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfinity%2Ficp-calculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdfinity%2Ficp-calculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfinity%2Ficp-calculator/lists"}