|
| 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