Skip to content

Commit

Permalink
V2 SDK Docs (#702)
Browse files Browse the repository at this point in the history
* feat: wip of v2 sdk docs

* fix: spelling
  • Loading branch information
IsabellaSmallcombe authored and kulkarohan committed Aug 29, 2024
1 parent b57eadf commit e24c3ab
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/pages/protocol-sdk/creator/onchain.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,29 @@ that creates an 1155 contract at the deterministic address based on those parame

:::

### Custom parameters for secondary markets

If you are wanting to customize the default configuration parameters such as `saleStart` you can do that by passing in a `salesConfig` struct.

:::code-group

```ts twoslash [example.ts]
// @filename: config.ts
// [!include ~/snippets/protocol-sdk/create/config.ts]

// @filename: example.ts
// ---cut---
// [!include ~/snippets/protocol-sdk/create/createNew1155ContractOrTokenWithCustomParams.ts]
```

```ts twoslash [config.ts]
// [!include ~/snippets/protocol-sdk/create/config.ts]
```

:::

With the update to use the v2 sales config it introduces `marketCountdown` and `minimumMarketEth` in version 0.9.5 of the sdk.

## Configuring the backing ERC20 Token Name and Symbol for the 1155 Secondary Market

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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {
useAccount,
useChainId,
usePublicClient,
useWriteContract,
} from "wagmi";
import { createCreatorClient } from "@zoralabs/protocol-sdk";

// use wagmi hooks to get the chainId, publicClient, and account
const chainId = useChainId();
const publicClient = usePublicClient()!;
const { address } = useAccount();

const creatorClient = createCreatorClient({ chainId, publicClient });

const { parameters, contractAddress } = await creatorClient.create1155({
// the contract will be created at a deterministic address
contract: {
// contract name
name: "testContract",
// contract metadata uri
uri: "ipfs://DUMMY/contract.json",
},
token: {
tokenMetadataURI: "ipfs://DUMMY/token.json",
salesConfig: {
type: "timed",
erc20Name: "testToken", // If not provided, uses the contract name
erc20Symbol: "TEST", // If not provided, extracts it from the name.
saleStart: 0n, // If not provided, sets to 0
marketCountdown: BigInt(24 * 60 * 60), // If not provided, sets to 24 hours
minimumMarketEth: 2220000000000000n, // If not provided, sets to 200 mints worth of ETH
},
},
// account to execute the transaction (the creator)
account: address!,
});

const { writeContract } = useWriteContract();

writeContract(parameters);

export { contractAddress };

0 comments on commit e24c3ab

Please sign in to comment.