Closed maxmux-xyz closed 6 months ago
Hello!
To fix this with a local signer you need to pass in an Account
to the createForFree
function.
import {createPremintClient} from "@zoralabs/protocol-sdk";
import type {Address, PublicClient, WalletClient} from "viem";
import { createPublicClient, createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { base } from 'viem/chains'
async function createForFree({
walletClient,
publicClient,
creator,
}: {
// wallet client that will submit the transaction
walletClient: WalletClient;
// public client that will simulate the transaction
publicClient: PublicClient;
// address of the token contract
creator: Account | Address;
}) {
const premintClient = createPremintClient({chain: walletClient.chain!, publicClient: publicClient});
// create and sign a free token creation.
const createdPremint = await premintClient.createPremint({
walletClient,
// this line has been updated.
creatorAccount: creator,
checkSignature: true,
collection: {
// This line has been updated
contractAdmin: if typeof creator === 'string' ? creator : creator.address,
contractName: "Testing Contract",
contractURI: "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
},
tokenCreationConfig: {
tokenURI: "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
},
});
const premintUid = createdPremint.uid;
const premintCollectionAddress = createdPremint.verifyingContract;
return {
// unique id of created premint, which can be used later to
// update or delete the premint
uid: premintUid,
tokenContractAddress: premintCollectionAddress,
};
}
async function main() {
const cl = createPublicClient({
chain: base,
transport: http(),
})
const blockNumber = await cl.getBlockNumber()
console.log('blockNumber', blockNumber)
const account = privateKeyToAccount('<0xPK>')
account.address
const wc = createWalletClient({
account,
chain: base,
transport: http()
})
const {uid, tokenContractAddress} = await createForFree({
walletClient: wc,
publicClient: cl as PublicClient,
creatorAccount: "0x65318ba4d49C1da4B05F2632bB50e29637ed5A64",
})
console.log('uid', uid)
console.log('tokenContractAddress', tokenContractAddress)
}
main();
Hi! Trying to call
createPremint
oncreatePremintClient
, and getting the viem error below. I'm running simple ts-node env, with following dependencies:Full code here: https://github.com/maxmux-xyz/zora-sandbox See
script.ts
Quick clarification questions: I want to pre-deploy/mint nft collection on behalf of a creator that is logged on my app through Privy & has an associated AA wallet. How should I call
createPremint
so that my logged in users AA wallet is the contract admin? Which account should be on the WalletClient, and which address should be the creatorAccount in the example here: https://github.com/maxmux-xyz/zora-sandbox/blob/4ee220f72a621724943262ac9f43576260b24744/script.ts#L66-L70 I also want to collect platform fees. Is that done through re-directs for our app for every different mint request?