Coder Social home page Coder Social logo

cip-sdk's Introduction

Canto Identity Protocol SDK (CIP-SDK)

The Canto Identity Protocol SDK provides easy use functions to retrieving user CIP data.

Canto Identity Protocol

Canto Identity Protocol (CIP) is an on-chain identity protocol that aggregates identity from Subprotocols. Anyone can permissionlessly create a Subprotocol to represent any kind of identity trait โ€“ textual, visual, or otherwise. End users freely choose which traits to include in their on-chain identity.

Install

npm i cip-sdk

Example

import { ethers } from 'ethers';
import { CIP } from 'cip-sdk';

// Initialize provider and CIP instance
const provider = new ethers.JsonRpcProvider('<YOUR_CANTO_RPC_URL>');
const cipInstance = new CIP(provider);

// Retrieve user data using CIP
const namespace = await cipInstance.getNamespaceByAddress('<USER_CANTO_ADDRESS>');
const bio = await cipInstance.getBioByAddress('<USER_CANTO_ADDRESS>');
const pfp = await cipInstance.getPfpByAddress('<USER_CANTO_ADDRESS>');

Methods

  • getCID(address): CID - returns the CIP NFT ID of the provided address.
  • getPrimaryData(cid, subprotocolName): sub protocol CID - Method is used to get the users NFT IDs of any subprotocol registered with the user's CID.
  • getNamespaceCID(cid): namespace CID - Method used to get the users registered namespace CID.
  • getBioCID(cid): bio CID - Method used to get the user's registered bio CID.
  • getPfpCID(cid): pfp CID - Method used to get the user's registered pfp CID.
  • getNamespace(namespaceCID): Namespace - Method used to return te user's registered namespace display name and base name.
  • getPfpData(pfpCID): ProfilePictureData - Method used to get the user's profile picture data from profile picture contract. Profile picture data = [nftContractAddress, nftID]
  • getPfpImage(nftContractAddress, nftID): ProfilePictureInfo - Method used to get the user's pfp image data. return value will be src = image src, alt: nft name.
  • getBio(bioCID): bio - Method used to get user's bio information. return value is a string of the registered bio.
  • getBioByAddress(address): bio - Method is an aggregation of getCID, getBioCID and getBio. This method only needs user's address to return the bio.
  • getNamespaceByAddress(address): Namespace - Method used to get user's namespace data. This method is also an aggregation of getCID, getNamespaceCID, and getNamespace.
  • getPfpByAddress(address): ProfilePictureInfo - Method used to get the user's profile picture data. This method is also an aggregation of getCID, getPfpData, getPfpImage. return value will be src = image src, alt: nft name.
  • registerSubprotocol(ordered, primary, active, nftAddress, name, fee): ethers.ContractTransaction - Method used to register new sub protocol to cip.

cip-sdk's People

Contributors

tyler-cranmer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.