Hi,
Im trying to upload an image to IPFS to make a NFT minter with Next.js and Node but im getting this error following the moralis documentation when i try new Moralis.File(file.name, file).
const onSubmit = async (e) => {
e.preventDefault();
console.log("name: "+ name)
console.log('description: ' + description)
try {
console.log("===================")
//save image to IPFS
console.log(data)
const file1 = new Moralis.File(data.name, data);
console.log(file1)
await file1.saveIPFS();
console.log('=====', file1)
const file1url = file1.ipfs;
//generate metadata and save to ipfs
const metadata = {
name, description, image: file1url
}
const file2 = new Moralis.File(`${name}metadata.json`, {
base64: Buffer.from(JSON.stringify(metadata)).toString('base64')
});
await file2.saveIPFS();
const metadataurl = file2.ipfs();
//interact with smart contracts
const contract = new web3.eth.Contract(contractABI, contractAddress);
const response = await contract.methods.mint(metadataurl).send({ from: account.get('ethAddress')});
//const tokenId = response.events.Transfer.returnValues.tokenId;
alert(
'NFT successfully minted. Contract address - ${contractAddress} and Token Id - ${tokenId}'
);
} catch(err) {
console.error(err);
alert('Something went wrong');
}
}