# @testprotocol/avatar

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

Latest version **1.0.6** (published 2022-12-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install @testprotocol/avatar
pnpm add @testprotocol/avatar
yarn add @testprotocol/avatar
bun add @testprotocol/avatar
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2022-12-12 |
| First published | 2022-12-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 84.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | testprotocol |

## Links

- npm: https://www.npmjs.com/package/@testprotocol/avatar
- Repository: https://github.com/TestProtocol/avatar
- Homepage: https://github.com/TestProtocol/avatar#readme
- Issues: https://github.com/TestProtocol/avatar/issues
- npm.io page: https://npm.io/package/@testprotocol/avatar

## Dependencies (5)

- [web3](https://npm.io/package/web3.md) ^1.8.1
- [axios](https://npm.io/package/axios.md) ^1.2.1
- [tslib](https://npm.io/package/tslib.md) ^2.4.1
- [web3-utils](https://npm.io/package/web3-utils.md) ^1.8.1
- [@ensdomains/eth-ens-namehash](https://npm.io/package/@ensdomains/eth-ens-namehash.md) ^2.0.15

## Recent versions

- 1.0.6 (latest) — 2022-12-12
- 1.0.5 — 2022-12-12
- 1.0.4 — 2022-12-12

## README

# @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

```bash
# npm
npm install @testprotocol/avatar

# yarn
yarn add @testprotocol/avatar
```

### Usage

```js
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

```js
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

```js
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)_

```js
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" }
);
```

---
_Source: https://npm.io/package/@testprotocol/avatar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
