• Stars
    star
    135
  • Rank 267,885 (Top 6 %)
  • Language
    TypeScript
  • License
    GNU General Publi...
  • Created over 3 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NFT Data Fetching Hooks with Zora contract data

@zoralabs/nft-hooks

Simple React hooks to load Zora NFT data. Includes on-chain data, NFT metadata, and tools for fetching NFT content if needed.

Put together, these power implementations of the zNFT protocol on any website.

This library consists of a data fetch class and associated React hooks to load NFT data is an easy, efficient manner. The API both batches and caches requests, meaning you can use the hooks across a page without needing to worry about significant performance penalties.

πŸ‘― See also: @zoralabs/nft-components a complimentary library to this one to render NFT data on a webpage.

Install:

yarn add @zoralabs/nft-hooks

Then you can import and use the hooks in your react application:

import {useZNFT, useNFTMetadata} from "@zoralabs/nft-hooks";

function MyNFT() {
  const {data} = useZNFT("20");
  const {metadata} = useNFTMetadata(data && data.metadataURI);
  
  return (
    <div>
      <h3>{metadata.title}</h3>
      <p>{metadata.description}</p>
      <p>Owned by: {data.owner.id}</p>
    </div>
  );
}

All hooks:

Hook Usage
useNFT Fetches on-chain NFT data using a configured backend strategy
useNFTQuery Queries for NFTs using a configured backend strategy
useNFTMetadata Fetches off-chain metadata (not required for most indexers)
useNFTContent Fetches off-chain content (useful for some text content, but less often used)

Configuration:

To set the network configuration, wrap the hooks used with the NFTFetchConfiguration component.

import {Networks, NFTFetchConfiguration, Strategies} from '@zoralabs/nft-hooks';

const zdkStrategy = Strategies.ZDKFetchStrategy();

function NFTGallery() {
  return (
    <NFTFetchConfiguration strategy={zdkStrategy} networkId={Networks.MAINNET}>
      <NFTList>
    </NFTFetchConfiguration>
  );
}

Data sources:

Provided strategies are:

  1. ZDKFetchStrategy from the zora indexer (recommended)
  2. ZoraV2Indexer strategy from the legacy zora indexer (deprecated)
  3. ZoraGraphStrategy strategy from the zora subgraph (not recommended)
  4. EtherActorStrategy using ether.actor as a nft backend (not recommended)
  5. OpenseaStrategy using opensea's api as a nft backend (not recommended)

Links direct to zora.co interfaces, but can be overridden to directly use the zdk instead.

Development:

  1. git clone https://github.com/ourzora/nft-hooks
  2. cd nft-hooks
  3. npm i -g yarn if you don't have yarn installed
  4. yarn
  5. yarn run test test your code

Pull requests and tickets are accepted for issues and improvements to this library.

More Repositories

1

v3

Solidity
370
star
2

zora-721-contracts

Zora drops contracts (powers create.zora.co)
Solidity
189
star
3

nft-editions

Contracts to lazy-mint editioned ERC721s
Solidity
164
star
4

core

A protocol to create, share and exchange universally accessible and valuable media on the internet.
TypeScript
161
star
5

auction-house

TypeScript
154
star
6

create-auction-house

Starter repo for creating your own auction house with Zora's protocol
TypeScript
121
star
7

nouns-protocol

Solidity
108
star
8

zora-docs

JavaScript
107
star
9

offchain

NFT Metadata made easy
Python
107
star
10

zdk

TypeScript
107
star
11

zorb

Zorb zelated zings
TypeScript
107
star
12

nft-components

NFT Rendering Components
TypeScript
100
star
13

nouns-builder

Nouns Builder
TypeScript
89
star
14

lanyard

Decentralized allowlists for web3
TypeScript
78
star
15

zora-protocol

Monorepo for Zora Protocol (contracts & sdks)
Solidity
77
star
16

mint-page-template

TypeScript
71
star
17

nft-metadata

generic nft metadata parsers
TypeScript
65
star
18

faucets

TypeScript
57
star
19

nouns-marketplace

βŒβ—¨-β—¨
TypeScript
49
star
20

foundry-script-examples

Solidity
44
star
21

doge-nft

DOGE NFT
SCSS
32
star
22

media-metadata-schemas

A repository of known JSON metadata schemas for the Zora media protocol.
TypeScript
29
star
23

themis

The legal terms of service for people's tokenized work
29
star
24

zora-v1-subgraph

TypeScript
27
star
25

mintpool

A mempool of things you can bring onchain
Rust
21
star
26

zora-token-factory-deprecated-

A token factory that enables any person or community to tokenize any good or endeavour.
JavaScript
21
star
27

nft-cli

NFT CLI library
TypeScript
17
star
28

protocol-rewards

Solidity
16
star
29

nouns-builder-bot

TypeScript
15
star
30

recovery-protocol

Solidity
15
star
31

simple-wallet-provider

Simple Wallet Provider
TypeScript
15
star
32

smol-safe

smol safe ui
TypeScript
15
star
33

chains-cli

Cli for chain configuration
TypeScript
14
star
34

zora-drops-extensions

Extensions for ZORA Drops
Solidity
11
star
35

nouns-ar-glasses-ios

Nouns AR Glasses for iOS
Swift
11
star
36

nouns-connect

Connect your Nouns DAOs to DApps
TypeScript
10
star
37

thegrandexchange

welp here goes nothing
TypeScript
9
star
38

json-extension-registry

Store arbitrary JSON data associated with a contract
Solidity
8
star
39

zorb-zenerator

JavaScript
8
star
40

zora-drop-frontend

Frontend template iteration for drop site using Zora drops contract factory.
JavaScript
7
star
41

rent-a-vote

Solidity
7
star
42

zora-crypto-list

A list of resources to help get started in crypto.
6
star
43

rug-house

Rug Store Auction House!
TypeScript
6
star
44

cryptomedia

What is Cryptomedia?
HTML
6
star
45

cli

TypeScript
5
star
46

hollyplus-minting-contract

Simple royalty-enabled IPFS minting contract for holly plus
TypeScript
5
star
47

manage-auction-hooks

Hooks to manage auction state for auction houses, integrates with simple-wallet-hooks
TypeScript
4
star
48

first-lol

TypeScript
3
star
49

mad-realities-auction

TypeScript
3
star
50

matthew-ball-minting-contract

On-chain metadata with contentURI implementation for Matthew Ball's Metaverse Essays
HTML
2
star
51

zora-zine-reader

POC for zora zine reader
TypeScript
1
star
52

uniswap-v2-interface

TypeScript
1
star
53

zora-creator-subgraph

TypeScript
1
star
54

frontend-exercise-one

ZORA Frontend Exercise #1
TypeScript
1
star