npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

avatarid-js-sdk

v1.0.8

Published

LIFEFORM AvatarID SDK

Downloads

5

Readme

AvatarID API接入说明

简介

​ AvatarID是由 Lifeform 提供的一套去中心化的自定义头像协议,用户可以通过持有的NFT(无论是721还是1155)自定义自己的专属WEB3头像。

​ AvatarID API 由 Lifeform 提供给第三方项目的集成API,只需要几行代码就可以在自己的WEB3应用里实现用户的自定义头像功能。

协议地址

bsc 测试网

0xA4fC79e00BdD38722A7fA236d766B4f3f671bF09

bsc 主网

0x905De1Ac381b330c2C187cea0f1685E85a844390

接口说明

1.设置用户自定义头像
/**
  * set AvatarId
  * @collect avatar's contract address
  * @tokenId avatar id
  * @addr owner address
  * */
async setAvatar

调用示例

const web3 = new Web3(ethereum)
const AvatarIdSDK = new AvatarId(web3)
// collect可默认传空
AvatarIdSDK.setAvatar('',token_id,owner_address)
2.重制用户自定义头像
/**
  * reset AvatarId
  * @addr owner address
  * @collect avatar's contract address
  * */
async resetAvatar

调用示例

const web3 = new Web3(ethereum)
const AvatarIdSDK = new AvatarId(web3)
// collect可默认传空
AvatarIdSDK.resetAvatar(owner_address,'')
3.取得用户可用的自定义头像
/**
  * get avatar list
  * @collect avatar's contract address
  * @addr owner address
  * @page select a page, start at 0
  * @size page size
  * */
async getAvatarList

调用示例

const web3 = new Web3(ethereum)
const AvatarIdSDK = new AvatarId(web3)
// collect可默认传空
AvatarIdSDK.getAvatarList('',owner_address,page_num,page_size)

返回示例

[
  {
    image:'xxx',
    token_id:'xxx'
  },
  {
    image:'xxx',
    token_id:'xxx'
  }
]
4.查看当前用户自定义头像的详情
/**
  * get AvatarId details
  * @collect avatar's contract address
  * @addr owner address
  * */
async getStakeAvatarDetails

调用示例

const web3 = new Web3(ethereum)
const AvatarIdSDK = new AvatarId(web3)
// collect可默认传空
AvatarIdSDK.getStakeAvatarDetails('',owner_address)

返回示例

{
  image:'xxx',
  token_id:'xxx' //如果是默认头像 则返回-1
}
5.授权Avatar资产权限
/**
  * approve avatar
  * @collect avatar's contract address
  * @addr owner address
  * @type collect type
  * */
async approve

调用示例

const web3 = new Web3(ethereum)
const AvatarIdSDK = new AvatarId(web3)
// collect可默认传空
AvatarIdSDK.approve('',owner_address,collect_type)

接入说明

  1. 安装api

    npm i avatarid-js-sdk
  2. 引入api代码

    import AvatarId from 'avatarid-js-sdk'
  3. 初始化api,需要先创建provider,然后构造avatarid 实例

    const web3 = new Web3(ethereum)
    const AvatarIdSDK = new AvatarId(web3)
  4. getAvatarList可以获得用户持有的avata nft 列表

  5. getStakeAvatarDetails可以查看当前自定义头像详情,如果用户没设置过,会有默认头像

  6. 如果需用支持用户自定义头像,需要做资产合约的approve接口就行授权操作。授权通过后,通过调用setAvatar,进行头像设置,也可以引导用户到Lifeform官网的设置页面就行设置,https://www.lifeform.cc/avatarid

  7. 如果用户希望取消该功能,只需要执行resetAvatar接口就可以完成,并返回用户质押的资产。

  8. 如果需要支持项目方自己的NFT作为自定义头像,请发邮件到:[email protected]