Skip to main content

ZORA NFTs

Provides read and write access to the ZORA NFT contracts


NFTs minted out of ZORA are known as ZORA NFTs (zNFT) and are also reffered to as media. More details about the ZORA smart contracts can be found here.

To instantiate the module, an ethers.js Signer or Provider, must be passed to the constructor as well as the chainID. ZORA currently supports Ethereum Mainnet (1) and Rinkeby Testnet (4).

You can learn more about connecting to ethers.js here.

Constructor Arguments#

NameTypeDescription
signerOrProviderSigner | ProviderThe Wallet or JSON RPC Provider connected to Ethereum
chainIdnumberThe network to connect to. 1 for Mainnet, and 4 for Rinkeby.
mediaAddress?string[Optional] The Media contract address
marketAddress?string[Optional] The Market contract address

import { Zora } from '@zoralabs/zdk'import { Wallet } from 'ethers'
// If you don't specify a //url//, Ethers connects to the default// (i.e. ``http:/\/localhost:8545``)const provider = new ethers.providers.JsonRpcProvider()
let wallet = Wallet.createRandom()wallet = wallet.connect(provider)
const zora = new Zora(wallet, 1) //passing in 1 for Ethereum Mainnetconst totalSupply = await zora.fetchTotalMedia()

If you are using a local blockchain, you must specify overrides for both mediaAddress and marketAddress. These should point to the addresses of the deployed ZORA media and market contracts on your local environment.

const zora = new Zora(wallet, 50, mediaAddress, marketAddress)
note

For more details on connecting to a user's wallet with Metamask or WalletConnect, see our React Guide

Read Functions#


All the functions that are able to read data from the ZORA NFT smart contracts. We recommend using the using the NFT Rendering and Zora Indexer sections if you only want to get NFT data.

fetchContentHash#

Fetch the contentHash of a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose content hash is being fetched

fetchMetadataHash#

Fetch the metadataHash of a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose metadata hash is being fetched

fetchContentURI#

Fetch the contentURI of a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose content uri is being fetched

fetchMetadataURI#

Fetch the metadataURI of a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose metadata uri is being fetched

fetchCreator#

Fetch the creator of a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose creator is being fetched

fetchCurrentBidShares#

Fetch the current bidShares of a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose current bid shares are being fetched

fetchCurrentAsk#

Fetch the current Ask of a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose current ask is being fetched

fetchCurrentBidForBidder#

Fetch the current Bid for a bidder on a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose metadata uri is being fetched
bidderstringThe address of the bidder

fetchPermitNonce#

Fetch the next permit nonce for an address

NameTypeDescription
addressstringThe address of the account whose permit nonce is being fetched

fetchMintWithSigNonces#

Fetch the next mintWithSig nonce for an address

NameTypeDescription
addressstringThe address of the account whose mintWithSig nonce is being fetched

fetchBalanceOf#

Fetch the balance of an address on an instance of the ZORA Media Contract

NameTypeDescription
addressstringThe address of the account whose balance is being fetched

fetchOwnerOf#

Fetch the owner of a ZORA NFT on an instance of the ZORA Media Contract

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose owner is being fetched

fetchMediaOfOwnerByIndex#

Fetch the mediaId of the specified owner by index on an instance of the ZORA Media Contract

NameTypeDescription
ownerstringThe owner address of the ZORA NFT
indexBigNumberishThe ERC-721 enumerbale index of owner

fetchTotalMedia#

Fetch the total amount of non-burned ZORA NFTs that has been minted

NameTypeDescription

fetchMediaByIndex#

Fetch the mediaId by index

NameTypeDescription
indexBigNumberishThe ERC-721 enumerbale index of a ZORA NFT

fetchApproved#

Fetch the approved account for the specified ZORA NFT

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose approved address is being fetched

fetchIsApprovedForAll#

Fetch if the specified operator is approved for all ZORA NFTs owned by the specified owner

NameTypeDescription
ownerstringAn address on the ZORA Protocol
operatorstringAn address on the ZORA Protocol

Write Functions#


All the functions that are able to submit transactions to interact with the ZORA NFT smart contracts

mint#

Mint a new ZORA NFT.

NameTypeDescription
mediaDataMediaDataThe data represented by this ZORA NFT, including SHA256 hashes for future integrity checks
bidSharesBidSharesThe percentage of bid fees that should be perpetually rewarded to the creator.

mintWithSig#

Mint a new piece of media on behalf of signed message from a creator.

NameTypeDescription
creatorBigNumberishThe creator address of the ZORA NFT
mediaDataMediaDataThe data represented by this media, including `SHA256 hashes for future integrity checks
bidSharesBidSharesThe percentage of bid fees that should be perpetually rewarded to the creator.
sigEIP712SignatureThe eip-712 compliant signature to be verified on chain

updateContentURI#

Update the contentURI of a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose content uri is being updated

updateMetadataURI#

Update the metadataURI of a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose metadata uri is being updated

setAsk#

Set an Ask on a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose ask is being set
askAskThe ask to be set

removeAsk#

Remove the Ask from a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose ask is being removed

setBid#

Set a Bid on a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose bid is being set
bidBidThe bid to be set

removeBid#

Remove the Bid from a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose bid is being removed

acceptBid#

Accept a Bid on a ZORA NFT.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT whose bid is being accepted
bidBidThe bid to be accepted

permit#

Permit an address to act on behalf of the owner of the ZORA NFT

NameTypeDescription
spenderstringThe address that is being permitted to spend the ZORA NFT
media IdBigNumberishThe ID for the ZORA NFT
sigEIP712SignatureThe eip-712 compliant signature to be verified on chain

burn#

Burn a ZORA NFT

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT to burn

revokeApproval#

As an approved address on a ZORA NFT, revoke your approval.

NameTypeDescription
mediaIdBigNumberishThe ID for the ZORA NFT to burn

approve#

Grant approval to the specified address for the specified ZORA NFT on an instance of the ZORA Media Contract

NameTypeDescription
tostringThe address being granted approval for the ZORA NFT
mediaIdBigNumberishThe ID for the ZORA NFT

setApprovalForAll#

Grant approval for all ZORA NFT owner by msg.sender on an instance of the ZORA Media Contract

NameTypeDescription
operatorstringThe address of the account the approvalForAll is being set
approvedbooleanWhether or not the operator address is being granted approval

transferFrom#

Transfers the specified ZORA NFT to the specified to address on an instance of the ZORA Media Contract

NameTypeDescription
fromstringThe from address of the ZORA NFT transfer
tostringThe to address of the ZORA NFT transfer
mediaIdBigNumberishThe ID for the ZORA NFT being transferred

safeTransferFrom#

Transfers specified ZORA NFT to the specified address if and only if it adheres to the ERC721-Receiver Interface

NameTypeDescription
fromstringThe from address of the ZORA NFT transfer
tostringThe to address of the ZORA NFT transfer
mediaIdBigNumberishThe ID for the ZORA NFT being transferred