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 });
Type '{ account: undefined; batch?: { multicall?: boolean | { batchSize?: number | undefined; wait?: number | undefined; } | undefined; } | undefined; cacheTime: number; ccipRead?: false | { request?: ((parameters: CcipRequestParameters) => Promise<...>) | undefined; } | undefined; ... 58 more ...; extend: <const client e...' is not assignable to type 'PublicClient'. The types returned by 'getBlock(...)' are incompatible between these types. Type 'Promise<{ number: bigint | null; hash: `0x${string}` | null; nonce: `0x${string}` | null; logsBloom: `0x${string}` | null; baseFeePerGas: bigint | null; blobGasUsed: bigint; difficulty: bigint; excessBlobGas: bigint; ... 18 more ...; transactions: `0x${string}`[] | ({ ...; } | ... 4 more ... | { ...; })[]; }>' is not assignable to type 'Promise<{ number: bigint | null; hash: `0x${string}` | null; nonce: `0x${string}` | null; logsBloom: `0x${string}` | null; baseFeePerGas: bigint | null; blobGasUsed: bigint; difficulty: bigint; excessBlobGas: bigint; ... 18 more ...; transactions: `0x${string}`[] | ({ ...; } | ... 3 more ... | { ...; })[]; }>'. Type '{ number: bigint | null; hash: `0x${string}` | null; nonce: `0x${string}` | null; logsBloom: `0x${string}` | null; baseFeePerGas: bigint | null; blobGasUsed: bigint; difficulty: bigint; excessBlobGas: bigint; ... 18 more ...; transactions: `0x${string}`[] | ({ ...; } | ... 4 more ... | { ...; })[]; }' is not assignable to type '{ number: bigint | null; hash: `0x${string}` | null; nonce: `0x${string}` | null; logsBloom: `0x${string}` | null; baseFeePerGas: bigint | null; blobGasUsed: bigint; difficulty: bigint; excessBlobGas: bigint; ... 18 more ...; transactions: `0x${string}`[] | ({ ...; } | ... 3 more ... | { ...; })[]; }'. Types of property 'transactions' are incompatible. Type '`0x${string}`[] | ({ yParity: number; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; typeHex: `0x${string}` | null; v: bigint; ... 11 more ...; transactionIndex: number | null; } | ... 4 more ... | { ...; })[]' is not assignable to type '`0x${string}`[] | ({ yParity?: undefined; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; typeHex: `0x${string}` | null; v: bigint; ... 12 more ...; transactionIndex: number | null; } | { ...; } | { ...; } | { ....'. Type '({ yParity: number; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; typeHex: `0x${string}` | null; v: bigint; value: bigint; ... 10 more ...; transactionIndex: number | null; } | ... 4 more ... | { ...; })[]' is not assignable to type '`0x${string}`[] | ({ yParity?: undefined; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; typeHex: `0x${string}` | null; v: bigint; ... 12 more ...; transactionIndex: number | null; } | { ...; } | { ...; } | { ....'. Type '({ yParity: number; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; typeHex: `0x${string}` | null; v: bigint; value: bigint; ... 10 more ...; transactionIndex: number | null; } | ... 4 more ... | { ...; })[]' is not assignable to type '`0x${string}`[]'. Type '{ yParity: number; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; typeHex: `0x${string}` | null; v: bigint; value: bigint; ... 10 more ...; transactionIndex: number | null; } | ... 4 more ... | { ...; }' is not assignable to type '`0x${string}`'. Type '{ yParity: number; from: `0x${string}`; gas: bigint; hash: `0x${string}`; input: `0x${string}`; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; typeHex: `0x${string}` | null; v: bigint; value: bigint; type: "deposit"; ... 9 more ...; transactionIndex: number | null; }' is not assignable to type '`0x${string}`'.
// 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
create1155OnExistingContract
createPremint
deletePremint
getRewardsBalances
updatePremint
withdrawRewards
const collectorClient = createCollectorClient({ chainId, publicClient }); collectorClient.m
mint