{"id":13523423,"url":"https://github.com/dfinity/node-ic0","last_synced_at":"2025-09-02T16:56:47.368Z","repository":{"id":65338674,"uuid":"587449226","full_name":"dfinity/node-ic0","owner":"dfinity","description":"An easy-to-use JavaScript API for the Internet Computer.","archived":false,"fork":false,"pushed_at":"2024-11-08T20:05:55.000Z","size":554,"stargazers_count":19,"open_issues_count":4,"forks_count":2,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-08-09T00:54:52.978Z","etag":null,"topics":["blockchain","browser","canister","internet-computer","motoko","nodejs","npm","smart-contracts","typescript","web3"],"latest_commit_sha":null,"homepage":"","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}},"created_at":"2023-01-10T19:25:13.000Z","updated_at":"2025-04-04T04:01:27.000Z","dependencies_parsed_at":"2024-04-04T02:40:57.755Z","dependency_job_id":"fb676ae6-3d6d-4822-816b-84a15ed02988","html_url":"https://github.com/dfinity/node-ic0","commit_stats":{"total_commits":70,"total_committers":2,"mean_commits":35.0,"dds":"0.11428571428571432","last_synced_commit":"dc0c4a137242c7088d63f1d34dcfc41e20bb034b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dfinity/node-ic0","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Fnode-ic0","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Fnode-ic0/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Fnode-ic0/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Fnode-ic0/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dfinity","download_url":"https://codeload.github.com/dfinity/node-ic0/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Fnode-ic0/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":["blockchain","browser","canister","internet-computer","motoko","nodejs","npm","smart-contracts","typescript","web3"],"created_at":"2024-08-01T06:00:59.959Z","updated_at":"2025-09-02T16:56:47.342Z","avatar_url":"https://github.com/dfinity.png","language":"TypeScript","readme":"\n# `ic0` \u0026nbsp;[![npm version](https://img.shields.io/npm/v/ic0.svg?logo=npm)](https://www.npmjs.com/package/ic0) [![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dfinity/ic0/issues)\n\n\u003e ### An easy-to-use JavaScript API for the [Internet Computer](https://internetcomputer.org/).\n\n---\n\nThe `ic0` package is a simple, straightfoward way to interact with canisters running on the [Internet Computer](https://internetcomputer.org/) (IC). \n\n## Installation\n\n```sh\nnpm i --save ic0\n```\n\n## Quick Start\n\nTry running the following code from Node.js or a web application:\n\n```ts\nimport ic from 'ic0';\n\nconst ledger = ic('ryjl3-tyaaa-aaaaa-aaaba-cai'); // Ledger canister\n\nconsole.log(await ledger.call('name')); // Call the `name()` method\n```\n\nEasily call any Internet Computer canister using the following syntax:\n\n```ts\nimport ic from 'ic0';\n\nic(canisterId).call(method, ...args); // IC mainnet\n\nic.local(canisterId).call(method, ...args); // Local replica\n```\n\n## Local Canisters\n\nThe [`dfx start`](https://internetcomputer.org/docs/current/references/cli-reference/dfx-start) command hosts a local execution environment for developing canister smart contracts. Here is an example of how to call a local canister:\n\n```ts\nconst backend = ic.local('rrkah-fqaaa-aaaaa-aaaaq-cai'); // Access a local canister\n\nbackend.call('myFunction', 123); // Call `myFunction(123)`\n```\n\n### Basic usage:\n\n```ts\nconst ledger = ic('ryjl3-tyaaa-aaaaa-aaaba-cai'); // Principal for the IC ledger\n\nconsole.log(await ledger.call('name')); // =\u003e { name: 'Internet Computer' }\n```\n\n### Advanced usage:\n\nReplica canisters use [agent-js](https://github.com/dfinity/agent-js) behind the scenes.\n\n```ts\nimport { replica, HttpAgent } from 'ic0';\n\nconst ic = replica(new HttpAgent({ ... })); // Use a custom agent from `@dfinity/agent`\n\nconst ledger = ic('ryjl3-tyaaa-aaaaa-aaaba-cai');\n\nconsole.log(await ledger.call('name')); // =\u003e { name: 'Internet Computer' }\n```\n\n## Mock Canisters\n\nA **mock canister** makes it easy to [mock](https://stackoverflow.com/a/2666006) the behavior of a canister.\n\n### Basic usage:\n\n```ts\nimport { mockCanister } from 'ic0';\n\nconst mock = mockCanister({\n    // Mock canister method named `echo()`\n    async echo(x: number) {\n        return x;\n    }\n});\n\nconsole.log(await mock.call('echo', 123)); // =\u003e 123\n```\n\n### Advanced usage:\n\nProvide a fallback canister and/or compose several mocks by passing a second argument to the `mockCanister()` function:\n\n```ts\nimport { mockCanister, replicaCanister } from 'ic0';\n\nconst ledger = replicaCanister(principal, agent);\n\nconst mockLedger = mockCanister({\n    async echo(x: number) {\n        return x;\n    }\n}, ledger); // Fall back to the deployed `ledger` canister\n\nconst mock = mockCanister({\n    async runMock() {\n        return this.call('echo', 456); // Call the mocked `echo()` function\n    }\n}, mockLedger); // Fall back to another mock canister\n\nconsole.log(await mock.call('runMock')); // =\u003e 456\n```\n\n## Related Projects\n\nCheck out the following GitHub repositories for more IC-related npm packages:\n\n- [agent-js](https://github.com/dfinity/agent-js): a collection of npm packages for building on the Internet Computer\n- [node-motoko](https://github.com/dfinity/node-motoko): run Motoko programs directly in the browser\n- [mo-dev](https://npmjs.com/package/mo-dev): a live-reload server for local Motoko dapp development\n- [@infu/icblast](https://github.com/infu/icblast): a community-built library for exploring the IC and writing integration tests\n","funding_links":[],"categories":["Client Libraries (Agents)"],"sub_categories":["JavaScript/TypeScript"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfinity%2Fnode-ic0","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdfinity%2Fnode-ic0","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfinity%2Fnode-ic0/lists"}