New answers tagged

0 votes
Accepted

HardhatError: HH700: Artifact for contract not found

since you named your contract 'Btc' the name should be sync on your getContractFactory as well. on your Dogecoin.sol don't use: contract Btc is ERC20, Ownable { ... instead use: contract Dogecoin is ...
user avatar
0 votes

Im trying to deploy contract on Polygon Mumbai but cant

Found the solution. If your deploy script's (in hardhat-deploy atleast) gas limit is higher than the network's block gas limit then you will receive that error.
user avatar
0 votes

Get interfaceId from interface in ethers js or hardhat

I made a simple app with the objective of making this easier, https://interfaceid.lucasgrasso.com.ar/ , you just have to paste the interface ABI, hope its useful!
user avatar
  • 1
0 votes

Error: Hydration failed because the initial UI does not match what was rendered on the server, Wagmi and Nextjs

If you set autoConnect: to false it should resolve your issue.
user avatar
  • 1
1 vote

Hardhat get last block timestamp, block number, block hash, nonce, gas limit, gas used

To answer: how can I use it to get the last block timestamp? And adding to the previous answer to get the timestamp just read the property from the returned block information: const timeStamp = (...
user avatar
  • 1,224
0 votes

Automated gas cost calculation in Hardhat?

I would suggest Remix IDE for such aim. It provides rich UI to compile, deploy and run the contract. In console it publish relevant information from EVM including gas cost on deploy and transaction.
user avatar
  • 269
2 votes
Accepted

Why isn't ether value not showing in etherscan transaction?

In Withdraw() actually 0.55 eth is sent to your wallet. You can click on transaction or click here to see it. But why in this screenshot it is not shown? Lets understand step by step. First Lets ...
user avatar
0 votes

Testing for emitted events in Hardhat

You can pass a function as the argument to capture the event arguments. let capturedValue const captureValue = (value) => { capturedValue = value return true } await expect(eventEmitter....
user avatar
1 vote

msg.sender.call{value: 0.1 ether, gas: 1}(""): Why it doesn't fail? Shouldn't?

Please send the value slightly greater than 0.1 ether and also you have ff.deploy where it should be FF.deploy and please use assert statements to make sure it behaves as you wish.
user avatar
0 votes

msg.sender.call{value: 0.1 ether, gas: 1}(""): Why it doesn't fail? Shouldn't?

it("Should fail", async function () { const FF = await ethers.getContractFactory("MyContract"); const _f = await FF.deploy({ value: utils.parseEther("0.1")...
user avatar
  • 156
1 vote

trasnsaction not confirmed forever at polygon mumbai

Polygon (and mumbai) apparently have a min gas fee now: https://thedefiant.io/polygon-transaction-fee-hike Raise it up and you should be good
user avatar
  • 3,437
0 votes

How to mock smart contract function for testing (in hardhat)

Try out the smock hardhat contracts mocking library.
user avatar
  • 131
0 votes
Accepted

How to verify in PolygonScan correctly?

As Mikko suggested I used HardHat to deploy and verify my contract and was correct. I follow the next Polygon reference: https://docs.polygon.technology/docs/develop/hardhat/ The last step was the ...
user avatar
0 votes

Add a 'from' account to hardhat transaction calls

Identical issue is resolved in this answer here on official etherjs github repo. NOTE: By default, first account (i.e, signer at 0 index) from the list of accounts returned by ethers.getSigners method ...
user avatar
1 vote

How to verify in PolygonScan correctly?

Without having full access to your computer, it is not possible to tell what you are doing wrong. If you use a smart contract development framework like Brownie or Hardhat to develop your smart ...
user avatar
0 votes

Contract Deployment "not enough funds for gas" Arbitrum

Arbitrum has a different way to compute gas cost, see here https://developer.offchainlabs.com/docs/Differences_Overview#fee-stats In particular, calldata is more expensive than L1, and this explains ...
user avatar
  • 578
1 vote

What is the difference between getSigners and getNamedAccounts?

If I write getNamedAccounts instead of getSigners in my code, the code won't run ? Because you are using named accounts.. thats why getNamedaccounts result in error.. Check your hardhat.config , ...
user avatar
  • 151
1 vote

How to get contract's ether balance at hardhat / waffle

Updated 2022 contractFactory = await ethers.getContractFactory("MySmartContract"); contract = await contractFactory.deploy(); await contract.deployed(); const contractBalance = await ...
user avatar
0 votes

"yarn hardhat run scripts/propose.ts --network localhost" - Console.log not working?

You are calling the Propose function inside the propose function.. so it does not call any function while you running your script.. Propose.then.catch should be outside the function, so it can be ...
user avatar
  • 151
2 votes

ERC777 upgradeable deployment error: cannot estimate gas; transaction may fail or may require manual gas limit hardhat

I had the same problem and I tried to use "hardhat-erc1820", but it didn't work well, so I changed it a little and it worked,here is my code , This is a full deployment of ERC1820 and ERC777 ...
user avatar
0 votes

Contract Deployment "not enough funds for gas" Arbitrum

I had to increase the gas limit to 100mil and it took 80 mil to deploy. I am not sure why similar transaction only took 5mil on kovan and Arbitrum testnet
user avatar
1 vote

Is it possible to log how much gas was used during hardhat/ethers transaction?

I use this code const txReceipt = await provider.getTransactionReceipt(txArbitrage.hash); console.log(txArbitrage.hash); const effGasPrice = txReceipt.effectiveGasPrice; ...
user avatar
4 votes
Accepted

What is the difference between getSigners and getNamedAccounts?

getSigners and getNamedAccounts are both used for the same purpose, getting public key for accounts. Since you asked for getNamedAccounts I assume you are developing on a hardhat environment because ...
user avatar
  • 83
1 vote

Is it possible to log how much gas was used during hardhat/ethers transaction?

myBigNumber.mul() method of the BigNumber is the way to do multiplication ideally: const trans = await myContract.withdraw(myAddress, amount) const receipt = await trans.wait() const gasCostForTxn = ...
user avatar
2 votes
Accepted

Modify storage in Ganache or Hardhat Network?

You can use hardhat_setStorageAt: await ethers.provider.send("hardhat_setStorageAt", [contractAddress, storageSlot, newValue]) See examples at https://github.com/mixbytes/hardhat-modify-...
user avatar
0 votes

Getting error in modifier while compiling. DeclarationError: Identifier not found or not unique

It looks like you are not inheriting IERC721Receiver into your contract Try this: contract ERC721 is IERC721, IERC721Metadata, IERC721Receiver { (If this still doesn't work, then please share your ...
user avatar
  • 177
0 votes

"Cannot read property 'utils' of undefined" on web3.utils

Are you sure that you are importing from the correct library? I think it should be this instead: import web3 from "web3"
user avatar
1 vote
Accepted

Call child contract functions from outside

First, you may want to define the ercContract variable as public. You can read this thread to learn more about visibility for storage variables: Solidity: private vs public variables. Second, you ...
user avatar
0 votes

Run a single hardhat test file

$ yarn hardhat test ./test/ContratA.test.js Should work as the command line helper message explains: $ yarn hardhat test --help Usage: hardhat [GLOBAL OPTIONS] test [--bail] [--deploy-fixture] [-...
user avatar
0 votes

How do you set max amount of NFTs a wallet can mint?

you should use function 'balanceOf' or 'balances' state variable. (they return The number of NFTs owned by an address). contract xyz is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable { using ...
user avatar
0 votes

How do you set max amount of NFTs a wallet can mint?

contract xyz is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; uint256 public constant maxSupply ...
user avatar
0 votes

TypeError: Cannot read properties 'toString')

The error log means that chainId is undefined. When you run the deploy script, you can specify which network config you want to use, it usually defines inside hardhat.config.js (see documentation). ...
user avatar
0 votes

Is it possible to log how much gas was used during hardhat/ethers transaction?

@kornelHub answer works except you might need to pay attention to the property of gas used. There are two properties explain the used gas amount, one is gasUsed, and another is cumulativeGasUsed, as ...
user avatar
0 votes

Chainlink Keepers - getting "InvalidConsumer"

as done manually for testnet (Look into https://youtu.be/rdJ5d8j1RCg by chainlink) , we have to create a VRFCoordinatorV2 (VRFCoordinatorV2Mock in case of local testing), fund it and then have to add ...
user avatar
0 votes

CALL_EXCEPTION when calling a simple view function with ethers.js, but not in my hardhat test

Hii even I ran out in the same issue...The problem with me was My metamask was connected to another network. I switched to hardhat network in metamask it worked.
user avatar
0 votes

Run aave test suite locally on ganache [Change network hardhat to ganache]

Option 1 If you don't want to manually start and stop Ganache every time, you can use the hardhat-ganache plugin. This plugin creates a network called ganache, and automatically starts and stops ...
user avatar
  • 1,224
1 vote
Accepted

Polygon Mumbai Testnet Not Working

The issue can be Linked to either : 1- the RPC url 2- the provider 3- THE WALLET ADDRESS, this has happened to me on the mumbai testnet alot and to solve it, i switched the wallet address to a brand ...
user avatar
1 vote

Polygon Mumbai Testnet Not Working

The Mumbai testnet is running and processing transactions as evidenced eg by the explorer. If you have an endpoint issue, I suggest trying a different provider. e.g. Chainstack.
user avatar
  • 121
1 vote

Chainlink Keepers - getting "InvalidConsumer"

I had this issue as well and the solution for me was..edit your deploy-raffle js using the following steps 1 make the the variable that holds "VRFCoordinatorV2Mock" contract a global ...
user avatar
  • 11
0 votes

How to check if a token was approved?

in DAI contract Check Approval from allowence read function. In first (address) put Owner address (your address) In second (address) put Spender address (Uniswap Address). Put address of spender, as ...
user avatar
0 votes

How to check if a token was approved?

I solved this problem. I didn't need to make the first transfer from Uniswap V3 example , because I already had DAI ready to spend. // TransferHelper.safeTransferFrom( // DAI, // ...
user avatar
0 votes

How to check if a token was approved?

DAI's smart contract emits an Approval event and returns true if the transaction is approved. function approve(address usr, uint wad) external returns (bool) { allowance[msg.sender][usr] = wad;...
user avatar
  • 1
0 votes

Using hardhat with Windows

When I run npm install --save-dev hardhat I also get a peer dependency issue. Anyone able to solve the issue? Conflicting peer dependency: @nomiclabs/hardhat-ethers@2.1.0 npm ERR! node_modules/@...
user avatar
0 votes

hardhat deploy with specific account

Can you try this? [theDefaultDeployer, acc1] = await ethers.getSigners(); // we will not use the "theDetaultDeployer" in what follows: const MyContract = await ethers.getContractFactory(&...
user avatar
0 votes

Run a single hardhat test file

yes you can do that. You just need to put ".only" after that describe, that you want to run. In your case: const { expect } = require("chai"); describe.only("ContractA tests&...
user avatar
0 votes

Chainlink Keepers - getting "InvalidConsumer"

I have the exact same issue. After debugging the code, I found we have to add the Raffle contract's address to VRFCoordinatorV2Mock's consumers by add the following code to your deploy file (for me it ...
user avatar
  • 1
0 votes

How can I enable the logging in smart contract?

If you take a look at the console.sol on Github,you will notice that it has an address hardcoded (0x000000000000000000636F6e736F6c652e6c6f67) where it will send the logged data. That hardcoded address ...
user avatar
0 votes

HH100 : Network rinkebey doesnt exists

rinkeby is spelled wrong in your config file
user avatar
  • 3,437
0 votes

Cannot interact with deployed contract - negative hex string

try to add below code after .deploy() call: await contract.deployed(); for example: const FirstContract = await ethers.getContractFactory("FirstContract"); const firstContract = await ...
user avatar
  • 66
1 vote

How can I create the typechain directory in my hardhat project?

try to re-initial your hardhat project and use the default typescript template. please vote me up if it's useful :)
user avatar
  • 66

Top 50 recent answers are included