Questions tagged [hardhat]

For questions about Hardhat - a development environment for Ethereum software. When using this tag also include the more generic [ethereum] tag where possible.

712 questions
27
votes
3 answers

No safeTransferFrom function in ethers.js contract instance?

I created a contract instance in hardhat console like so: const contract_fac = await ethers.getContractFactory("ContractName"); const contract = await contract_fac.attach("CONTRACTADDR..."); Contract object has all public/external functions except…
Lightstorm
  • 379
  • 4
  • 5
18
votes
1 answer

How can I use different addresses to call functions in Hardhat tests and scripts?

When running tests and scripts, all functions are called by the first address provided by Hardhat. I'd like to know if there's a way to change the calling address within the same test or script. Thanks in advance!
Nico
  • 181
  • 1
  • 4
15
votes
10 answers

Error HH12: Trying to use a non-local installation of Hardhat, which is not supported. Please install Hardhat locally using npm or Yarn, and try again

I've been working on a Hardhat project for sometime. After a while, when I run npx hardhat node to start the HH server, I get the error below: I tried researching the error and found this on the hardhat site HH12: Hardhat is not installed or…
KelvinIOT
  • 325
  • 1
  • 2
  • 14
15
votes
5 answers

Failing to compile multiple Solidity versions

I'm trying to compile (through Hardhat) a contract that imports several interfaces with different Solidity versions but I'm getting the following error: Error HH606: The project cannot be compiled, see reasons below. These files and its…
dNyrM
  • 545
  • 1
  • 4
  • 17
12
votes
4 answers

Ethers.js "Error: unknown account #0 (operation="getAddress", code=UNSUPPORTED_OPERATION)"

I'm trying to fetch the price of ETH from KyberSwap, using Ethers.js, but I'm receiving the following error: Error: unknown account #0 (operation="getAddress", code=UNSUPPORTED_OPERATION, version=providers/5.5.3) I'm connected to an Infura web…
Jasperan
  • 2,154
  • 1
  • 16
  • 40
12
votes
6 answers

Error HH604: Error running JSON-RPC server: error:0308010C:digital envelope routines::unsupported

I am setting up hardhat in Linux. I have set up the react app first using these commands. npx create-react-app react-dapp cd react-dapp Then I have installed some hardhat dependencies using this command. npm install ethers hardhat…
enstazao
  • 121
  • 1
  • 8
11
votes
6 answers

Error in plugin @nomiclabs/hardhat-etherscan: The contract verification failed. Reason: Fail - Unable to verify - with arguments

I am trying to verify my contract with arguments and I am getting this error: Error in plugin @nomiclabs/hardhat-etherscan: The contract verification failed. Reason: Fail - Unable to verify I am also importing Open Zeppelin contracts…
solidityguy
  • 199
  • 1
  • 3
  • 8
11
votes
4 answers

How do I add ether to my localhost Metamask wallet with Hardhat?

I've connected metamask to a node created with hardhat. I can connect to this node on http://localhost:8545 network in metamask after setting the chain id to match the hardhat network chain id (31337) How can I send ether to the accounts/addresses…
goonerify
  • 1,668
  • 25
  • 27
10
votes
3 answers

How to limit token receiver callers to accepted token address?

I want to create a payable token which includes a function transferAndCall(TokenReceiver to, uint256 amount, bytes4 selector). By calling this function, you can transfer tokens to the TokenReceiver smart contract address, and then call…
Aleks Shenshin
  • 2,117
  • 5
  • 18
10
votes
4 answers

"npx hardhat accounts" not available in Hardhat latest version 2.9.9

I have installed the latest version of hardhat. It installed fine. After setting hardhat up and installing all the required packages, when I run: npx hardhat accounts It gives an error: Error HH303: Unrecognized task accounts It seems like…
Umair
  • 313
  • 3
  • 10
10
votes
2 answers

How to receive a value returned by a Solidity smart contract transacting function?

I am writing an NFT smart contract which I am going to test via Hardhat and deploy on RSK. //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; contract MyNFT…
Ahsan
  • 339
  • 3
  • 11
10
votes
3 answers

hardhat run with parameters

I need to run a particular ts script using hardhat from the command line but I need to specify parameters... Similar to this: npx hardhat run --network rinkeby scripts/task-executor.ts param1 param2 Where the --network rinkeby is the parameter for…
Anibal Estevez
  • 121
  • 1
  • 6
10
votes
1 answer

Get events from a transaction receipt in hardhat

I have an ethers contract that I've made a transaction with: const randomSVG = new ethers.Contract(RandomSVG.address, RandomSVGContract.interface, signer) let tx = await randomSVG.create() I have an event with this transaction: function create()…
Patrick Collins
  • 5,621
  • 3
  • 26
  • 64
9
votes
6 answers

Invalid address or ENS name

I can't understand what the problem is. When I am run the app I am getting this error: Unhandled Runtime Error Error: invalid address or ENS name (argument="name", value=5.050201689117535e+47, code=INVALID_ARGUMENT, version=contracts/5.5.0) My code…
Ishtiaq Mahmood
  • 154
  • 1
  • 2
  • 8
9
votes
9 answers

Error connecting to localhost after npm hardhat run

I am new to deploying smart contracts with hardhat and am following a tutorial at https://dev.to/dabit3/the-complete-guide-to-full-stack-ethereum-development-3j13. However, after running npx hardhat run scripts/deploy.js --network localhost, I get…
sultan m_c_t
  • 99
  • 1
  • 1
  • 3
1
2 3
47 48