Frequently Asked Questions

This page contains all frequently asked questions with regards to the issues that users experience when working on the project on buildspace.

Unpredictable Gas Limit

What is Gas Limit?

Gas limit refers to the maximum amount of gas that you're willing to spend on a particular transaction. This error usually happens when you are providing an invalid input when calling a function from your smart contract

βœ… Solutions

// Add a manual gasLimit
await wavePortalContract.wave("hello", { gasLimit: 300000 });
// Add a dynamic gasLimit
const startEstimate = await wavePortalContract.estimateGas.wave("Hello");
const tx = await wavePortalContract.wave("Hello", {
gasLimit: startEstimate,
});

Call revert exception

Why is this happening?

  1. Your metamask wallet is not connected to the correct network
  2. Your contract is not deployed
  3. You did not update your ABI after deploying your contract
  4. You did not implement this function in your smart contract

βœ… Solutions

  1. Make sure you're connected to the correct network your smart contract is deployed to. If your contract is deployed to Rinkeby, make sure you're connected to the Rinkeby network

  2. Deploy by running npx hardhat run scripts/deploy.js --network rinkeby
  3. Make sure to update your ABI to the latest version after deploying your smart contract
  4. Do remember to save your changes in your smart contract before deploying

Many vulnerabilities when installing hardhat

Why is this happening?

This happens because most of the dependencies hardhat used is depenedent on other packages that might be vulnerable. You can simply ignore it as you only need hardhat to help you with compiling and deploying your smart contract and will not be needed in your production environment. However, if you want to fix this issue, you're free to submit a PR here hardhat

Timeout error

Why is this happening?

This happens when your contract deployment takes too long to deploy or that your RPC endpoint is not responding

βœ… Solution

You will need to recreate a new Alchemy app from the dashboard and update it in your environment variables

Error HH100: Network rinkeby doesn’t exist

Why is this happening?

This is usually caused by not having a rinkeby network in your hardhat.config.js

βœ… Solution

Make sure your hardhat.config.js looks like this and also do save your changes before running any commands
// hardhat.config.js
require("@nomiclabs/hardhat-waffle");
require("dotenv").config();
// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
module.exports = {
solidity: "0.8.0",
networks: {
rinkeby: {
url: process.env.ALCHEMY_KEY,
accounts: [process.env.ACCOUNT_PRIVATE_KEY],
},
},
};

error:0308010C:digital envelope routines::unsupported

Why is this happening?

This error is usually caused by the library using an unsupported version of Node.

βœ… Solution

You need to download Node v16.14.2 from here

Hardhat menu not showing

Why is this happening?

This usually happens when you create a hardhat.config.js in your PC drive instead of your project folder.

βœ… Solution

  1. Go to C:/Users/[YOUR_USERNAME] and delete hardhat.config.js
  2. Run npx hardhat

Expected private key to be an Uint8Array with length 32

Why is this happening?

This happens because you're most probably using your wallet address instead of your private key.

βœ… Solution

You can get your private key by following the guide here

Hardhat is not displaying logs

Why is this happening?

This happens because the latest version of hardhat disabled logging by default.

βœ… Solution

There are 2 ways to solving this.
  1. Downgrade your hardhat to 0.9.1 by running npm install hardhat@0.9.1
  2. Add this to your hardhat config
  3. module.exports = {
        solidity: '0.8.4',
        networks: {
            hardhat: {
                loggingEnabled: true,
            },
        },
    };
    

OpenSea is not showing my NFTs

Why is this happening?

There are various reasons why this can happen.
  1. Your image URL is invalid. It needs to have the image extension at the end of the URL to be considered as an image. For example, here's how it might look if you were to use imgur as your image host. https://i.imgur.com/Qm3U6wd_d.webp

  2. Your metadata is not refreshed automatically by OpenSea

βœ… Solution

There are 2 ways to solving this.
  1. Fix your image URL and re-deploy your contract.
  2. Click on the refresh metadata button at the top right corner of your NFT page in OpenSea

Failed to deploy editionDrop. Error (!= 200) =403

Why is this happening?

There are various reasons why this can happen.
  1. You did not initialize your app in your ThirdWeb Dashboard
  2. Your firewall is blocking access to ThirdWeb's IPFS

