Questions tagged [hardhat]
The hardhat tag has no usage guidance.
1,297
questions
0
votes
0
answers
7
views
Javascript FundMe Solidity Test code troubleshooting
Code 1 returns error while Code 2 doesn't, why?
CODE 1
const { assert, expect } = require("chai")
const { ethers } = require("hardhat")
describe("FundMe", function () {
...
0
votes
1
answer
8
views
How to advance blocks in a Hardhat test that uses block.timestamp?
I have this code for a Voting smart contract test:
it("Should return true if end time is less than the current timestamp", async function () {
const { votingSmartContract } = await ...
0
votes
0
answers
9
views
My test isn't working and I'm having a lot of issue
const { expect } = require('chai');
const { ethers } = require('hardhat');
const tokens = (n) => {
return ethers.parseUnits(n.toString(), 'ether')
}
describe('Token', ()=> {
let token, ...
0
votes
0
answers
4
views
Data Fetching from an Aave subgraph
Hi guys I am writing a dApp which deals with liquidations flash loans etc,
The 1st step of development is to receive the user addresses who have borrowed more than zero from 'The Graph'
I use hardhat....
0
votes
1
answer
20
views
Is it possible to run a validator node on a forked net?
As the question says - is it possible to fork mainnet with hardhat and run/setup a validator node on the fork? There are some things I'd like to try out before testing it on testnet (I don't even have ...
0
votes
1
answer
16
views
typeError: Cannot read properties of undefined (reading 'format')
I am getting this error whenever I run my hardhat deploy script for uniswap pool contract :
TypeError: Cannot read properties of undefined (reading 'format')
at Function.from (/home/abdulaleem/token/...
0
votes
0
answers
10
views
ethers.utils.solidityKeccak256 in hardhat test file
Here is a test file.
ethers.getSigners() works fine
ethers.deployContract() works fine
for some reason, ethers.utils.solidityKeccak256 keeps breaking the code with this error:
'
TypeError: Cannot read ...
1
vote
0
answers
26
views
Foundry or Hardhat: I'm really confused about which one should I use?
Hello everyone
I'm new in the smart contract and Dapp development and I'm so confused about choosing a framework. my questions are dumb but I couldn't find the answers by myself. Here is my problem:
I ...
0
votes
0
answers
9
views
How Remix IDE compiles smart contract code to ABI and bytecode?
I am building a DApp where user uploads his smart contract code file and his smart contract gets deployed using his private key ( After he connects his metamask account to the DApp ) . How RemixIDE is ...
0
votes
0
answers
12
views
Gas reporter does not report gas usage for low level calls
I am using npx hardhat test command to get the gas usages analysis. My configuration to get the report is like below. In my tests. I have tests for deployment, functions calls, but also some other ...
0
votes
0
answers
31
views
Swap functions seems to not swap?
I have deployed a smart contract on a local network and I am trying to do swaps from a metamask account. I have allocated a quantity of tokens to the smart contract so it can use it using the approve ...
0
votes
0
answers
4
views
How to put .opezeppelin folder at desired directory in hardhat?
I am using Openzeppelin upgradable with hardhat. By default the plugin store .openzeppelin folder at root but I have running multiple environments so would like to set .openzeppelin folder at the ...
1
vote
0
answers
24
views
How to I solve fetch has been blocked by CORS policy when fetch data from contract
I'm trying to fetch campaign data and display it to the user. I'm using Nextjs in the front-end and solidity & hardhat in the back-end. The contract data seems to be fetched but when being ...
0
votes
0
answers
100
views
unsupported addressable value (argument="target") - [email protected] and @openzeppelin/[email protected]
When I create an OpenZeppelin ERC721 Smart Contract using OpenZeppelins Smart Contract wizard builder, I get an error when trying to deploy the smart contract to my local network using hardhat. I have ...
0
votes
1
answer
28
views
Unknown key "viaIR"
Unknown key "viaIR"
Error HH600: Compilation failed
I'm encountering the above error when I try to compile.
Here is my hardhat.config.ts
import { HardhatUserConfig } from "hardhat/...
0
votes
0
answers
29
views
Getting error when I trying to test my contract
I started coding project and I got error when trying to test him.
When I trying to call some contract function from js tester i got error:
Error: call revert exception [ See: https://links.ethers.org/...
0
votes
0
answers
18
views
How to run a hardhat node in the cloud
I have a set of tests i run locally using hardhat and mocha. However, I would like to run these tests on every push to prod. How can I start a hardhat node in the cloud for the testing.
0
votes
0
answers
34
views
Hardhat MetaMask Error: Transaction decoding is not available for chainId 31337
I created a Real-Estate Decentralized Contract and connected it with Vite-React using ethers.js.
I'm using Meta Mask and HardHat local network for Hardhat free Ether. I import 5 wallets of Hardhat to ...
0
votes
1
answer
19
views
Cannot read properties of null (reading 'constructor') Etherjs error
I am trying to interact with a deployed contract at Sepolia in a hardhat test. Here's how I do it:
const provider= new ethers.providers.JsonRpcProvider(process.env.ALCHEMY_API_KEY);
const ...
0
votes
1
answer
13
views
How do I obtain a signer object from a named account address in a Hardhat project?
In my Hardhat project, I'm using the hardhat-deploy plugin to manage named accounts, and I need to obtain signer objects associated with these named account addresses to interact with my smart ...
1
vote
0
answers
85
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;
...
0
votes
1
answer
29
views
How to run the hardhat fork in the separate terminal?
I want to interact with the contracts in the mainnet, i used hardhat fork to fork the arbitrum mainnet, forking is done but after that my contracts getting deployed according to the script and the ...
0
votes
0
answers
21
views
how to access to a public mapping from test script
i'm in hardhat
i'v this public mapping
mapping (address user => uint[] commentIds) public userComments;
and i'm trying to call it inside my test Script
console.log(`user1 comments: ${...
0
votes
0
answers
7
views
How to fix `str is undefined` nft dapp upload picture problem?
I'm trying to do an example in a tutorial, I tried to run this, but I get an error that "Upload errorTypeError: str is undefined". How can I solve this?
I tried: -> deleting artifacts and ...
0
votes
1
answer
54
views
Error while deploying on sepolia network
hardhat.config.js ->
require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-ethers");
require("dotenv").config();
console.log("1");
...
0
votes
1
answer
36
views
Error deploying contracts: Error: incorrect number of arguments to constructor at ContractFactory.getDeployTransaction
const hre = require("hardhat");
// async function main(){
// const RPSLS = await hre.ethers.getContractFactory("RPSLS");
// const RPSLSF = await RPSLS.deploy();
// await ...
0
votes
1
answer
5
views
How to Ensure TypeScript Type-Checking in a Hardhat Project Before Execution?
I'm working on a Hardhat project with TypeScript enabled. Currently, I can run my TypeScript scripts even if there are type errors, presumably due to the use of ts-node. I would like to enforce type ...
1
vote
1
answer
53
views
How to deploy a Safe on Hardhat
I am developing a Safe Module and would like to use Hardhat to test it. However, I have been so far unable to deploy a Safe using Hardhat. Does anyone have experience doing this? Even when I set my ...
0
votes
0
answers
140
views
"Error happened while trying to execute a function inside a smart contract" after trying to call smart contract function with fork ethereum chain
I am forking Ethereum blockchain using Alchemy's api. Below is my chain config
module.exports = {
solidity:
{
compilers :[
{version : "0.8.17"},
{version: "0.8.4"}...
0
votes
1
answer
18
views
Error HH8: There's one or more errors in your config file: * Invalid account: #0 for network: sepolia - private key too short, expected 32 bytes
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
require('dotenv').config();
const {API_URL, PRIVATE_KEY} = process.env;
const ...
0
votes
1
answer
24
views
When deploying a contract on a custom blockchain using hardhat, i get BroadcastedTxDifferentHash error?
I am trying to deploy a contract to a custom EVM chain using hardhat and i get the following error
BroadcastedTxDifferentHash: Expected broadcasted transaction to have hash '...
0
votes
2
answers
35
views
Failing to deploy any Contract
I am unable to deploy any contract, including the example contract shown below:
// contracts/Box.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
// Import Ownable from the OpenZeppelin ...
0
votes
1
answer
33
views
I have problem with deploying my token to Goerli testnet
I have an issue with deploying smart contract on Goerli network.
When I trying to run the contract I get Error
Error HH100: Network goerli doesn't exist
Here is example of my code
// SPDX-License-...
0
votes
1
answer
51
views
hardhat ethers.provider.listAccounts()
This JavaScript test code is from a course I'm undertaking:
before(async () => {
const Collectible = await ethers.getContractFactory("Collectible");
collectible = await ...
0
votes
1
answer
22
views
whitelist contract's address showing undefined without showing any error message
I am following this tutorial here to learn developing whitelist contract. My node verion is 18.12.1 and testnet is sepolia. I am currently on windows11 OS.
whitelist.sol:
//SPDX-License-Identifier: ...
0
votes
1
answer
37
views
Cant make conection with my Smart Contract using web3
I cant get my contract instance using web3 . I am making todo app using web3 . I cant get my contract instance in js file . I am new to web3 development and everyday I am trying my best improve my ...
1
vote
1
answer
18
views
Does geth or parity in development chain mode support methods like hardhat_setSorageAt or is there a way to manipulate EOA?
I wan’t to create more sustainable test network for my develop project. Hardhat node gets slowed down with the time and even crashes.
I am wondering is there a modified geth rpc client supporting some ...
0
votes
0
answers
16
views
Installing hardhat on an Amzon EC2 instance or on any live server
I want to deploy and maintain contracts from an ec2 instance, didn't choose lambda for time constraints reasons.
I could translate everything to ethers js except contract verification which proves a ...
0
votes
0
answers
5
views
Pool Prices Not Updating in Forked Hardhat Mainnet
Why do pool prices remain static in my forked Hardhat mainnet environment during swaps? What steps can I take to troubleshoot and ensure that pool prices accurately reflect the expected changes in ...
0
votes
1
answer
31
views
Send Function is not working in test file using ethers.js
I write a wallet smart contract in which one address can send ethers to other addresses. I'm using the HardHat framework and this package. when i use await addr1.sendTransaction( {to: addr2, value: ...
0
votes
1
answer
71
views
HardhatError: HH700: Artifact for contract "Lock" not found
If I run yarn hardhat test. I'm getting this error:
yarn run v1.22.19
warning ../../../package.json: No license field
$ /Users/deepak/Desktop/Etherium/hardhat-fund-me-fcc/node_modules/.bin/hardhat ...
0
votes
0
answers
20
views
before each" hook for "sets the aggregator addresses correctly": TypeError: (0 , ethers_1.getAddress) is not a function
I am getting TypeError: (0 , ethers_1.getAddress) is not a function when i run yarn hardhat test on the first part of unit testing
here is FundMe.tets.js
const { deployments, ethers, getNamedAccounts ...
0
votes
1
answer
57
views
NFT transfer to a contract in ERC1155 standard
NFTS transfer from minter to contract isn't working, below is the detailed problem.
NFT.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;
import {ERC1155} from "@openzeppelin/...
0
votes
0
answers
18
views
eth_estimateGas calling random function
I'm testing my Ethereum smart contract with Hardhat and Metamask. In Metamask if I try to send zero tokens it reverts, as expected (the transfer function reverts if token amount is zero).
If I look at ...
1
vote
2
answers
277
views
Calling smart contract function from frontend is not working
I've created a twitter profile contract and a function called
contract Twitter {
//Struct for user profile
struct Profile {
string name;
string username;
string bio;
...
1
vote
1
answer
21
views
Property 'zkUpgrades' does not exist on type 'HardhatRuntimeEnvironment'.ts(2339)
I have a test file for testing an upgradable smart contract on zkSync by looking at the docs here. I'm getting a typescript error on this line
await hre.zkUpgrades.deployProxy(deployer.zkWallet, ...
0
votes
1
answer
17
views
Hardhat deploy same contract to multiple addresses fails
I need to deploy the same contract to multiple wallets and I have this shell script.
#!/bin/bash
set -x
contractName=MyContract
network=sepolia
npm cache clean --force
yarn hardhat clean
yarn hardhat ...
0
votes
0
answers
12
views
Good extensions for both Foundry & Hardhat
Hello i'am looking for good vscode extension for both foundry & hardhat. Thank you for your feedback !
0
votes
1
answer
73
views
TypeError: ethers.provider.getStorageAt is not a function
I have deployed the contract and I'm trying to get the address at each storage slot
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
...
0
votes
1
answer
35
views
How to properly test my flashloan bot
I am building a simple flashloan bot as shown below:
Flashloan from Aave -> lend it on Lending protocol A -> Borrow tokens from protocol A -> Lend borrowed to protocol B -> Borrow from ...