Zora Protocol

The Zora module provides read/write access directly to the Zora protocol.

To instantiate the module, an ethers Signer or Provider, must be passed to the constructor. In addition, the chainID representing the Ethereum network you are trying to connect to. Zora currently supports Rinkeby (4) for testing, and Mainnet (1) for production.

Name

Type

Description

signerOrProvider

Signer | Provider

The Wallet or JSON RPC Provider connected to Ethereum

chainId

number

The network to connect to. 1 for Mainnet, and 4 for Rinkeby.

mediaAddress?

string

[Optional] The media address of a deployed zora protocol

marketAddress?

string

[Optional] The market address of a deployed zora protocol

import { Zora } from '@zoralabs/zdk'
import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()
const zora = new Zora(wallet, 1)
console.log(await zora.totalSupply())

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/sdk'
import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()
const zora = new Zora(wallet, 50, mediaAddress, marketAddress)
console.log(await zora.totalSupply())

To see a real life example of connecting to a user's wallet with Metamask or WalletConnect, see our React Guide

Read Functions

fetchContentHash

Fetch the contentHashof a piece of media

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose content hash is being fetched

fetchMetadataHash

Fetch the metadataHash of a piece of media

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose metadata is being fetched

fetchContentURI

Fetch the contentURI of a piece of media

Name

Type

Description

mediaID

BigNumberish

The ID for the media whose content URI is being fetched

fetchMetadataURI

Fetch the metadataURI of a piece of media

Name

Typ

Description

mediaID

BigNumberish

The ID for the media whose metadata URI is being fetched

fetchCreator

Fetch the creator of a piece of media.

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose creator is being fetched

fetchCurrentBidShares

Fetch the current bidShares of a piece of media.

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose current bid shares are being fetched

fetchCurrentAsk

Fetch the current Ask of a piece of media.

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose current ask is being fetched

fetchCurrentBidForBidder

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

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose metadata uri is being fetched

bidder

string

The address of the bidder

fetchPermitNonce

Fetch the next permit nonce for an address

Name

Type

Description

address

string

The address of the account whose permit nonce is being fetched

fetchMintWithSigNonces

Fetch the next mintWithSig nonce for an address

Name

Type

Description

address

string

The 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

Name

Type

Description

address

string

The 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

Name

Type

Description

mediaId

BigNumberish

The 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

Name

Type

Description

owner

string

The owner address of the media

index

BigNumberish

The ERC-721 enumerbale index of owner

fetchTotalMedia

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

Name

Type

Description

fetchMediaByIndex

Fetch the mediaId by index

Name

Type

Description

index

BigNumberish

The ERC-721 enumerbale index of a piece of media

fetchApproved

Fetch the approved account for the specified media

Name

Type

Description

mediaId

BigNumberish

The 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

Name

Type

Description

owner

string

An address on the Zora Protocol

operator

string

An address on the Zora Protocol

Write Functions

mint

Mint a new piece of cryptomedia.

Name

Type

Description

mediaData

MediaData

The data represented by this media, including SHA256 hashes for future integrity checks

bidShares

BidShares

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

Name

Type

Description

creator

BigNumberish

The creator address of the piece of media

mediaData

MediaData

The data represented by this media, including SHA256 hashes for future integrity checks

bidShares

BidShares

The percentage of bid fees that should be perpetually rewarded to the creator.

sig

EIP712Signature

The eip-712 compliant signature to be verified on chain

updateContentURI

Update the contentURI of a piece of media.

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose content uri is being updated

updateMetadataURI

Update the metadataURI of a piece of media.

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose metadata uri is being updated

setAsk

Set an Ask on a piece of media.

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose ask is being set

ask

Ask

The ask to be set

removeAsk

Remove the Ask from a piece of media.

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose ask is being removed

setBid

Set a Bid on a piece of media.

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose bid is being set

bid

Bid

The bid to be set

removeBid

Remove the Bid from a piece of media.

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose bid is being removed

acceptBid

Accept a Bid on a piece of media.

Name

Type

Description

mediaId

BigNumberish

The ID for the media whose bid is being accepted

bid

Bid

The bid to be accepted

permit

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

Name

Type

Description

spender

string

The address that is being permitted to spend the media

media Id

BigNumberish

The ID for the media

sig

EIP712Signature

The eip-712 compliant signature to be verified on chain

burn

Burn a piece of media

Name

Type

Description

mediaId

BigNumberish

The ID for the media to burn

revokeApproval

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

Name

Type

Description

mediaId

BigNumberish

The 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

Name

Type

Description

to

string

The address being granted approval for the media

mediaId

BigNumberish

The ID for the media

setApprovalForAll

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

Name

Type

Description

operator

string

The address of the account the approvalForAll is being set

approved

boolean

Whether 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

Name

Type

Description

from

string

The from address of the media transfer

to

string

The to address of the media transfer

mediaId

BigNumberish

The 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

Name

Type

Description

from

string

The from address of the media transfer

to

string

The to address of the media transfer

mediaId

BigNumberish

The ID for the media being transferred