βœ… Solution You need to initialise your ThirdWebSDK by using cloudflare's IPFS. Special thanks to @piperalpha for this solution

const sdk = new ThirdwebSDK(wallet, {}, new IpfsStorage("https://cloudflare-ipfs.com/ipfs/"));

Hardhat: Nothing to compile

Similar Errors

  • Hardhat: Nothing to compile
  • Cannot find artifacts for contract from any sources

Why is this happening?

This happens because there's a dependency that's not included in the hardhat version.

βœ… Solution You need to install this dependency to fix this issue. Make sure you're installing it in your smart contract folder. After doing this, you should be able to see it generate an Artifacts folder in your project directory. Credits

1. npm install glob@7.2.0
2. npx hardhat run scripts/run.js

VS Code: File import callback error

Why is this happening?

This happens because your smart contract is in a nested folder which can be a problem for VS Code Solidity extension when they're trying to look for a package that you're trying to import from the node_modules.

Normally, if your smart contract is placed in the root folder, VS Code will not throw a file import callback error. Like this

β”œβ”€β”€ node_modules
β”œβ”€β”€ contracts
β”‚   β”œβ”€β”€ **/*.sol
β”œβ”€β”€ scripts
β”‚   β”œβ”€β”€ **/*.js
β”œβ”€β”€ test
β”‚   β”œβ”€β”€ **/*.js
β”œβ”€β”€ hardhat.config.js
β”œβ”€β”€ package.json

Problems will start occuring if you placed your smart contract in a nested folder. Like this

β”œβ”€β”€ frontend
β”‚   β”œβ”€β”€ public
β”‚   β”‚   β”œβ”€β”€ **/*.png
β”‚   β”‚   β”œβ”€β”€ **/*.jpg
β”‚   β”œβ”€β”€ src
β”‚   β”‚   β”œβ”€β”€ App.tsx
β”‚   β”‚   β”œβ”€β”€ index.css
β”‚   β”‚   β”œβ”€β”€ main.tsx
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ smartcontract
β”‚   β”œβ”€β”€ node_modules
β”‚   β”œβ”€β”€ contracts
β”‚   β”‚   β”œβ”€β”€ **/*.sol
β”‚   β”œβ”€β”€ scripts
β”‚   β”‚   β”œβ”€β”€ **/*.js
β”‚   β”œβ”€β”€ test
β”‚   β”‚   β”œβ”€β”€ **/*.js
β”‚   β”œβ”€β”€ hardhat.config.js
β”‚   β”œβ”€β”€ package.json

βœ… Solution You will need to create a .vscode/settings.json to map your contract's node_modules to the one you're trying to import. Here's an example of it

  1. create a folder name .vscode in your root directory
  2. create a file in that folder name settings.json
  3. In your settings.json, your code should look like this
"solidity.remappings": [
"hardhat/=smartcontract/node_modules/hardhat"
"@openzeppelin/contracts/=smartcontract/node_modules/@openzeppelin/contracts"
]
  1. Now, this is how your folder structure will look
β”œβ”€β”€ .vscode
β”‚   β”œβ”€β”€ settings.json
β”œβ”€β”€ frontend
β”‚   β”œβ”€β”€ public
β”‚   β”‚   β”œβ”€β”€ **/*.png
β”‚   β”‚   β”œβ”€β”€ **/*.jpg
β”‚   β”œβ”€β”€ src
β”‚   β”‚   β”œβ”€β”€ App.tsx
β”‚   β”‚   β”œβ”€β”€ index.css
β”‚   β”‚   β”œβ”€β”€ main.tsx
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ smartcontract
β”‚   β”œβ”€β”€ node_modules
β”‚   β”œβ”€β”€ contracts
β”‚   β”‚   β”œβ”€β”€ **/*.sol
β”‚   β”œβ”€β”€ scripts
β”‚   β”‚   β”œβ”€β”€ **/*.js
β”‚   β”œβ”€β”€ test
β”‚   β”‚   β”œβ”€β”€ **/*.js
β”‚   β”œβ”€β”€ hardhat.config.js
β”‚   β”œβ”€β”€ package.json