zora orb logo

Zora

The Zora class gives a developer direct read / write access to a specified instance of the Zora Protocol.

Constructor

constructor(
    signerOrProvider: Signer | Provider,
    chainId: number,
    mediaAddress?: string,
    marketAddress?: string
  )

The constructor requires two arguments:

  • signerOrProvider
  • chainID

The constructor will use the signerOrProvider to determine if the Zora Instance is readOnly or readAndWrite capable. If a signer is passed in then the Zora instance will be able to invoke both read and write functions. If only a provider is passed in then the Zora instance can only invoke readOnly methods.

The constructor will use the chainID to look up the officially supported Zora Protocol addresses and return a Zora instance connected the protocol

If the chainId does not exist in chainIdToNetworkName the constructor will raise.

The constructor can optionally accept two parameters to override the official supported Zora Protocol addresses. These overrides are particularly useful for development on a local blockchain. The overrides must adhere to a logical XAND to be valid. Either both overrides must be present or both must be null.

Examples

Mainnet

import { Zora } from '@zoralabs/zdk'
import { Wallet } from 'ethers'

const wallet = Wallet.createRandom()
const zora = new Zora(wallet, 1)
await zora.totalSupply()

Rinkeby

import { Zora } from '@zoralabs/zdk'
import { Wallet } from 'ethers'

const wallet = Wallet.createRandom()
const zora = new Zora(wallet, 4)
await zora.totalSupply()

Local Blockchain

When using a local blockchain you must specify overrides for both mediaAddress and marketAddress. These should point to the addresses of deployed Zora Media and Market contracts on your local blockchain.

import { Zora } from '@zoralabs/zdk'
import { Wallet } from 'ethers'

const wallet = Wallet.createRandom()
const zora = new Zora(wallet, 50, mediaAddress, marketAddress)
await zora.totalSupply()

Read Functions

fetchContentHash

Fetch the contentHash of a piece of media.

NameTypeDescription
mediaIdBigNumberishThe ID for the media whose content hash is being fetched

fetchMetadataHash

Fetch the metadataHash of a piece of media.

NameTypeDescription
mediaIdBigNumberishThe ID for the media whose metadata hash is being fetched

fetchContentURI

Fetch the contentURI of a piece of media.

NameTypeDescription
mediaIdBigNumberishThe ID for the media whose content uri is being fetched

fetchMetadataURI

Fetch the metadataURI of a piece of media.

NameTypeDescription
mediaIdBigNumberishThe ID for the media whose metadata uri is being fetched

fetchCreator

Fetch the creator of a piece of media.

NameTypeDescription
mediaIdBigNumberishThe ID for the media whose creator is being fetched

fetchCurrentBidShares

Fetch the current bidShares of a piece of media.

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

fetchCurrentAsk

Fetch the current Ask of a piece of media.

NameTypeDescription
mediaIdBigNumberishThe ID for the media whose current ask is being fetched

fetchCurrentBidForBidder

Fetch the current Bid for a bidder on a piece of media.

NameTypeDescription
mediaIdBigNumberishThe ID for the media 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 piece of media on an instance of the Zora Media Contract

NameTypeDescription
mediaIdBigNumberishThe ID for the media 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 media
indexBigNumberishThe ERC-721 enumerbale index of owner

fetchTotalMedia

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

NameTypeDescription

fetchMediaByIndex

Fetch the mediaId by index

NameTypeDescription
indexBigNumberishThe ERC-721 enumerbale index of a piece of media

fetchApproved

Fetch the approved account for the specified media

NameTypeDescription
mediaIdBigNumberishThe ID for the media whose approved address is being fetched

fetchIsApprovedForAll

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

NameTypeDescription
ownerstringAn address on the Zora Protocol
operatorstringAn address on the Zora Protocol

Write Functions

mint

Mint a new piece of cryptomedia.

NameTypeDescription
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.

mintWithSig

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

NameTypeDescription
creatorBigNumberishThe creator address of the piece of media
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 piece of media.

NameTypeDescription
mediaIdBigNumberishThe ID for the media whose content uri is being updated

updateMetadataURI

Update the metadataURI of a piece of media.

NameTypeDescription
mediaIdBigNumberishThe ID for the media whose metadata uri is being updated

setAsk

Set an Ask on a piece of media.

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

removeAsk

Remove the Ask from a piece of media.

NameTypeDescription
mediaIdBigNumberishThe ID for the media whose ask is being removed

setBid

Set a Bid on a piece of media.

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

removeBid

Remove the Bid from a piece of media.

NameTypeDescription
mediaIdBigNumberishThe ID for the media whose bid is being removed

acceptBid

Accept a Bid on a piece of media.

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

permit

Permit an address to act on behalf of the owner of the media

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

burn

Burn a piece of media

NameTypeDescription
mediaIdBigNumberishThe ID for the media to burn

revokeApproval

As an approved address on a piece of media, revoke your approval.

NameTypeDescription
mediaIdBigNumberishThe ID for the media to burn

approve

Grant approval to the specified address for the specified media on an instance of the Zora Media Contract

NameTypeDescription
tostringThe address being granted approval for the media
mediaIdBigNumberishThe ID for the media

setApprovalForAll

Grant approval for all media 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 media to the specified to address on an instance of the Zora Media Contract

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

safeTransferFrom

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

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

isValidBid

Checks to see if a Bid's amount is evenly splittable given the media's current bidShares

NameTypeDescription
mediaIdBigNumberishThe ID for the media
bidBidThe Bid to check for validity

isValidAsk

Checks to see if an Ask's amount is evenly splittable given the media's current bidShares

NameTypeDescription
mediaIdBigNumberishThe ID for the media
askAskThe Ask to check for validity

isVerifiedMedia

Checks to see if a piece of media has verified uris that hash to their immutable hashes

NameTypeDescription
mediaIdBigNumberishThe ID for the media being checked for verification
timeoutnumberThe timeout (ms) for fetching content from the media's uris