Hot answers tagged

2 votes

How to write unit test in hardhat?

When you create a new hardhat project there is a really good example test. The docs also explain it step by step https://hardhat.org/tutorial/testing-contracts You can run the test for the default ...
user avatar
1 vote

HardHat error: Invalid number of arguments error for constructor with no passed arguments

I think you have a typo, is address instead of adderss
user avatar
1 vote
Accepted

Is there a way to set gas fees to 0 for unit tests in ethers js?

In your hardhat.config.js, you can explicitly state the network that you are using and subsequently the gasPrice that you would like to use. In the docs, there is a gasPrice configuration which can be ...
user avatar
  • 76
1 vote

Modify block number when testing with Hardhat

There's now a Hardhat method exactly for that: From hardhat docs: // mine 256 blocks await hre.network.provider.send("hardhat_mine", ["0x100"]); // mine 1000 blocks with an ...
user avatar
1 vote
Accepted

Returned value solidity

You need to let the Ethereum know that you're just returning a value and you're not modifying the state, which does not require a transaction. To do this, mark your function as a pure function: ...
user avatar
1 vote
Accepted

Governor: proposal not successful

take a look at the following diagram: In order to be able to enqueue a proposal you should previously cast votes, met the required quorum (proposal in state ProposalState.Succeeded) And after the ...
user avatar
1 vote
Accepted

Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.6.2)

Check to see if the keys in the networkConfig object in the helper-hardhat-config.js file match the argument array you set up in 01-deploy-raffle.js. const args = [ vrfCoordinatorV2Adress, ...
user avatar
1 vote

evm_increaseTime in hardhat

In order to advance time when testing with Hardhat, you have to use the network provider's increase_time method. Here's a code of what it should look like const { network } = require("hardhat&...
user avatar
1 vote
Accepted

Error when passing the literal string " " to a function with bytes calldata as parameter

There are some of issues. The function checkUpkeep accepts bytes calldata but it is public. Solc generates an error with that combination. function checkUpkeep(bytes calldata /* checkData */) public ...
user avatar
  • 29.1k
1 vote
Accepted

In My ERC-721 Contract, tokenURI Doesn't Return A String, It Returns A Promise

All contract interactions are asynchronous, you will need to use await or then. await token.tokenURI(1);
user avatar
  • 302
1 vote
Accepted

Hardhat chain fork on the test rather than config file

yes just change your network (add this with your api key to the before each): await hre.network.provider.request({ method: "hardhat_reset", params: [{forking: { ...
user avatar
  • 3,264
1 vote

Difference between `node /* ... */` and `npx hardhat run /* ... */`

npx hardhat node and npx hardhat run are both tasks that come by default in hardhat. You can check all defined tasks with the following commands: npx hardhat or npx hardhat help. Here you have that: ...
user avatar
  • 331
1 vote
Accepted

Getting WETH from ETH on Hardhat Local Network

I think the easiest way to do this is to create an ERC20 called WETH. Something like: // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC20/...
user avatar
  • 26
1 vote
Accepted

console.log not working in scripts/deploy.js and in smart_contract in HardHat

After trying so hard I got the solution. Actually I've installed vs code extension Hardhat+Solidity provided by Hardhat officially. So, I uninstalled it and I installed Solidity extension by Juan ...
user avatar
1 vote
Accepted

NFT mint call reverted while testing

The failed transaction calls the function with id 0xba41b0c6 which refers to the function mint(uint256 amount, bytes32[] merkleProof) But there isn't a function mint with that signature in the ...
user avatar
  • 29.1k

Only top scored, non community-wiki answers of a minimum length are eligible