0.1.4 • Published 2 years ago
segenie-js v0.1.4
Segenie-js
The npm package used to communicate with the segenie project. The core functionality of this npm package is to provide functionality for token gating.
The package exposes the SegenieAgent
agent which can be easily instantiated.
import SegenieAgent from "segenie-js";
const agent = new SegenieAgent("https://icp0.io");
Using the agent we can get all of the nfts owned by the user. This is very easily achievable in the following way:
const nfts = agent.getPortalsOfUser("the principal of the user");
// we are loggin every nft owned by the specified user
nfts.forEach(nft => {
console.log(nft);
});
Now that there is access to all of the nfts owned by the user it is easy to implement token gating features.
Examples
Using the segenie-js npm package there are other things that can also be done. In the future we are looking to expand the functions the Segenie actor exposes.
- Querying all the collections a user has created:
const agent = new SegenieAgent("https://icp0.io");
const collections = await agent.getCollectionsCreatedBy("2vxsx-fae");
console.log(collections);
- Querying all nfts in existance:
const agent = new SegenieAgent("https://icp0.io");
const nfts = await agent.getAllNfts();
console.log(nfts);