0.3.20 • Published 3 years ago
@nft-portal/portal-sdk v0.3.20
Introduction
This SDK exposes all the clients required to interact with Portal services.
Getting Started
Instantiate an Actor by passing the canister id of the target service and optionally in agent.
If you don't pass an agent an anonymous one will be created. If the service requires any permissions you'll have to pass in a agent that has been authenticated.
Here's an example without using an agent to make anonymous calls:
import { PIMetadata } from '@nft-portal/portal-sdk';
const cid = 'aaaaa-aa'; // Your channel canister id
const client = PIMetadata.client(cid);
const res = await client.getMetadata();
console.log(res.ok); // prints out channel metadata
To make authenticated calls use the Portal providers npm package and pass the resulting agent into the client:
import { useAuthentication } from '@nft-portal/providers';
import { PILogging } from '@nft-portal/portal-sdk';
const cid = 'aaaaa-aa'; // Your channel canister id
const { agent } = useAuthentication();
const client = PILogging.client(cid, agent);
const page = {
limit: 100n,
cursor: {
from: 0,
operation: { Next: null },
},
};
const res = await client.listLogs({ page });
console.log(res); // prints out list of logs