Questions tagged [hardhat]
The hardhat tag has no usage guidance.
473
questions
0
votes
0
answers
8
views
How to send ether to a contract with receive( ) in hardhat?
I have written the Ether Wallet Contract.
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;
contract EtherWallet {
address payable public owner;
// solhint-disable-next-line no-empty-...
0
votes
0
answers
5
views
CALL_EXCEPTION when calling a simple view function with ethers.js, but not in my hardhat test
UPDATE:
The short description is this function works the contract is deployed on Mumbai Polygon, but fails in Hardhat locally.
Details:
Here is my simple function which has no issue when testing, but ...
0
votes
0
answers
3
views
Hardhat mumbai forking is throwing ConnectTimeoutError
I've started to learning Chainlink and made a simple contract that query a Data Feed ETH/USD, as you can see in details in this repository: https://github.com/fabianorodrigo/chainlink-experiments.
...
0
votes
1
answer
23
views
from solidity: TypeError: Member "log" not found or not visible after argument-dependent lookup in type(library console)
from solidity: TypeError: Member "log" not found or not visible after argument-dependent lookup in type(library console).
Im using hardhats lib "hardhat/console.sol";
I want to ...
0
votes
0
answers
5
views
Invalid ENS name in Damn Vulnerable Defi (naive-receiver)
I'm trying to solve the Damn vulnerable Defi challenge's Level 2 - Naive Receiver.
We have to drain the user's balance by exploiting the missing access control allowing anyone to be the borrower and ...
0
votes
0
answers
8
views
Metamask doesn't connect to it's own localhost or hardhat localhost
Metamask doesn't connect to it's own localhost. I run a hardhat node from Mac. I know it's a known issue, but I've tried all available methods listed below.
I tried installing older versions of ...
0
votes
0
answers
4
views
How to get hardhat to give more detailed error messages?
I am trying to call some function from the smart contract and I am only recieving the error message Error: Transaction reverted without a reason string . This makes degubbing quite hard.
Is there ...
0
votes
1
answer
25
views
fallback not executing
I have a test project with proxy pattern (fallback/delegate call). The purpose is to have upgradeable contracts.
Here is the proxy contract:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
...
0
votes
1
answer
14
views
hardhat beginner "Nothing to compile" error
following hardhat beginner tutorial.
This is how I did it,
first run "npx hardhat " command and created basic sample project. After that run following command
npm install --save-dev @...
0
votes
0
answers
5
views
Mint an NFT in the "backend" and let user claim it in the frontend
I have users coming to my frontend, connecting with their wallet, and authenticating with Twitter (using OAuth). The next step is to let them mint an NFT with their Twitter name (extracted on the fly ...
0
votes
0
answers
6
views
Testing require failures and events with HardHat
There are two things I want to do with Hardhat that I cannot figure out. The first is having a test pass when the "require" logic inside my contract causes a transaction to fail.
As a ...
0
votes
1
answer
14
views
Add a 'from' account to hardhat transaction calls
I recently started learning to use hardhat to interact with and deploy smart contracts and I noticed that while brownie can accept a from address field for chain transactions, hardhat doesn't.
Does ...
0
votes
0
answers
7
views
Best way sorting and using own libraries
I just wondered what would be the best way using/reusing my own libraries/contracts?
I mean if I use libraries or contracts from openzeppelin I just add them with an import at hardhat.
Now I am ...
0
votes
1
answer
11
views
how to test all funds are withdrawn from a contract with hard hat
the function in the contract is
function withdraw() external onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
the test I've started is
it('Should withdraw all ...
0
votes
1
answer
35
views
How to test address(0) with Hard Hat?
This is my test, which fails and it should pass
it('Should not allow 0 address to be added', async () => {
await expect(greeter.addWhitelistAddress('0x0')).to.be.revertedWith(
'Invalid ...
0
votes
0
answers
16
views
Openzeppelin 2.x Crowdsale Solidity Pragma issue
how can I compile multiple versions within one project?
currently I am developing a crowdsale repo. I want to implement the feature to let the investor claimBack their funds
So I implemented this into ...
0
votes
1
answer
29
views
how to use a library with testcases using hardhat
I'm using a library for managing Events. Now when I'm running the test case script then I'm getting an error.
ERROR
If I don't mention the library when I'm deploying the Users.sol contract.
...
0
votes
0
answers
15
views
How to Calculate USD Transaction Gas Cost in Hardhat?
I know this has been asked many times but would like to get confirmation when using hardhat as my cost is not where I think it's supposed to be.
const receipt = await contract.safeMint(5)
.then((tx:...
0
votes
1
answer
15
views
about deploying polygon smart contract mumbai
When I run npx hardhat compile I got this error;
Error: Cannot find module '@nomiclabs/hardhat-waffle'
Require stack:
- C:\Users\User\Documents\co\polygon-smart-contract-tutorial\hardhat.config.js
- C:...
0
votes
0
answers
12
views
Unit test in hardhat of SushiToken function delegatebySig
I'm playing around with contracts and trying to get the hang of it.
My problem is I'm stuck with a singe function I like to unit test.
I have absolutely no idea how to create an signatory in the ...
0
votes
1
answer
35
views
Passing an array of constructor arguments through hardhat-etherscan in CLI
Here is the code that I used to deploy this contract to the Rinkeby network.
const hre = require("hardhat");
async function main() {
// Hardhat always runs the compile task when running ...
0
votes
1
answer
8
views
HH404 Hardhat error at correct entry-point to an existance fi
I have that route and It fails to compile but if I change @openzeppelin/contracts/token/ERC20/ERC20Burnable.sol to @openzeppelin/contracts/token/ERC20/ERC20.sol it compiles without problems.
How it ...
0
votes
1
answer
21
views
Hardhat test verificaiton failed
I have Error in plugin @nomiclabs/hardhat-etherscan: The selected network is hardhat. Please select a network supported by Etherscan. when trying to verify a contract in hardhat.
The contract: ...
0
votes
1
answer
15
views
Error HH600: Compilation failed ParserError: Expected ',' but got ';'
I was doing the chainlink hackton lesson "DeFi Staking App: Code Along" link when I got this error while running yarn hardhat compile:
ParserError: Expected ',' but got ';'
--> contracts/...
0
votes
1
answer
18
views
How to test contract not being called by another contract?
In my contract I have a modifier that doesn't allow for other contracts to call the function
modifier callerIsUser() {
require(tx.origin == msg.sender, "The caller cannot be another contract&...
0
votes
1
answer
24
views
How to deploy Ownable contract with Hardhat and Ethers?
When I deploy an Ownable contract via hardhat (hardhat-deploy in particular) to Optimistic Kovan, it doesn't seem to set the owner correctly, whereas when I deploy the same set of contracts via Remix, ...
0
votes
0
answers
12
views
hardhat check doesn't specify files
i may be missing something, but when running npx hardhat check i get a list of warnings with line numbers but no filenames. how do i know where these are?
line 38:29 extraneous input 'timeLockDelay' ...
0
votes
1
answer
39
views
function selector was not recognized error
I'm extending OpenZeppelins ERC20 to create a Token that I use for testing in another smart contract. Here's how it looks:
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "@...
0
votes
1
answer
14
views
Is it possible to run hardhat node & hardhat deploy in Github Actions? | Github Action Stuck for hours
Currently using the code below for Github Actions to test local deployment. However, my github actions have been stuck for hours on Test deploy.
Any ideas on how I can fix it?
# This is a basic ...
0
votes
1
answer
37
views
How to mock smart contract function for testing (in hardhat)
In my Test I want to mock an external function that I call inside my smart contract to test both conditions without writing and deploying an extra fake smart contract.
My Contract
//SPDX-License-...
0
votes
2
answers
26
views
Sending ERC20s to a Contract on deployment
I'm trying to send an amount of ERC20 on Contract deploy to the contract itself. I'm using Hardhat and OpenZeppelin Contracts.
Contract Code:
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8....
0
votes
1
answer
17
views
How to call a function of a smart contract if I only know the address of that contract in hardhat script?
I have a factory contract which creates a child contract upon calling a createChild
function and emit an event that has the newly created child contract address. Now how to call any function of the ...
0
votes
1
answer
27
views
solidity function functionCall from openzeppelin-contracts-accounts reverted
I was calling flashLoan function using following parameters for hardhat testing
expect(
await this.pool.flashLoan(100, attacker.address, this.token.address, 0x00)
).to.be.not.reverted;
This is ...
0
votes
0
answers
9
views
Test Multi-chain interactions hardhat tets
Is there a way to spin up two separate local instances and interact with them via hardhat tests?
e.g.
let token1 = await token.deploy({network:"localhost:8545"});
let token2 = await token....
0
votes
1
answer
20
views
I am getting an error of UNSUPPORTED ENGINE while installing hardhat
Why am I not getting welcome to hardhat message?
I got it for my earlier projects
but not this one
0
votes
1
answer
61
views
Deployed contract with Remix, and trying to verify contract on Etherscan after few weeks but Bytecode doesn't match
I've been reading as much around this as possible, but cannot verify a contract which relies on openzeppelin imports, because the compiled bytecode differs from the deployed bytecode.
I deployed an ...
0
votes
0
answers
85
views
HardHat does not build artifacts when i compile the contract
I compile the contract but the json file and the debug file does not appear in the artifacts.i get this from the compiler: "Compiled 1 Solidity file successfully", i have the default hardhat ...
0
votes
1
answer
20
views
ReferenceError: greeter is not defined
Here is the script in my deploy.js:
const main = async () => {
// We get the contract to deploy
const Transactions = await hre.ethers.getContractFactory("Transactions");
const ...
0
votes
3
answers
24
views
How To Check If A Receiving Contract Emitted An Event With Ethersjs?
In the context of testing using hardhat...
The scenario: My token is transfering from owner to receiverContract. I want to check that receiverContract emitted a Received event.
The transaction looks ...
0
votes
1
answer
125
views
ethers contract call for value of state variable reverts with "missing revert data"
I am trying to obtain the value of a state variable in my smart contract declared simply as string public projectName; at the top of my smart contract, which is deployed to the Polygon Mumbai testnet.
...
1
vote
0
answers
31
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 ...
1
vote
1
answer
43
views
Is it okay to make "OpenZeppelin contracts" a dev dependency in my React app?
I am trying to reduce the bundle size of a React application. I deploy a smart contract during the project build pipeline. The contract needs to be inside the project folder of the React app so that ...
0
votes
1
answer
17
views
How to detect emit in another contract using hardhat?
I'm trying to replicate expectEvent.inTransaction() from @openzeppelin/test-helpers for hardhat.
The scenario: token is transfering from owner to receiverContract. I want to check that ...
0
votes
1
answer
79
views
How to override transactionObject `{from: xxx }` in hardhat?
I'm trying to write a test to check if an approved address can transfer the owner's token. However, whenever I try to call token.transferFrom() with a transactionObject of {from: approved.address}, it ...
0
votes
1
answer
69
views
Hardhat + Waffle + Hardhat: Nonce has already been used
This week at a talking by our friend Patrick Collins during the Chainlink Spring 2022 Hackathon schedule, I took knowledge of the possibility of moving ahead of time on the blockchain during tests:
...
0
votes
0
answers
23
views
Contract is showing undefined, while I try to interact with smart contract
I am not able to call this update Message where I am basically updating a string in the smart contract, it is showing that "contract" is not defined.
function:
const updateMessage = async (...
0
votes
1
answer
91
views
How to get the array length in ethers.js and hardhat
I have a function that pushes a value into a public array.
Now in my hardhat tests, I would like to check that before the first time calling my function, the array has a length of 0, and afterward, it'...
0
votes
1
answer
66
views
Error: Contract with a Signer cannot override from (operation="overrides.from", code=UNSUPPORTED_OPERATION, version=contracts/5.6.0)
This is the solidity function that I have written,
function jobAssignment(uint256 _jobID) external {
//Require the job to be pending
Job memory job = JobList[_jobID];
require(
...
0
votes
1
answer
31
views
MetaMask not picking Hardhat Accounts from Port 8545
I have hardhat node running on http://127.0.0.1:8545/. However, On MetaMask (in FireFox), when I select Localhost:8545 as a Test Network, the first Account is entirely different from the List of 20 ...
0
votes
1
answer
56
views
Unable to run mythril on a Hardhat project
I have a hardhat project on my local system. For running Mythril security analysis I am using the following command:
myth analyze contracts/MyFile.sol --execution-timeout 900
Receiving the following ...