Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using the CreatorContract in a Next JS / Typescript project #462

Open
Booker-CU opened this issue Oct 25, 2024 · 4 comments
Open

using the CreatorContract in a Next JS / Typescript project #462

Booker-CU opened this issue Oct 25, 2024 · 4 comments

Comments

@Booker-CU
Copy link

Hello... I am having trouble implementing the creatorClient contract in NextJS w/ Typescript..

Here are my 2 function.
I am passing in an imagebuffer which is an AI generated image.
How do I use it inside the creatorClient.create1155 function?

Do I first need to do something w/ makeImageTokenMetadata, makeContractMetadata first to get the token and contract uri's? -- but then what do I do?

Also how would I call them correctly (makeImageTokenMetadata, makeContractMetadata)

thanks

import {
    useAccount,
    useWriteContract,
} from "wagmi";

import { creatorClient, publicClient } from "../config/zoraConfig";
import { makeImageTokenMetadata, makeContractMetadata } from "./zoraMetaDataUtil";

export async function createNFT(imageBuffer: string) {

    const { address } = useAccount();

    if (!publicClient || !address) {
        throw new Error("No public client or address found");
    }

    const { parameters, contractAddress} = await creatorClient.create1155({

        contract: {

            //Contract Name
            name: "My NFT Collection",

            //Contract Metadata URI
            uri: "ipfs://DUMMY/contract.json",
        },
        token: {
            tokenMetadataURI: "ipfs://TOKEN_URI",
        },
        account: address,
    });

    return { parameters, contractAddress };
}

export async function executeMint(parameters: any) {
    const { writeContract } = useWriteContract();
    const { abi } = parameters

    try {
      const txResult =  await writeContract(
        parameters.contractAddress,
        abi,
    );
      console.log(txResult)
      return txResult;
    } catch (error) {
      console.error('Error during NFT mint:', error);
      throw error;
    }
}
@iainnash
Copy link
Collaborator

We strongly recommend using an IPFS service to upload your image before posting and incorporate that url in the make contract and token metadata fields. There are a number of IPFS services that will handle standard NFT metadata and docs on the spec here: https://docs.zora.co/contracts/Metadata

Let us know if we can help clarify this information further :).

@Booker-CU
Copy link
Author

We strongly recommend using an IPFS service to upload your image before posting and incorporate that url in the make contract and token metadata fields. There are a number of IPFS services that will handle standard NFT metadata and docs on the spec here: https://docs.zora.co/contracts/Metadata

Let us know if we can help clarify this information further :).

thanks for the message... was curious, does the writeContract function return anything?

const txResult = await writeContract(
parameters.contractAddress,
abi,
);
it says its returning type VOID

Thanks

@Booker-CU
Copy link
Author

have another question... I am now using 'ipfs-http-client' to pin image to ipfs...

//Pin ImageBuffer to IPFS
const { cid } = await ipfs.add(imageBuffer);
console.log('Image pinned to IPFS with CID:', cid.toString());
what do I do with makeImageTokenMetadata & makeContractMetadata functions (zoralabs sdk)... do I need to pass them both the cid, since the image is pinned to ipfs do I need to change part of the makeImageTokenMetadata function?

thanks

@iainnash
Copy link
Collaborator

iainnash commented Oct 25, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants