1.0.6 • Published 1 year ago

@testprotocol/avatar v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

@testprotocol/avatar

Getting started

Prerequisites

  • Have your web3 provider ready (infura, etc)
  • You must have both a MATIC and ETH Provider

And you're good to go!

Installation

# npm
npm install @testprotocol/avatar

# yarn
yarn add @testprotocol/avatar

Usage

import { Avatar } from "@testprotocol/avatar";

const avatar = new Avatar(
  "https://polygon-mainnet.infura.io/v3/<API_KEY>", // MATIC Provider
  "https://mainnet.infura.io/v3/<API_KEY>" // ETH Provider
);

async function getAvatar() {
  const avatar = await avatar.getAvatar("rare.llamaverse");
  // avatar = https://gateway.pinata.cloud/ipfs/QmSSt6VmXPSuUcCUuHF9YB6G8xRMAYquY5d7eCmcy846Fp/499.gif
}

async function getAvatarDetails() {
  const avatarDetails = await avatar.getAvatarDetails("rare.llamaverse");
  // avatarDetails = { avatar: ... , originalAvatar: ... , type: erc721 }
}

Functions

getAvatar

Returns the avatar uri of a given name. If the given name does not have an avatar, it returns null

async getAvatar(name: string) => Promise<string | null>;

getAvatarDetails

Returns detailed info about the avatar of a given name, which includes the resolved avatar, the original avatar, and the avatar type. If the given name does not have an avatar, it returns null

async getAvatarDetails(name: string) => Promise< { avatar: string; originalAvatar: string; type: AvatarTypes; } | null | undefined >

Supported avatar specs

NFTs

  • ERC721
  • ERC1155

URIs

  • HTTP
  • Base64
  • IPFS

Options

Custom IPFS Gateway (Default: https://gateway.pinata.cloud)

const avatar = new Avatar(
  "https://polygon-mainnet.infura.io/v3/<API_KEY>", // MATIC Provider
  "https://mainnet.infura.io/v3/<API_KEY>", // ETH Provider
  { ipfs: "https://ipfs.io" }
);