New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ic0

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ic0 - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

3

package.json
{
"name": "ic0",
"version": "0.1.0",
"version": "0.1.1",
"description": "An easy-to-use JavaScript API for the Internet Computer.",

@@ -36,2 +36,3 @@ "author": "DFINITY Foundation",

"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"ts-jest": "^29.0.3",

@@ -38,0 +39,0 @@ "ts-node": "^10.9.1",

@@ -8,3 +8,3 @@

The `ic0` npm package makes it easier to call Internet Computer (IC) canisters from outside of the IC.
The `ic0` package is a simple, straightfoward way to interact with canisters running on the [Internet Computer](https://internetcomputer.org/) (IC).

@@ -19,3 +19,3 @@ ## Installation

Add the following code to your web application or Node.js script:
Try running the following code from Node.js or a web application:

@@ -25,17 +25,30 @@ ```ts

const ledger = ic('ryjl3-tyaaa-aaaaa-aaaba-cai'); // Access the IC ledger canister
const ledger = ic('ryjl3-tyaaa-aaaaa-aaaba-cai'); // Ledger canister
console.log(await ledger.call('name')); // Call the `name` method
console.log(await ledger.call('name')); // Call the `name()` method
```
## Replica Canisters
Easily call any Internet Computer canister using the following syntax:
A **replica canister** represents a live canister running on the IC (or local replica), identified by a unique
[Principal](https://medium.com/dfinity/internet-computer-basics-part-1-principals-and-identities-215e8f239da4).
```ts
import ic from 'ic0';
ic(canisterId).call(method, ...args); // IC mainnet
ic.local(canisterId).call(method, ...args); // Local replica
```
## Local Canisters
The [`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:
```ts
const backend = ic.local('rrkah-fqaaa-aaaaa-aaaaq-cai'); // Access a local canister
backend.call('myFunction', 123); // Call `myFunction(123)`
```
### Basic usage:
```ts
import ic from 'ic0';
const ledger = ic('ryjl3-tyaaa-aaaaa-aaaba-cai'); // Principal for the IC ledger

@@ -61,10 +74,2 @@

Access a canister on your local replica (served by `dfx start`):
```ts
import ic from 'ic0';
const canister = ic.local('rrkah-fqaaa-aaaaa-aaaaq-cai');
```
## Dev Canisters

@@ -92,7 +97,7 @@

```ts
import { devCanister, replicaCanister } from 'ic0';
import { devCanister, ic } from 'ic0';
const backend = import.meta.env.DEV
? devCanister('backend')
: replicaCanister('rrkah-fqaaa-aaaaa-aaaaq-cai'); // Principal of deployed canister
: ic('rrkah-fqaaa-aaaaa-aaaaq-cai'); // Deployed canister

@@ -104,3 +109,3 @@ console.log(await backend.call('getValue')); // Call the `getValue()` method on the deployed canister when in production

A **mock canister** makes it easy to mock the behavior of a canister.
A **mock canister** makes it easy to [mock](https://stackoverflow.com/a/2666006) the behavior of a canister.

@@ -150,5 +155,5 @@ ### Basic usage:

- [mo-dev](https://github.com/dfinity/motoko-dev-server): a live-reload server for local Motoko dapp development
- [agent-js](https://github.com/dfinity/agent-js): a collection of npm packages for building on the Internet Computer
- [node-motoko](https://github.com/dfinity/node-motoko): run Motoko programs directly in the browser
- [mo-dev](https://github.com/dfinity/motoko-dev-server): a live-reload server for local Motoko dapp development
- [@infu/icblast](https://github.com/infu/icblast): a community-built library for exploring the IC and writing integration tests
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc