0

I'm trying to do an example in a tutorial, I tried to run this, but I get an error that "Upload errorTypeError: str is undefined". How can I solve this?

I tried: -> deleting artifacts and then deploying with hardhat again but nothing happened and I got the same error. -> I tried to upload small pictures but nothing happened again.

Now I want to ask how can I add liquidity and a treasury process? Do you have any documents or videos about that?

enter image description here

Here is the project link: https://github.com/kayhannkaya/Nft-Mint-Tutorial/tree/main

SellNFT.js code:

     var file = e.target.files[0];
    //check for file extension
    try {
        //upload the file to IPFS
        disableButton();
        updateMessage("Uploading image.. please dont click anything!")
        const response = await uploadFileToIPFS(file);
        if(response.success === true) {
            enableButton();
            updateMessage("")
            console.log("Uploaded image to Pinata: ", response.pinataURL)
            setFileURL(response.pinataURL);
        }
    }
    catch(e) {
        console.log("Error during file upload", e);
    }
}

//This function uploads the metadata to IPFS
async function uploadMetadataToIPFS() {
    const {name, description, price} = formParams;
    //Make sure that none of the fields are empty
    if( !name || !description || !price || !fileURL)
    {
        updateMessage("Please fill all the fields!")
        return -1;
    }

    const nftJSON = {
        name, description, price, image: fileURL
    }

    try {
        //upload the metadata JSON to IPFS
        const response = await uploadJSONToIPFS(nftJSON);
        if(response.success === true){
            console.log("Uploaded JSON to Pinata: ", response)
            return response.pinataURL;
        }
    }
    catch(e) {
        console.log("error uploading JSON metadata:", e)
    }
}

    data.append('pinataOptions', pinataOptions);

return axios 
    .post(url, data, {
        maxBodyLength: 'Infinity',
        headers: {
            'Content-Type': `multipart/form-data; boundary=${data._boundary}`,
            'Authorization': `Bearer ${JWT}`,
            'pinata_api_key': key,
            'pinata_secret_api_key': secret,
        }
    })
    .then(function (response) {
        console.log("image uploaded", response.data.IpfsHash)
        return {
           success: true,
           pinataURL: "https://blush-defeated-roundworm-642.mypinata.cloud/ipfs/" + response.data.IpfsHash
       };
    })
    .catch(function (error) {
        console.log(error)
        return {
            success: false,
            message: error.message,
        }

});

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.