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

Error: cannot estimate gas; transaction may fail or may require manual gas limit #20

Open
naive2022 opened this issue Feb 3, 2022 · 4 comments

Comments

@naive2022
Copy link

naive2022 commented Feb 3, 2022

a- project that i target and setting:

1- i use the (SVGNFT.sol and 01_Deploy_SVGNFT.js) version, from YouTube video (as i do not need the random).
2- i use the (hardhat.config.js) for same version from YouTube video, at the end i add the hardhat.config.js and helper-hardhat-config.js code (same version of YouTube).

b- the main problem:

the code is work and every thing is good as the svg file size less than 27Kb. but when the svg file more than 27kb it deploy the contract but can not deploy (upload, deal, mint) the svg file (tokenuri) and return next error message:

An unexpected error occurred:

Error: ERROR processing /home/naive/demos/secondtry/deploy/01_Deploy_SVGNFT.js:
Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"name":"ProviderError","code":-
32000,"_isProviderError":true}, method="estimateGas", transaction={"from":"metamask wallet address","to":"contract address",

c- what i try until now and the results:

1- try set the gas limit in "hardhat.config" but did not make any effect.
2- in "01_Deploy_SVGNFT" add gaslimit to tx, so the code line look like next:

 2-0 origonal code line before edit it:  tx = await svgNFT.create(svg)
 2-1 code line after edit it:  tx = await svgNFT.create(svg, {gasLimit: 3000000 })
 2-2 the result: give me some error message about wrong syntic (form, typing)

3- in "01_Deploy_SVGNFT" add gaslimit to tx, so the code line look like next:

    3-0 origonal code line before edit it:  tx = await svgNFT.create(svg)
    3-1 code line after edit it:  tx = await svgNFT.create({svg}, {gasLimit: 3000000 })

   3-2 the results:
          3-2-0 contract deploying, svg uploading, contract verifying, the matic value decrease in metamask wallet(gas value transfer succeed) all thing look good.
          3-2-1 when go to opensea there's no image appears.
          3-2-2 when go to polygonscan or etherscan and use token id to see the token uri it return nothing (ther's no metadata string appears, nothing appears).

so hope help me find how set the gas limit manually for the first smart contract(SVGNFT.sol) without face this problem when use polygon test or main network.

thanks in advanced

require("@nomiclabs/hardhat-ethers")
require("@nomiclabs/hardhat-etherscan")
require("hardhat-deploy")
require('dotenv').config()


const Mumbai_RPC_URL = process.env.Mumbai_RPC_URL
const Polygon_RPC_URL = process.env.Polygon_RPC_URL
const MNEMONIC = process.env.MNEMONIC
const POLYGONSCAN_API_KEY = process.env.POLYGONSCAN_API_KEY 

// optional
const PRIVATE_KEY = process.env.PRIVATE_KEY

module.exports = {
    defaultNetwork: "matic",
    networks: {

        matic: {
            url: Mumbai_RPC_URL,
               accounts: [PRIVATE_KEY],
           /** accounts: {
                mnemonic: MNEMONIC,
            },**/
            saveDeployments: true,
        },
        polygon: {
            url: Polygon_RPC_URL,
            // accounts: [PRIVATE_KEY],
            accounts: {
                mnemonic: MNEMONIC,
            },
            saveDeployments: true,
        },
        
        
    },
    etherscan: {
        // Your API key for Etherscan
        // Obtain one at https://etherscan.io/
        apiKey: POLYGONSCAN_API_KEY
    },
    namedAccounts: {
        deployer: {
            default: 0, // here this will by default take the first account as deployer
            1: 0 // similarly on mainnet it will take the first account as deployer. Note though that depending on how hardhat network are configured, the account 0 on one network can be different than on another
        },
        feeCollector: {
            default: 1
        }
    },
    solidity: {
        compilers: [
            {
                version: "0.8.0"
            },
            {
                version: "0.7.0"
            },
            {
                version: "0.6.6"
            },
            {
                version: "0.4.24"
            }
        ]
    },
    mocha: {
        timeout: 100000
    }
}

const networkConfig = {
     80001: {
          name: 'matic',
     },
     137: {
        name: 'polygon',
     },
}
module.exports = {
networkConfig,
}
@naive2022
Copy link
Author

problem update

during my search find next code
await contract.wrap(token_id, address, { gasLimit: 250000, gasPrice: gwei });

so i try use same theory to set the gaslimit and final deploy code as next
1- tx = await svgNFT.create({svg}, { gasLimit: 250000, gasPrice: gwei })
when run this deploy code receive some error message about "gwei" is not identified, by other words the code don't know what it is.

so i edit the code again as next:
2- tx = await svgNFT.create({svg}, { gasLimit: 250000, gasPrice: 1 })
the results: when run the deploy code nothing happen (no error message, but also it can not upload the svg), the process did not finish. so i cancel it (using ctrl+z, as i run it from console).

  • but after that when i back the deploy code to it's original i face this error message "deploying "SVG NFT"replacement fee too low"
  • even when try start from scratch i face same error message "deploying "SVG NFT"replacement fee too low"
  • the only thing solve the problem is create new metamask wallet and use it.
    and back to face main problem again "Error: cannot estimate gas; transaction may fail or may require manual gas limit"

@PatrickAlphaC
Copy link
Owner

There is a good chance this is just too big :/

Could you test deploying an NFT with that much data on something like Remix?

@naive2022
Copy link
Author

There is a good chance this is just too big :/

Could you test deploying an NFT with that much data on something like Remix?

I just search for Remix and find it. when try use it find it is not Operation system simulation, so i will start learn it first and then try use it. (this my first tutorial, so i only know harhat)

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