Skip to content

Commit e24c3ab

Browse files
IsabellaSmallcombekulkarohan
authored andcommitted
V2 SDK Docs (#702)
* feat: wip of v2 sdk docs * fix: spelling
1 parent b57eadf commit e24c3ab

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

docs/pages/protocol-sdk/creator/onchain.mdx

+23
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,29 @@ that creates an 1155 contract at the deterministic address based on those parame
4545

4646
:::
4747

48+
### Custom parameters for secondary markets
49+
50+
If you are wanting to customize the default configuration parameters such as `saleStart` you can do that by passing in a `salesConfig` struct.
51+
52+
:::code-group
53+
54+
```ts twoslash [example.ts]
55+
// @filename: config.ts
56+
// [!include ~/snippets/protocol-sdk/create/config.ts]
57+
58+
// @filename: example.ts
59+
// ---cut---
60+
// [!include ~/snippets/protocol-sdk/create/createNew1155ContractOrTokenWithCustomParams.ts]
61+
```
62+
63+
```ts twoslash [config.ts]
64+
// [!include ~/snippets/protocol-sdk/create/config.ts]
65+
```
66+
67+
:::
68+
69+
With the update to use the v2 sales config it introduces `marketCountdown` and `minimumMarketEth` in version 0.9.5 of the sdk.
70+
4871
## Configuring the backing ERC20 Token Name and Symbol for the 1155 Secondary Market
4972

5073
When leveraging the [secondary markets](https://support.zora.co/en/articles/2519873) feature, a backing ERC20 token is created with a name and symbol for each minted 1155.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {
2+
useAccount,
3+
useChainId,
4+
usePublicClient,
5+
useWriteContract,
6+
} from "wagmi";
7+
import { createCreatorClient } from "@zoralabs/protocol-sdk";
8+
9+
// use wagmi hooks to get the chainId, publicClient, and account
10+
const chainId = useChainId();
11+
const publicClient = usePublicClient()!;
12+
const { address } = useAccount();
13+
14+
const creatorClient = createCreatorClient({ chainId, publicClient });
15+
16+
const { parameters, contractAddress } = await creatorClient.create1155({
17+
// the contract will be created at a deterministic address
18+
contract: {
19+
// contract name
20+
name: "testContract",
21+
// contract metadata uri
22+
uri: "ipfs://DUMMY/contract.json",
23+
},
24+
token: {
25+
tokenMetadataURI: "ipfs://DUMMY/token.json",
26+
salesConfig: {
27+
type: "timed",
28+
erc20Name: "testToken", // If not provided, uses the contract name
29+
erc20Symbol: "TEST", // If not provided, extracts it from the name.
30+
saleStart: 0n, // If not provided, sets to 0
31+
marketCountdown: BigInt(24 * 60 * 60), // If not provided, sets to 24 hours
32+
minimumMarketEth: 2220000000000000n, // If not provided, sets to 200 mints worth of ETH
33+
},
34+
},
35+
// account to execute the transaction (the creator)
36+
account: address!,
37+
});
38+
39+
const { writeContract } = useWriteContract();
40+
41+
writeContract(parameters);
42+
43+
export { contractAddress };

0 commit comments

Comments
 (0)