Questions tagged [hardhat]

The tag has no usage guidance.

629 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8 votes
1 answer
926 views

hardhat remappings option in configs

I know that solc can take remappings but I'm trying to force hardhat to take in my remappings.txt file each time it is compile. I've looked for a while and can't seem to find anything about that on ...
karma badger's user avatar
6 votes
0 answers
723 views

Save hardhat node state for later

Is there a way to save your current local hardhat node state for later? Or do you have to restart every time you start up a new node? Like: yarn hardhat node --from-state ./state-dir Or something
Patrick Collins's user avatar
6 votes
2 answers
2k views

Hardhat - HardhatEthersProvider.resolveName is not implemented

I'm passing the contract address from a bash script export CONTRACT_ADDRESS I verified contractAddress has the correct value in my javascript, but I'm getting NotImplementedError: Method '...
user125051's user avatar
5 votes
0 answers
2k views

How to calculate gas fees to deploy smart contract? (on Hardhat OR Truffle)

How to calculate gas fees to deploy smart contract on Hardhat OR Truffle
Gajesh S Naik's user avatar
5 votes
1 answer
6k views

Subscribing to events using ethers / hardhat network

I have a basic node express application. It connects to my locally running hardhat network via ethers & websocket. The connection seems to work, since I can query the blockchain succesfully (for ...
Fabian Scherer's user avatar
5 votes
1 answer
260 views

Is it possible to fork multiple blockchains at the same time for testing smart contracts?

I am trying to fork ethereum, polygon, and arbitrum at the same time. I tried to use ganache-cli specifying different ports for each chain but it does not seem to grab the chain data when I use a ...
Prox Ima's user avatar
4 votes
0 answers
353 views

Hardhat and foundry, contract bytecode different

I'm developing a contract in hardhat project. But now I want to write test by foundry. My problem is I'm using create2, but when running contract by hardhat and foundry they gave different addresses. ...
CT95's user avatar
  • 396
3 votes
0 answers
119 views

How to mock smart contract with hardhat and ethers v6

I found here 2 ways to mock Smart contract but they all limited to ethers.js v5: @nomiclabs/hardhat-waffle @defi-wonderland/smock Today hardhat-toolbox is at version 4 and migrated away from hardhat-...
codekoriko's user avatar
3 votes
1 answer
1k views

contract runner does not support sending transactions

Update (08 July 2023) : From node_modules/ethers/lib.esm/contract/contract.js, I found the error message (the assert part). const send = async function (...args) { const runner = contract....
Téwa's user avatar
  • 141
3 votes
1 answer
260 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 ...
Josip's user avatar
  • 53
3 votes
2 answers
674 views

Testing VrfCoordinatorV2Mock fulfillRandomWords gets stuck

I am testing a smart contract that uses Chainlink's VRF Oracle. Locally, I am using a mock to test with. In the unit test it never executes the fulfillRandomWords function that on my smart contract, ...
Anas Latique's user avatar
3 votes
0 answers
342 views

hardhat-deploy openzeppelin transparent proxies

Could anyone please share how can we use hardhat-deploy with openzeppelin transparent proxies properly because the hardhat-deploy seems to have this option but I was not able to find any good ...
Shiv Bhonde's user avatar
3 votes
1 answer
152 views

Deploy Upgradable contract with factory contract

I have a simple contract below Swap.sol that is upgradable. // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "@openzeppelin/contracts-upgradeable/proxy/utils/...
Haris's user avatar
  • 123
3 votes
1 answer
461 views

Get interfaceId from interface in ethers js or hardhat

Solidity has this wonderful way to quickly get the interface id from an interface. Suppose I have the interface interface undernose { function overmouth() external; } then solidity (at least in ...
Marlo's user avatar
  • 329
3 votes
0 answers
515 views

Hardhat test increasing account balance

I'm running the test outlined below using Hardhat. The smart contract has a function to output 'msg.sender.balance', and the test file calls this function, then waits for the next block, then calls ...
Rick's user avatar
  • 91
3 votes
0 answers
1k views

hardhat verify contract faild! Help!

I use command npx hardhat verify, and the log is: Nothing to compile No need to generate any newer typings. Successfully submitted source code for contract contracts/ygu/yguToken.sol:YGUToken at ...
euclan's user avatar
  • 31
3 votes
0 answers
596 views

How to set manual gas limit for a specific transaction (using hardhat, polygon test and main network)?

How to set manual gas limit when deploying(mint) in case of a specific transaction (using hardhat, polygon test and main network)?
naive2022's user avatar
3 votes
0 answers
479 views

How to test EIP-2981 implementation with hardhat/ethers

My goal is to mint an NFT collection and then import it onto OpenSea. I know you can import an existing ERC-721 contract onto OpenSea, but I'm trying to figure out how secondary sales work and if they'...
Brodan's user avatar
  • 31
3 votes
0 answers
883 views

ethers.js can't handle functions with variant call signature?

I get type errors in hardhat when my contracts have two versions of the same function which differ only by call signature, i.e. contract MyContract { string memory public _defaultVersion ="1.0....
GGizmos's user avatar
  • 741
3 votes
0 answers
783 views

Locally test Chainlink VRF call from another contract in Waffle/Hardhat

Locally testing Chainlinks VRF While trying to locally test a contract that calls a Chainlink VRF contract, I'm experiencing some difficulties in setting up the contract balances. I have a ...
a.t.'s user avatar
  • 65
3 votes
2 answers
2k views

How do I wait for confirmation in metamask/ethers before proceeding

The following function happens when a user clicks a "withdraw" button in my dapp: const canUserWithdraw = async () => { if (b <= a) { alert("You can ...
ComicBookGuy's user avatar
3 votes
1 answer
1k views

Openzeppelin test helper with hardhat config and tests

I'm using hardhat and I added a task to manipulate time in the hardhat.config.js file which is working fine. require("@nomiclabs/hardhat-waffle"); require("@nomiclabs/hardhat-truffle5&...
Majd TL's user avatar
  • 3,217
3 votes
1 answer
1k views

Ethers and Web3-React: Cannot estimate gas when trying to connect with contracts deployed on testnet and using Alchemy as node provider

I'm trying to connect with contracts deployed on the Rinkeby testnet using a node provider. When I was testing using hardhat as a local node, the contracts are called with no problem, but when I ...
Dan's user avatar
  • 31
3 votes
1 answer
626 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/...
shamapumbu muzandu's user avatar
3 votes
3 answers
7k views

Are the Hardhat provided accounts' public keys as accessible as their private keys?

I know that if I run Hardhat node, I will be provided with the addresses and private keys of the Hardhat provided accounts, like this: Hardhat Accounts ======== Account #0: ...
Roberto's user avatar
  • 63
2 votes
0 answers
118 views

Hardhat throw Error: yParity mismatch (argument="signature", ...... ) when i try to deploy smartcotnract in sepolia testnet

Command passed: npx hardhat run scripts/deploy.js --network sepolia Hardhat throw error when i try to deploy smart contract in sepolia test using alchemy api: TypeError: yParity mismatch (argument=&...
Ethereum Developer's user avatar
2 votes
1 answer
75 views

TypeError in Hardhat-Chai Matchers - isAddress not a function

I'm encountering a TypeError in my Hardhat test script that involves the isAddress function from the @nomicfoundation/hardhat-chai-matchers library. The error seems to be causing issues with my test ...
Aung's user avatar
  • 21
2 votes
0 answers
399 views

Could not decode result data

I have an issue when trying deploy contract // SPDX-License-Identifier: ISC pragma solidity ^0.8.19; contract SimpleStorage { uint256 favoriteNumber; struct People { uint256 favoriteNumber; ...
Victor's user avatar
  • 45
2 votes
1 answer
240 views

TypeError: Cannot read properties of undefined (reading 'checkUpkeep')

i'm getting this error while testing patrick collins smart-contract-lottery project, below is the part where the error coming from. describe("checkUpkeep", async function () { ...
Gautam's user avatar
  • 33
2 votes
0 answers
174 views

Hardhat public network fork: Error calling view functions with ethers.js on browser

I have my hardhat network configured as a fork of Binance Smart Chain like this: const config: HardhatUserConfig = { solidity: { version: "0.8.0", settings: { optimizer: { ...
Alexander Herranz's user avatar
2 votes
1 answer
658 views

How can I solve TypeError: Cannot read properties of undefined (reading 'getBalance')?

TL;DR I'm using ethers v6.7.0 const startingFundMeBalance = await fundMe.provider.getBalance(fundMe.target) lines using provider.getBalance are creating the problem. const { deployments, ethers, ...
ch9xy's user avatar
  • 121
2 votes
0 answers
188 views

Compilation error in deploying a contract on zksync, using deploy zksync

I'm trying to compile the code but I keep getting an error. Here is the hardhat.config.ts code: import "@matterlabs/hardhat-zksync-deploy"; import "@matterlabs/hardhat-zksync-solc";...
Mitchell Nwafor's user avatar
2 votes
0 answers
96 views

Can not sign transaction with signer get from mnemonic

I'm writing test for MAX_SUPPLY of this function // contract.sol function mintStandard() public payable whenNotPaused { require( _standardCounter.current() <= 2222, &...
dtnwen's user avatar
  • 33
2 votes
1 answer
115 views

how to use uniswap with hardhat?

I am try to using uniswap in hardhat test: it("should getAmountsOut for Token", async function () { const uniswapRouterAddress = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"; ...
Moon soon's user avatar
  • 163
2 votes
1 answer
190 views

How to send Wei to payable function with ethers

I want to send this function 1 wei using ethersJS while testing it on hardhat: modifier payFee() { bool sent = payable(address(this)).send(msg.value); require(sent, "Didn't receive fee.&...
Shadq's user avatar
  • 93
2 votes
1 answer
65 views

Can not interact with the deployed contract

getting this error Error: Transaction reverted: function returned an unexpected amount of data at Proxy.getDecimals (contracts/proxy.sol:100) at processTicksAndRejections (node:internal/process/...
Cartman_bruh's user avatar
2 votes
1 answer
93 views

How can ERC20 tokens be obtained in a local hardaht forked environment?

I've been learning about ethereum for a short time, besides my English could be better; if I'm wrong about something, please correct me. 😁 I am trying to test the interaction of different contract ...
4nibhal's user avatar
  • 21
2 votes
0 answers
69 views

I have a for loop. it doesnt work on hardhat but works on mumbai testnet

I have basic chainlink vrf contract.Trying to get 12 random numbers.I want to save those random numbers in another array. I define an array called output. in fulfillRandomWords function, simple assign ...
Furkan Sezal's user avatar
2 votes
0 answers
182 views

Debug Hardhat with Foundry

Can you debug a Hardhat project using Foundry? I know that doing Foundry tests on Hardhat is possible through their plugin, but is it possible to debug also?
dNyrM's user avatar
  • 936
2 votes
1 answer
433 views

How to access address mapping to array struct in hardhat solidity?

I'm writing Unit Test using hardhat for a solidity contract. There is a public mapping variable which has a mapping of address to array of struct. struct ticket { uint16 looteryID; ...
Ashish Kumar Rena's user avatar
2 votes
0 answers
115 views

AssertionError: Expected event "RaffleEnter" to be emited, but it doesn't exist in the contract

I'm working on freeCodeCamp.org's Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course I have the following contract code: //SPDX-License-Identifier: MIT pragma ...
PSS's user avatar
  • 543
2 votes
1 answer
138 views

Contract Verify fails

This is my code for utils/verify.js const { run } = require("hardhat") const verify = async (contractAddress, arguments) => { console.log("Verifying Contract... ") try { ...
Yana Gupta's user avatar
2 votes
1 answer
94 views

Struct returns indexed numbers and property names

I'm using ethers and hardhat to run my React application. I want to pass an object as a parameter to a Solidity function. The function should map the object (struct) to the id provided as a property ...
Justin Stephens's user avatar
2 votes
0 answers
135 views

Reverting blockchain state after each test (Hardhhat isolation Fixture)

When writing smart contract tests in python (using Brownie). I extensively used isolation fixture. This allowed me to isolate test cases from each other. Example: We have TokenContract, which upon ...
Sky's user avatar
  • 2,302
2 votes
0 answers
234 views

Deploying on hardhat using gnosis-safe as deployer

Is there any approach to deploy smart contracts in hardhat using my gnosis safe as deployer? I had a look over hardhat plugins but I haven't found anything. Any idea?
DIIMIIM's user avatar
  • 131
2 votes
0 answers
598 views

Error HH502: Couldn't download compiler version list. Please check your internet connection and try again

I am following the process from https://hardhat.org/tutorial/creating-a-new-hardhat-project to create a new hardhat project. After Doing yarn hardhat, I choose >Create a JavaScript project But when ...
Josal's user avatar
  • 121
2 votes
1 answer
867 views

How to connect Hardhat to my own private geth chain?

I can connect truffle to my own geth chain, with this setting $ vi truffle-config.js networks: { development: { host: "mydomain.com", port: 9000, network_id: "*&...
user6894661's user avatar
2 votes
0 answers
623 views

HardhatError: HH110: Invalid JSON-RPC response received: missing token when deploying to Görli (Gorli/Goerli) testnet

Summary When I run yarn hardhat run scripts/deploy.js --network goerli, the following error is displayed in my terminal: HardhatError: HH110: Invalid JSON-RPC response received: missing token at ...
BowTiedApu's user avatar
2 votes
1 answer
181 views

How to deploy .yul contract with Hardhat?

I would like to deploy a contract written in pure Yul with Hardhat but I'm not sure how to do it. Is there some plugin for it, or do I just need to add special fields to the hardhat.config.js file? ...
Kuly14's user avatar
  • 342
2 votes
0 answers
168 views

function call failed to execute with swapExactETHForTokens on pancakeswap

My friends, I am trying to create a function to swap WBNB vs tokens On pancakeswap. I can swap token vs token, But when I try to swap WBNB vs token, I'm stuck and get the error in the end of this post....
david's user avatar
  • 41

1
2 3 4 5
13