Skip to content

Zora Protocol SDKs

The Zora Protocol SDKs are a suite of typescript libraries and utilities that simplify interacting with the Zora protocol contracts.

Protocol Deployments Package

The Protocol Deployments package provides contract abis, deployed addresses, and typescript types for the Zora Contracts. These bundled configs and abis can be used in conjunction with wagmi or viem to interact with the Zora contracts in typescript without needing to write any solidity.

import {
  protocolRewardsABI,
  zoraCreator1155FactoryImplABI,
  protocolRewardsAddress,
  zoraCreator1155FactoryImplAddress,
} from "@zoralabs/protocol-deployments";

Protocol SDK

The Protocol SDK is a typescript package that simplifies interacting with the Zora protocol by generating required transactions for our contracts.

import { zora } from "viem/chains";
import { http, createPublicClient } from "viem";
import { createCollectorClient } from "@zoralabs/protocol-sdk";
 
const tokenContract = "0x1234567890123456789012345678901234567890";
const tokenId = 1n;
const mintToAddress = "0x71907e8Ae7aeFb58ceC8eb46DAf4fc78c29E5173";
const quantityToMint = 1;
const minterAccount = "0xCb8454D64AFeB46455cB4847C53279F6cdCbFb5e";
 
const publicClient = createPublicClient({
  // this will determine which chain to interact with
  chain: zora,
  transport: http(),
});
 
const collectorClient = createCollectorClient({ 
  chainId: zora.id, publicClient });
 
// prepare a transaction to mint an 1155 token
const { parameters } = await collectorClient.mint({
  mintType: "1155",
  // 1155 contract address
  tokenContract,
  // id of the token to mint
  tokenId,
  // address that will receive the minted tokens
  mintRecipient: mintToAddress,
  // quantity of tokens to mint
  quantityToMint,
  // account to execute the mint transaction
  minterAccount,
});
 
// simulate the transaction
const { request } = await publicClient.simulateContract(parameters);

Installation

To add @zoralabs/protocol-sdk to your project, install the required packages:

pnpm
pnpm add @zoralabs/protocol-sdk viem@2.x

If using wagmi install @tanstack/react-query as well:

npm install @zoralabs/protocol-sdk viem@2.x @tanstack/react-query

Usage

The Zora Protocol SDK contains both a Creator Client and a Collector Client. The Creator Client is used to create and manage Zora creator 1155 contracts and tokens, while the Collector Client is used to mint Zora creator 1155, 721, and premints.

import { useChainId, usePublicClient } from 'wagmi';
import { 
  createCreatorClient, 
  createCollectorClient } from "@zoralabs/protocol-sdk";
 
// get the current chain id and PublicClient using wagmi
const chainId = useChainId();
const publicClient = usePublicClient();
 
const creatorClient = createCreatorClient({ chainId, publicClient });
creatorClient.
create1155
createPremint
deletePremint
updatePremint
const collectorClient = createCollectorClient({ chainId, publicClient }); collectorClient.m
mint