![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
ic0
An easy-to-use JavaScript API for the Internet Computer.
The ic0
package is a simple, straightfoward way to interact with canisters running on the Internet Computer (IC).
npm i --save ic0
Try running the following code from Node.js or a web application:
import ic from 'ic0';
const ledger = ic('ryjl3-tyaaa-aaaaa-aaaba-cai'); // Ledger canister
console.log(await ledger.call('name')); // Call the `name()` method
Easily call any Internet Computer canister using the following syntax:
import ic from 'ic0';
ic(canisterId).call(method, ...args); // IC mainnet
ic.local(canisterId).call(method, ...args); // Local replica
The dfx start
command hosts a local execution environment for developing canister smart contracts. Here is an example of how to call a local canister:
const backend = ic.local('rrkah-fqaaa-aaaaa-aaaaq-cai'); // Access a local canister
backend.call('myFunction', 123); // Call `myFunction(123)`
const ledger = ic('ryjl3-tyaaa-aaaaa-aaaba-cai'); // Principal for the IC ledger
console.log(await ledger.call('name')); // => { name: 'Internet Computer' }
Replica canisters use agent-js behind the scenes.
import { replica, HttpAgent } from 'ic0';
const ic = replica(new HttpAgent({ ... })); // Use a custom agent from `@dfinity/agent`
const ledger = ic('ryjl3-tyaaa-aaaaa-aaaba-cai');
console.log(await ledger.call('name')); // => { name: 'Internet Computer' }
A mock canister makes it easy to mock the behavior of a canister.
import { mockCanister } from 'ic0';
const mock = mockCanister({
// Mock canister method named `echo()`
async echo(x: number) {
return x;
}
});
console.log(await mock.call('echo', 123)); // => 123
Provide a fallback canister and/or compose several mocks by passing a second argument to the mockCanister()
function:
import { mockCanister, replicaCanister } from 'ic0';
const ledger = replicaCanister(principal, agent);
const mockLedger = mockCanister({
async echo(x: number) {
return x;
}
}, ledger); // Fall back to the deployed `ledger` canister
const mock = mockCanister({
async runMock() {
return this.call('echo', 456); // Call the mocked `echo()` function
}
}, mockLedger); // Fall back to another mock canister
console.log(await mock.call('runMock')); // => 456
Check out the following GitHub repositories for more IC-related npm packages:
FAQs
An easy-to-use JavaScript API for the Internet Computer.
The npm package ic0 receives a total of 6 weekly downloads. As such, ic0 popularity was classified as not popular.
We found that ic0 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.