New answers tagged hardhat
1
vote
Insufficient Liquidity after adding liquidity on Sepolia Uniswap V2
I didn't think the front end was connected to the smart contracts on the test net. You can still use the router to test, just swap via the explorer:
-
https://scrollscan.com/address/...
0
votes
Hardhat doesn't recognize custom errors from inherited Contracts
The message is thrown at chai-matchers validation and it means, that the expected error is not found in the contracts interface:
https://github.com/NomicFoundation/hardhat/blob/...
1
vote
Accepted
Insufficient Allowance ERC20 when adding liquidity to Uniswap V2 Pool
The error is quite clear, you'll need to approve the contract before calling a transferFrom function.
So before you call the addLiquidity function (which has the call to transferFrom), add this line.
...
0
votes
hardhat verify ConnectTimeoutError: Connect Timeout Error
I have solved this issue by setting mocha timeout in hardhat.config.js
module.exports = {
...
mocha: {
timeout: 100000000 // or any time value that suits your project
},
...
}
0
votes
Why the method _castToPure in hardhat/console.sol can convert a view method to a pure one?
This function is called to avoid having solc throwing when trying to cast a view function into a pure one (doing it in assembly bypass the compiler check)
Without the assembly block (ie just assigning ...
0
votes
Hardhat is not generating private keys when I run `npx hardhat node`
i tweaked the node_modules and found this
at node_modules/hardhat/src/builtin-tasks/node.ts
there is check that to output the private keys only if you have the default configuration in your hardhat....
0
votes
How to get the ETH balance after calling getSigners()
To get the balance of WETH token on the Arbitrum network, you can call the balanceOf() function of the corresponding token contract:
const { ethers } = require("ethers");
const provider = ...
1
vote
how to access to a public mapping from test script
If you are accessing a mapping that is some type to an array type, you need to pass the array index that you'd like to access as well.
For example: access first element in the returned list
console....
-1
votes
Are the Hardhat provided accounts' public keys as accessible as their private keys?
import { call } from '@wagmi/core'
import { config } from './config'
await call(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
to: ...
0
votes
How to check if a token was approved?
Had similar issue when I met error STF despite the approve going through beforehand.
Turns out I forgot to parse the amountIn with the correct number of decimal as DAI and other stable coin have only ...
0
votes
Large price discrepancy between swapExactTokensForTokens and official swap
The price you get depends on the available liquidity and path.
It is likely that your code and Hardhat fork took a different path, or does not have direct liquidity available, different what Quickswap ...
2
votes
Accepted
Why dynamic arrays seem to be empty when they are part of an event?
The indexed parameters of events are not stored directly in the event logs. Instead, the Keccak-256 hashes of these parameters are stored. This is particularly relevant for dynamic types like arrays.
...
0
votes
Accepted
Hardhat Errors: Invalid value null supplied to : QUANTITY
I commented out the forking url that I had pasted in the Hardhat.config.ts file.
The test cases run easily.
Looks like the mainnet rpc url used in forking was not working at times
0
votes
Accepted
Hardhat: Get contract address and pass as param to another contract to deploy
Hardhat Ignition doesn't seem to provide a way (yet) to retrieve the contract addresses directly after deployment, particularly because it creates Future artifacts corresponding to the contracts ...
1
vote
How is hardhat a dev dependency?
Installing Hardhat as a dev dependency means that it’s only required for development purposes, such as compiling, testing, and deploying contracts.
Once the development process is complete and you ...
0
votes
Error: Transaction reverted: function selector was not recognized and there's no fallback nor receive function
Update the smart contract address after deployment in your tests. It seems like the contract address is hardcoded.
0
votes
Accepted
Full node on sepolia
As far as I have experienced you will need a consensus client, as execution client will only start syncing when it connects to a beacon node and will need to be synced before you can compute the ...
0
votes
Reading Events from Implementation contract
The test case is actually failing when tested using to.emit() in Hardhat test.
However, when you check the logs, you can find the event being emitted from the proxy contract function call (i.e., ...
0
votes
I can't verify a proxy contract on polygon amoy testnet with Hardhat
I would take another look at the hardhat-oklink-verify plugin docs.
In your hardhat.config.js, you should rename etherscan to oklink.
Also you should use the oklink-verify command like in this example:...
0
votes
evm_increaseTime in hardhat
hre.ethers.provider.send("evm_increaseTime", [864005]); //replace 864005 with the time in seconds you wish to increase.
1
vote
Unable to verify contracts on polygon Amoy testnet
I've asked regarding this issue on OKLink Discord channel, and they've responded.
So, the correct configuration to be used in the hardhat.config.js would be:
etherscan: {
apiKey: {
...
0
votes
HardhatError: HH101: Hardhat was set to use chain id 11155111, but connected to a chain with id 1
Make sure to use the right RPC url for your sepolia network. For example, An Ethereum mainnet rpc URL from alchemy is not going to work on the sepolia network.
I encountered this issue too but I ...
1
vote
ethers.utils.solidityKeccak256 in hardhat test file
If you are on ethers v6, try this:
const message = ethers.solidityPackedKeccak256(
['address', 'bytes32', 'uint256'],
[userAddr, nonce, ammount]
);
2
votes
Accepted
Execution Reverted due to UniswapV2-Pair creation in constructor
The UniswapV2Router02 address you're using is not available for the Sepolia testnet. Instead, the corresponding address for the Sepolia testnet is
0xC532a74256D3Db42D0Bf7a0400fEFDbad7694008.
...
0
votes
How do I get Wagmi useWaitForTransaction to wait for Metamask (running on Hardhat)?
Try to increase the confirmation blocks, I don't figure out yet how to sync them with the metamask ones, but go around 3 blocks.
const { data: approveTx, isError, isLoading } = useWaitForTransaction({
...
0
votes
Unable to verify contracts on polygon Amoy testnet
You'd need to implementation with a combination of these two resources:
https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify#adding-support-for-other-networks
https://www.oklink....
0
votes
Hardhat Tasks - How to import an account with a private key as signer
Update your hardhat.config.js
module.exports = {
...
networks: {
sepolia: {
url: "https://sepolia.infura.io/v3/<key>",
accounts: [private_key, private_key,...] // ...
0
votes
Contract deployed to address: undefined. How do I find the contract address after deployment?
Maybe you are using ethers V6, in that case you need to change .address to .target to make it work:
genTest1.address
becomes:
genTest1.target
0
votes
Accepted
uniswapRouter.getAmountsOut returns less value of token B than present in reverses when provide full amounts of token A
That's just how math works.
Let's call the reserves values x and y. In your example
x = 36851089197799104779745113323n
y = 281312509765248795074n
Before and after the swap, the value of their product ...
0
votes
uniswapRouter.getAmountsOut returns less value of token B than present in reverses when provide full amounts of token A
It seems like there might be a misunderstanding of how the getAmountsOut() function works in Uniswap.
Let's break down the code and clarify the behavior:
getReserves() -> retrieves the current ...
Top 50 recent answers are included
Related Tags
hardhat × 1378solidity × 632
ethers.js × 347
hardhat-deploy × 212
testing × 156
javascript × 96
contract-deployment × 76
chai × 71
contract-development × 60
blockchain × 60
ether × 49
openzeppelin × 48
unittesting × 48
web3js × 46
test × 43
uniswap × 41
erc-20 × 40
typescript × 38
etherscan × 34
mocha × 34
nft × 33
ethereumjs × 32
metamask × 31
polygon × 31
chainlink × 29