Open mattleesounds opened 3 weeks ago
hey @mattleesounds could you provide a more full code example?
Sure, here ya go
import React, { useState } from "react"
import { Pressable, Text } from "react-native"
import { useEmbeddedWallet, isConnected } from "@privy-io/expo"
import { create1155CreatorClient } from "@zoralabs/protocol-sdk"
const CreateCollection: React.FC = () => {
const wallet = useEmbeddedWallet()
const [isCreated, setIsCreated] = useState(false)
const createCollection = async (provider: EIP1193Provider) => {
try {
const accounts = await provider.request({
method: "eth_requestAccounts",
})
const creatorClient = create1155CreatorClient({ publicClient: provider })
const { request } = await creatorClient.createNew1155Token({
contract: {
name: "test-collection-1",
uri: "https://gold-extraordinary-pigeon-404.mypinata.cloud/ipfs/QmbVrAKuxiHDVEdzhkQcC5euxYm3sLuf4M25FmavQgDpzm",
},
tokenMetadataURI:
"https://gold-extraordinary-pigeon-404.mypinata.cloud/ipfs/QmXxJHtGti9r2jLpKkRDmQqnMkmb6DHUnUZd9RuvxPnHe5",
account: accounts[0],
mintToCreatorCount: 1,
})
const { request: simulateRequest } = provider.simulateContract(request)
const hash = await provider.send({
method: "eth_sendTransaction",
params: [simulateRequest],
})
const receipt = await provider.request({
method: "eth_getTransactionReceipt",
params: [hash],
})
setIsCreated(true)
console.log("Collection created:", receipt)
} catch (error) {
setIsCreated(false)
console.error("Error creating collection:", error)
}
}
return (
<>
<Pressable
className="pt-4 "
onPress={() => isConnected(wallet) && createCollection(wallet.provider)}
>
<Text className="text-white border-2 border-white text-center text-xl font-bold">
CREATE COLLECTION
</Text>
</Pressable>
{isCreated && (
<Text className="text-green-500">Collection successfully created!</Text>
)}
</>
)
}
export default CreateCollection
hey so i tried to repro this locally, it looks like EIP1193Provider
doesn't have a method readContract
:
so it wouldn't work as an argument for publicClient for now.
we could add a better example and support for integration with privy. for now I found in their docs examples of creating a publicClient for using with other libs:
https://docs.privy.io/guide/react/recipes/account-abstraction/pimlico#_4-create-a-smart-account-for-your-user https://docs.privy.io/guide/react/recipes/account-abstraction/wagmi#_1-initialize-an-eip1193-provider-for-the-smart-account
Perhaps until we better support privy you could manually setup a PublicClient like those example?
Will attempt! Thanks for the privy resources.
@oveddan Hey i am trying to mint nft's i saw the abi : "inputs": [ { "internalType": "contract IMinter1155", "name": "minter", "type": "address" }, { "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "internalType": "uint256", "name": "quantity", "type": "uint256" }, { "internalType": "address[]", "name": "rewardsRecipients", "type": "address[]" }, { "internalType": "bytes", "name": "minterArguments", "type": "bytes" } ], here what are the minterArguments contains encodedbytes ? i saw in a sdk that it has : const mintArguments = { quantityToMint: 1, mintComment: "Summer Chain!", mintReferral: "0x8879318091671ba1274e751f8cdef76bb37eb3ed" }; but in args we already have quantitytomint so can you confirm it, while minting facing few errros thats why
@oveddan check this out: https://github.com/Nith567/mint-/blob/main/src/components/Transact.tsx when i try to mint it, says: (execution reverted with data Try again)
@oveddan FYI, this turned out to be the relevant docs for integration with privy-expo SDK https://docs.privy.io/guide/expo/embedded/3p-libraries
Hi!
We have different minter modules that take different arguments. Our SDK takes those arguments and encodes them for the fixed price minter module (our default).
It looks like the reason the last few transactions failed is that you attempted to call an NFT contract that has no NFTs/Mints registered:
Can you try with an NFT that has a token created/registered on it with a sales strategy?
@oveddan FYI, this turned out to be the relevant docs for integration with privy-expo SDK https://docs.privy.io/guide/expo/embedded/3p-libraries
great link @mattleesounds thank you! we can work on adding a section on privy integration to the docs, or look at ways to have more native integration
@iainnash yeah it did solved after i put correct parameters, tried through abi using wagmi hooks it worked out instead of sdk.
Hello, I am trying to deploy a new 1155 collection from a Privy embedded wallet and am getting this error:
Error creating collection: [TypeError: publicClient.readContract is not a function (it is undefined)]
Based on that error and looking at the SDK code, it appears that the SDK for creating collections only works with Viem providers, which is the only one with the readContract function as far as I can tell. Is this the case, and if so, is it still possible to create collections from a Privy Provider? FYI, Privy Provider follows the EIP 1193 standard.