@zoralabs/protocol-sdk 0.5.2 → 0.5.3-mints.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,9 +8,9 @@ $ tsup
8
8
  CLI Cleaning output folder
9
9
  CJS Build start
10
10
  ESM Build start
11
- ESM dist/index.js 46.16 KB
12
- ESM dist/index.js.map 96.98 KB
13
- ESM ⚡️ Build success in 54ms
14
11
  CJS dist/index.cjs 49.78 KB
15
12
  CJS dist/index.cjs.map 96.89 KB
16
- CJS ⚡️ Build success in 55ms
13
+ CJS ⚡️ Build success in 65ms
14
+ ESM dist/index.js 46.16 KB
15
+ ESM dist/index.js.map 96.98 KB
16
+ ESM ⚡️ Build success in 66ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @zoralabs/protocol-sdk
2
2
 
3
+ ## 0.5.3-mints.0
4
+
5
+ ### Patch Changes
6
+
7
+ - @zoralabs/1155-deployments@0.0.14-mints.0
8
+
3
9
  ## 0.5.2
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Zora Protocol SDK
2
2
 
3
- Protocol SDK allows users to create tokens using the Zora Protocol, and mint them.
3
+ Protocol SDK allows developers to create tokens using the Zora Protocol and mint them.
4
4
 
5
5
  ## Installing
6
6
 
@@ -9,13 +9,13 @@ Protocol SDK allows users to create tokens using the Zora Protocol, and mint the
9
9
  - `npm install viem`
10
10
  - `npm install `
11
11
 
12
- ### Creating a mint from an on-chain contract:
12
+ ### Creating a mint from an on-chain contract
13
13
 
14
14
  #### Using viem
15
-
15
+
16
16
  ```ts
17
- import {createMintClient} from "@zoralabs/protocol-sdk";
18
- import type {Address, PublicClient, WalletClient} from "viem";
17
+ import { createMintClient } from "@zoralabs/protocol-sdk";
18
+ import type { Address, PublicClient, WalletClient } from "viem";
19
19
 
20
20
  async function mintNFT({
21
21
  walletClient,
@@ -41,7 +41,7 @@ async function mintNFT({
41
41
  // optional address that will receive a mint referral reward
42
42
  mintReferral?: Address;
43
43
  }) {
44
- const mintClient = createMintClient({chain: walletClient.chain!});
44
+ const mintClient = createMintClient({ chain: walletClient.chain! });
45
45
 
46
46
  // prepare the mint transaction, which can be simulated via an rpc with the public client.
47
47
  const prepared = await mintClient.makePrepareMintTokenParams({
@@ -69,30 +69,47 @@ async function mintNFT({
69
69
  const txHash = await walletClient.writeContract(request);
70
70
 
71
71
  // wait for the transaction to be complete
72
- await publicClient.waitForTransactionReceipt({hash: txHash});
72
+ await publicClient.waitForTransactionReceipt({ hash: txHash });
73
73
  }
74
74
  ```
75
75
 
76
76
  #### Using wagmi
77
77
 
78
78
  ```tsx
79
- import {createMintClient} from "@zoralabs/protocol-sdk";
80
- import {useEffect, useMemo, useState} from "react";
81
- import {BaseError, SimulateContractParameters, stringify} from "viem";
82
- import {Address, useAccount, useContractWrite, useNetwork, usePrepareContractWrite, usePublicClient, useWaitForTransaction} from "wagmi";
79
+ import { createMintClient } from "@zoralabs/protocol-sdk";
80
+ import { useEffect, useMemo, useState } from "react";
81
+ import { BaseError, SimulateContractParameters, stringify } from "viem";
82
+ import {
83
+ Address,
84
+ useAccount,
85
+ useContractWrite,
86
+ useNetwork,
87
+ usePrepareContractWrite,
88
+ usePublicClient,
89
+ useWaitForTransaction,
90
+ } from "wagmi";
83
91
 
84
92
  // custom hook that gets the mintClient for the current chain
85
93
  const useMintClient = () => {
86
94
  const publicClient = usePublicClient();
87
95
 
88
- const {chain} = useNetwork();
96
+ const { chain } = useNetwork();
89
97
 
90
- const mintClient = useMemo(() => chain && createMintClient({chain, publicClient}), [chain, publicClient]);
98
+ const mintClient = useMemo(
99
+ () => chain && createMintClient({ chain, publicClient }),
100
+ [chain, publicClient],
101
+ );
91
102
 
92
103
  return mintClient;
93
104
  };
94
105
 
95
- export const Mint = ({tokenId, tokenContract}: {tokenId: string; tokenContract: Address}) => {
106
+ export const Mint = ({
107
+ tokenId,
108
+ tokenContract,
109
+ }: {
110
+ tokenId: string;
111
+ tokenContract: Address;
112
+ }) => {
96
113
  // call custom hook to get the mintClient
97
114
  const mintClient = useMintClient();
98
115
 
@@ -102,7 +119,7 @@ export const Mint = ({tokenId, tokenContract}: {tokenId: string; tokenContract:
102
119
  // params for the prepare contract write hook
103
120
  const [params, setParams] = useState<SimulateContractParameters>();
104
121
 
105
- const {address} = useAccount();
122
+ const { address } = useAccount();
106
123
 
107
124
  useEffect(() => {
108
125
  if (!mintClient || !address) return;
@@ -124,10 +141,14 @@ export const Mint = ({tokenId, tokenContract}: {tokenId: string; tokenContract:
124
141
  makeParams();
125
142
  }, [mintClient, address, quantityToMint]);
126
143
 
127
- const {config} = usePrepareContractWrite(params);
144
+ const { config } = usePrepareContractWrite(params);
128
145
 
129
- const {write, data, error, isLoading, isError} = useContractWrite(config);
130
- const {data: receipt, isLoading: isPending, isSuccess} = useWaitForTransaction({hash: data?.hash});
146
+ const { write, data, error, isLoading, isError } = useContractWrite(config);
147
+ const {
148
+ data: receipt,
149
+ isLoading: isPending,
150
+ isSuccess,
151
+ } = useWaitForTransaction({ hash: data?.hash });
131
152
 
132
153
  return (
133
154
  <>
@@ -139,7 +160,10 @@ export const Mint = ({tokenId, tokenContract}: {tokenId: string; tokenContract:
139
160
  }}
140
161
  >
141
162
  {/* input for quantity to mint: */}
142
- <input placeholder="quantity to mint" onChange={(e) => setQuantityToMint(Number(e.target.value))} />
163
+ <input
164
+ placeholder="quantity to mint"
165
+ onChange={(e) => setQuantityToMint(Number(e.target.value))}
166
+ />
143
167
  <button disabled={!write} type="submit">
144
168
  Mint
145
169
  </button>
@@ -161,7 +185,7 @@ export const Mint = ({tokenId, tokenContract}: {tokenId: string; tokenContract:
161
185
  };
162
186
  ```
163
187
 
164
- ### Creating an 1155 contract:
188
+ ### Creating an 1155 contract
165
189
 
166
190
  If an object with {name, uri} is passed in to this helper, it uses the creatorAccount and those values to either 1) create or 2) mint to that existing contract.
167
191
 
