-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: wip of v2 sdk docs * fix: spelling
- Loading branch information
1 parent
b57eadf
commit e24c3ab
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
docs/snippets/protocol-sdk/create/createNew1155ContractOrTokenWithCustomParams.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |