Questions tagged [hardhat]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
8 views

how to send both ether and other erc20 to the function?

I want to send ether to the function called deposit() mapping(address => uint256) public balance; constructor() { } function deposit (address _tokenAddress) payable public { IERC20(...
0 votes
0 answers
7 views

How to get the gas costs of a reversed transaction when testing (with Chai / ethers.js / Hardhat)?

Does anyone know how to get the gas costs of a reversed transaction when testing with Hardhat / Chai? I found out I can get the receipt object of a transaction, which holds the required data to ...
2 votes
1 answer
8 views

hardhat account balance does not change

I executed some contract creation scripts by terminal through hardhat, "npx hardhat run...." what I noticed is balances of hardhat accounts are not reduced. Meaning as there is no gas spent ...
  • 33
1 vote
2 answers
21 views

What is the use of Truffle/Hardhat?

I had been watching a course online, where I learnt that we can compile & deploy any smart contract to blockchain and then with web3.js we can interact with the smart contract. So why do we need ...
  • 11
0 votes
0 answers
7 views

Contract state doesn't update on Hardhat network

I’m working on a learning project where I have a function that requests a random number to Chainlinks VRFV2Wrapper. Then the fulfillRandomWords function mint an NFT to a random user. All the flow ...
0 votes
0 answers
9 views

STF error when I try to swap USDC for BRZ (Mainnet fork)

I am trying do test the swap from USDC to BRZ using Hardhat with a Mainnet fork (impersonating a wallet that has USDC, and the USDC/BRZ pool exists in Uniswap v3): This is my SC: pragma solidity =0.7....
  • 339
0 votes
1 answer
6 views

How can I mine a transaction in a block with a specified timestamp in Hardhat?

I'm working with time-dependent logic. In order to test it, a specific transaction needs to be mined at a specific time given in seconds. In Hardhat it is possible to increase the block timestamp to ...
0 votes
1 answer
17 views

Hardhat Error: Transaction reverted without a reason string

I'm testing a covered-call option smart contract in hardhat - specifically the execute function where the call buyer executes the option at a specific trike price. However I keep getting a transaction ...
  • 11
0 votes
0 answers
12 views

AssertionError: expected 0 to equal " ". The numerical values of the inputs were compared, and they differed

I'm pretty new to coding and solidiy - I'm testing a covered-call option smart contract in hardhat - specifically a function to check if the balance of the smart contract has been updated following ...
  • 11
0 votes
1 answer
14 views

transaction: reverted with reason string 'STE' using hardhat Uniswap v3

I'm trying to clone the uniswap V3. I am consistently getting the follwing here Error: VM Exception while processing transaction: reverted with reason string 'STE' This is my contract //SPDX-License-...
  • 1
0 votes
2 answers
14 views

How to monitor events on an Solidity Smart Contract using hardhat and ethers?

I'd like to monitor events happening on-chain on a specific Smart Contract. I'd like to know every time a Transfer event happens. I tried to write a code with hardhat, but no events if being logged. ...
0 votes
1 answer
12 views

remote hardhat - metamask connection issue

I am trying to set up a dev website accessible from remote. Thus I have install my application in AWS where I run a hardhat. However I can not connect metamask to that instance. I keep on having an ...
  • 11
0 votes
0 answers
48 views

Provider error hardhat

When i want to deploy my contract with this command: npx hardhat run --network goerli scripts/deploy.js I get this error: ProviderError: HttpProviderError at HttpProvider.request (/Users/alirezamac/...
  • 23
0 votes
1 answer
34 views

Hardhat deploy contract error: Error: cannot estimate gas; transaction may fail or may require manual gas limit

I want to deploy a FlashLoan smart contract using hardhat, and deploy the contract on hardhat network that fork by mainnet. But when I run the deploy script, keep showing Error: cannot estimate gas; ...
1 vote
0 answers
21 views

Hardhat chainID 31337 not changed to 1337 of Metamask localhost

I tried to use 1337 as chainID on Hardhat to match metamask localhost 8545. My hardhat.config.js have already included 1337 chainID for hardhat as below. module.exports = { solidity: "0.8.17&...
0 votes
1 answer
25 views

Error: call revert exception Uniswap getAmountsOut

I am trying to build a bot that can perform tri-arbitrage trades and I ran into an issue that I don't really understand when trying to interact with the Uniswap v2 router in my contract to estimate a ...
  • 133
0 votes
0 answers
10 views

How to set proxy to hardhat?

We will verify the contract after deploy, but I cannot access to the api without proxy. So how to set proxy to hardhat? Set proxy to hardhat.config.js or something else ? const verify = async (...
  • 101
0 votes
1 answer
10 views

SyntaxError: Digit expected on hardhat-compile

Here is a contract I am trying to compile // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "@openzeppelin/contracts/access/Ownable.sol"; contract EscrowView is ...
0 votes
0 answers
17 views

RangeError: The number ".." cannot be converted to a BigInt because it is not an integer

pretty new to coding and solidiy - I'm testing a covered-call option smart contract in hardhat - specifically a function to refund the call writer if the option is not executed but I keep getting a ...
  • 11
0 votes
0 answers
9 views

How to import interface from lower level of Solidity?

I'm extending a large codebase with another contract and I need to import an interface. My new contract uses 0.8.9 but the rest of the codebase is in 0.6.12. I'm using Hardhat multi compile to do ...
  • 65
0 votes
1 answer
23 views

How to properly use promises in loop contract calls when testing?

I've written this test but I've been told here that I should not use await inside a for loop; What I've found out is that using await will stop the execution of my code until the call to the network ...
0 votes
1 answer
13 views

Add liquidity function of uniswap is not minting LP tokens

I cloned uniswapv2 core and periphery contracts, and created 2 erc20 tokens, when i write test cases for addLiquidity function, one pair is created for tokens, the tokens are transfered to the pair ...
0 votes
1 answer
35 views

When deploy with hardhat, if there is the same contract name, how should I put the argument in getContractFactory?

I am currently trying to use OpenZeppelin's upgrade plugin. I am changing a logic contract, but it has the same name as the previous contract. this is deploy UUTP code import { ethers, upgrades } from ...
  • 153
0 votes
1 answer
32 views

Reset nonce to 0

Using hardhat and ethers.js, how do I reset the nonce queue to 0? Not submitting a new tx with the nonce of the one that's stuck. For example, the latest nonce I have is 432 and I want to reset it to ...
  • 475
1 vote
1 answer
30 views

Hardhat and Chai testing : How should I write the test?

I've digged through all the related question, but none of these worked for me. I used this repo, and replaced the contract and test file : https://github.com/NomicFoundation/hardhat-boilerplate EDIT ...
0 votes
0 answers
12 views

Calling chainlink VRFCoordinatorV2.sol contract from a local hardhat network (Goerli fork)

The goal is to work with the real VRFV2Coordinator contract: https://github.com/smartcontractkit/chainlink/blob/e1e78865d4f3e609e7977777d7fb0604913b63ed/contracts/src/v0.8/VRFCoordinatorV2.sol That is ...
  • 1
0 votes
1 answer
13 views

How to get the exact block number in Hardhat deploy script?

I have written a code in hardhat deploy script to fetch the exact block number at which the contract has been executed, but it usually returns the block next to the original. Any idea how to get the ...
0 votes
0 answers
9 views

Typechain and @typechain/ethersv5 conflicting issue in hardhat

I am trying to write test cases in hardhat using Typescript and Typechain. But when I try to compile the contracts using npx hardhat compile, it is asking me to install @typechain/ethers-v5. When I ...
0 votes
0 answers
16 views

Crowfund Contract - Hardhat deploy Scripts- Help needed?

So i have followed this tutorial that creates a CrowdFund contract. In the tutorial he also creates an ERC20 token that gets deployed. And then that contract address is passed into the constructor of ...
0 votes
1 answer
15 views

Getting Error: `Error: VM Exception while processing transaction: reverted with reason string 'TimelockController: underlying transaction reverted'"`

I am using openzepellin Govenance Wizard contract & openzepellin TimelockController . I am getting this error: Error: VM Exception while processing transaction: reverted with reason string '...
1 vote
1 answer
77 views

Hardhat testing - Error: Transaction reverted without a reason string

I'm new to coding and solidiy - I'm trying to test a covered-call option smart contract in hardhat but keep getting a transaction reverted error when I try to test the transfer of ether into the ...
  • 11
0 votes
1 answer
51 views

How to get USDC balance of impersonated wallet in Hardhat test

I am writing a smart contract that uses USDC when a NFT is purchased (so the USDC is transferred from the seller to the buyer). I am trying to test it in Hardhat but I am having troubles when using ...
0 votes
0 answers
13 views

Testing solidity contract with hadhat gives error missing argument even if i pass all valid arguments

Everything is working fine if we remove the array of addresses which is the last parameter in my function call. I have 14 parameters in my contract and if I am passing 14 parameters, Then also it ...
0 votes
2 answers
34 views

Hardhat - how to Verify a Contract

I've successfully deployed an ERC721 contract to GOERLI using Hardhat - and the contract is working perfectly, but when I try to verify the contract, I keep getting errors. I'm wondering if it has ...
  • 899
0 votes
1 answer
23 views

How to write a request funds function in solidity

Hello everyone…I am trying to build a dapp where a user can request funds or ethers from a specific address and then that address can approve that function, then the person who requested the fund will ...
  • 3
1 vote
1 answer
71 views

How to write tests for "msg.sender" being a contract?

I want to write unit-test (using ethers.js on top of an hardhat-project) that covers a hook-function for OpenZeppelin's ERC1155 contract: onERC1155Received. The special thing here is that the msg....
  • 297
0 votes
1 answer
40 views

Proper way to write ETH Withdrawal function in Contract

There seem to be two different ways to write a withdrawal function to get ETH funds out of a contract you've deployed. I'm wondering which is the better - or "safer" way to do this (in 2022.)...
  • 899
1 vote
1 answer
38 views

Error when importing ethers from hardhat

I am creating a react frontend that interacts with some smart contracts. However, when I run npm start to run my react application, I am getting the following error: Failed to compile. ./node_modules/...
0 votes
0 answers
25 views

How do I test a bool value?

I'm stuck on my last test for the NftMarketPlace unit tests. I want it to revert if the withdrawal is not successful. I have searched how to write tests for boolean values but I didn't find anything ...
0 votes
1 answer
15 views

Hardhat Deployment

I am trying to deploy a simple Token.sol script to a local network using hardhat though keep getting this error when running the script. I will post a photo of the error and then my migration script. ...
0 votes
0 answers
33 views

Error in hardhat config file

I am having an issue with smart contract deployment using hardhat. I don't see where is the error coming from. I have defined the .env file with values and also correctly called those values using ...
0 votes
0 answers
11 views

Available objects within require("hardhat")?

My understanding is that calling require("hardhat") gives you an instance of the hardhat runtime environment for your code to access. In a lot of sample code, they are pulling out objects ...
0 votes
2 answers
18 views

How to deploy a contract using HardHat which is using an a library

Suppose i have an contract name MetaCoin.sol // SPDX-License-Identifier: MIT // Tells the Solidity compiler to compile only from v0.8.13 to v0.9.0 pragma solidity ^0.8.13; import "./...
0 votes
1 answer
38 views

Fail with error '27' - Aave flashloans solidity

I have succesfully deployed the contract to the goerli testnet, via hardhat. However when I try to call the requestFlashLoan function with metamask, the transaction suggested gas fee seems unusually ...
0 votes
0 answers
33 views

transfer tokens from smart contract to wallet

I want to transfer tokens from my smart contract to my wallet, but it isn't working. My smart contract (Which I deploy to Mumbai testnet with hardhat): // SPDX-License-Identifier: MIT pragma solidity ^...
  • 11
0 votes
1 answer
10 views

how to parameterize which namedAccount I connect a contract to inside of a hardhat task?

I want to be able to switch between which account calls the function by passing the name as the parameter to the task: yarn hardhat doSomething --name deployer --network localhost task( "...
0 votes
1 answer
25 views

buyback token with uniswap-v3

I write a smart contract can buyback a specific token with the contract balance ETH, however I have the tx error Error: VM Exception while processing transaction: reverted with reason string 'STF' (...
0 votes
1 answer
24 views

Hardhat multiple folders for compilation

Is there a way to provide multiple folders for compilation in hardhat config? I test my contracts with the foundry and all test contracts are under test/foundry folder so the written code in this ...
  • 82
0 votes
1 answer
47 views

Forking mainnet with Hardhat + Alchemy fails with "Too Many Requests"

Running into a problem attempting to test with hardhat by forking mainnet. I'm following the instructions here: https://hardhat.org/hardhat-network/docs/guides/forking-other-networks. I have a ...
  • 111
0 votes
0 answers
33 views

I need an additional Loader

I'm trying to start a react app using NPM to connect my SmartContracts, but using the following commands i am still getting an error: $ npm start **Failed to compile. ../node_modules/hardhat/...

1
2 3 4 5
19