@@ -195,11 +219,11 @@ export async function createContract({
195
219
  }
196
220
  ```
197
221
 
198
- ### Creating a token for free (gasless creation):
222
+ ### Premint: create a mint without paying gas
199
223
 
200
224
  ```ts
201
- import {createPremintClient} from "@zoralabs/protocol-sdk";
202
- import type {Address, PublicClient, WalletClient} from "viem";
225
+ import { createPremintClient } from "@zoralabs/protocol-sdk";
226
+ import type { Address, PublicClient, WalletClient } from "viem";
203
227
 
204
228
  async function createForFree({
205
229
  walletClient,
@@ -213,7 +237,10 @@ async function createForFree({
213
237
  // address of the token contract
214
238
  creatorAccount: Address;
215
239
  }) {
216
- const premintClient = createPremintClient({chain: walletClient.chain!, publicClient});
240
+ const premintClient = createPremintClient({
241
+ chain: walletClient.chain!,
242
+ publicClient,
243
+ });
217
244
 
218
245
  // create and sign a free token creation.
219
246
  const createdPremint = await premintClient.createPremint({
@@ -225,11 +252,13 @@ async function createForFree({
225
252
  collection: {
226
253
  contractAdmin: creatorAccount,
227
254
  contractName: "Testing Contract",
228
- contractURI: "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
255
+ contractURI:
256
+ "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
229
257
  },
230
258
  // token info of token to create
231
259
  tokenCreationConfig: {
232
- tokenURI: "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
260
+ tokenURI:
261
+ "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
233
262
  },
234
263
  });
235
264
 
@@ -243,19 +272,21 @@ async function createForFree({
243
272
  tokenContractAddress: premintCollectionAddress,
244
273
  };
245
274
  }
246
-
247
275
  ```
248
276
 
249
- ### Updating a token that was created for free (before it was brought onchain):
277
+ ### Updating a premint before it is brought onchain
250
278
 
251
- Before a token that was created for free is brought onchain, it can be updated by the original creator of that token, by having that creator sign a message indicating the update. This is useful for updating the tokenURI, other metadata, or token sale configuration (price, duration, limits, etc.):
279
+ Before a premint is brought onchain, it can be updated by the original creator of that token, by having that creator sign a message indicating the update. This is useful for updating the tokenURI, other metadata, or token sale configuration (price, duration, limits, etc.):
252
280
 
253
281
  ```ts
254
- import {createPremintClient} from "@zoralabs/protocol-sdk";
255
- import type {Address, PublicClient, WalletClient} from "viem";
282
+ import { createPremintClient } from "@zoralabs/protocol-sdk";
283
+ import type { Address, PublicClient, WalletClient } from "viem";
256
284
 
257
- async function updateCreatedForFreeToken(walletClient: WalletClient, premintUid: number) {
258
- const premintClient = createPremintClient({chain: walletClient.chain!});
285
+ async function updateCreatedForFreeToken(
286
+ walletClient: WalletClient,
287
+ premintUid: number,
288
+ ) {
289
+ const premintClient = createPremintClient({ chain: walletClient.chain! });
259
290
 
260
291
  // sign a message to update the created for free token, and store the update
261
292
  await premintClient.updatePremint({
@@ -265,19 +296,20 @@ async function updateCreatedForFreeToken(walletClient: WalletClient, premintUid:
265
296
  walletClient,
266
297
  // Token information, falls back to defaults set in DefaultMintArguments.
267
298
  tokenConfigUpdates: {
268
- tokenURI: "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
299
+ tokenURI:
300
+ "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
269
301
  },
270
302
  });
271
303
  }
272
304
  ```
273
305
 
274
- ### Deleting a token that was created for free (before it was brought onchain):
306
+ ### Deleting a premint before it is brought onchain
275
307
 
276
- Before a token that was created for free is brought onchain, it can be deleted by the original creator of that token, by having that creator sign a message indicating the deletion:
308
+ Before a premint is brought onchain, it can be deleted by the original creator of that token, by having that creator sign a message indicating the deletion:
277
309
 
278
310
  ```ts
279
311
  async function deleteCreatedForFreeToken(walletClient: WalletClient) {
280
- const premintClient = createPremintClient({chain: walletClient.chain!});
312
+ const premintClient = createPremintClient({ chain: walletClient.chain! });
281
313
 
282
314
  // sign a message to delete the premint, and store the deletion
283
315
  await premintClient.deletePremint({
@@ -290,14 +322,18 @@ async function deleteCreatedForFreeToken(walletClient: WalletClient) {
290
322
  }
291
323
  ```
292
324
 
293
- ### Minting a token that was created for free (and bringing it onchain):
325
+ ### Minting a premint and bringing it onchain
294
326
 
295
327
  ```ts
296
- import {createPremintClient} from "@zoralabs/protocol-sdk";
297
- import type {Address, PublicClient, WalletClient} from "viem";
328
+ import { createPremintClient } from "@zoralabs/protocol-sdk";
329
+ import type { Address, PublicClient, WalletClient } from "viem";
298
330
 
299
- async function mintCreatedForFreeToken(walletClient: WalletClient, publicClient: PublicClient, minterAccount: Address) {
300
- const premintClient = createPremintClient({chain: walletClient.chain!});
331
+ async function mintCreatedForFreeToken(
332
+ walletClient: WalletClient,
333
+ publicClient: PublicClient,
334
+ minterAccount: Address,
335
+ ) {
336
+ const premintClient = createPremintClient({ chain: walletClient.chain! });
301
337
 
302
338
  const simulateContractParameters = await premintClient.makeMintParameters({
303
339
  minterAccount,
@@ -310,15 +346,19 @@ async function mintCreatedForFreeToken(walletClient: WalletClient, publicClient:
310
346
  });
311
347
 
312
348
  // simulate the transaction and get any validation errors
313
- const {request} = await publicClient.simulateContract(simulateContractParameters);
349
+ const { request } = await publicClient.simulateContract(
350
+ simulateContractParameters,
351
+ );
314
352
 
315
353
  // submit the transaction to the network
316
354
  const txHash = await walletClient.writeContract(request);
317
355
 
318
356
  // wait for the transaction to be complete
319
- const receipt = await publicClient.waitForTransactionReceipt({hash: txHash});
357
+ const receipt = await publicClient.waitForTransactionReceipt({
358
+ hash: txHash,
359
+ });
320
360
 
321
- const {urls} = await premintClient.getDataFromPremintReceipt(receipt);
361
+ const { urls } = await premintClient.getDataFromPremintReceipt(receipt);
322
362
 
323
363
  // block explorer url:
324
364
  console.log(urls.explorer);
@@ -327,4 +367,4 @@ async function mintCreatedForFreeToken(walletClient: WalletClient, publicClient:
327
367
  // manage url:
328
368
  console.log(urls.zoraManage);
329
369
  }
330
- ```
370
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoralabs/protocol-sdk",
3
- "version": "0.5.2",
3
+ "version": "0.5.3-mints.0",
4
4
  "repository": "https://github.com/ourzora/zora-protocol",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -16,7 +16,7 @@
16
16
  "lint": "prettier --check 'src/**/*.ts' 'test-integration/**/*.ts'"
17
17
  },
18
18
  "dependencies": {
19
- "@zoralabs/1155-deployments": "*",
19
+ "@zoralabs/1155-deployments": "0.0.14-mints.0",
20
20
  "abitype": "^0.10.3",
21
21
  "vite": "4.5.0"
22
22
  },