@bundly/ares-core
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-rc.0 • Public • Published

ic-core-js

A JavaScript library for interacting with the Internet Computer (IC).

How to use

Define your Candid Canisters

export const cc: Canister = {
	idlFactory,
	configuration: {
		canisterId: "YOUR_CANDID_CANISTER_ID",
	},
};

export const candidCanisters = {
  cc
};

Define your Rest Canisters

export const rc: Canister = {
  baseUrl: "YOUR_API_REST_URL"
};

export const restCanisters = {
  rc
};

Create a new client

const client = Client.create({
  agent: {
    host: "YOUR_IC_HOST_URL",
  },
  candidCanisters,
  restCanisters,
  providers: [
    new InternetIdentity({
      providerUrl: process.env.INTERNET_IDENTITY_URL,
    }),
  ],
});

Initialize your client

await client.init();

Available Methods

Replace Identity

import { Identity } from '@dfinity/agent';

const identity: Identity = yourIdentity;

await client.replaceIdentity(identity);

Get current Identity

const identity = client.getIdentity();

Get Candid Actor

const candidActor = client.getCandidActor("CANDID_ACTOR_NAME");

Get Rest Actor

const candidActor = client.getRestActor("REST_ACTOR_NAME");

Readme

Keywords

none

Package Sidebar

Install

npm i @bundly/ares-core

Weekly Downloads

99

Version

0.1.0-rc.0

License

MIT

Unpacked Size

74.1 kB

Total Files

8

Last publish

Collaborators

  • adrian.hidalgo
  • alannnc