87
votes
Accepted
Time-dependent tests with Hardhat?
Using Hardhat Network Helpers
The easiest way to do this is to use the time helpers in Hardhat Network Helpers.
Install them with:
npm install @nomicfoundation/hardhat-network-helpers
And then you ...
34
votes
Accepted
Difference between Ganache and Truffle
Ganache allows you to create a private Ethereum blockchain for you to run tests, execute commands, and inspect state while controlling how the chain operates. It gives you the ability to perform all ...
27
votes
Accepted
Member function "transfer" not found or not visible after argument-dependent lookup in contract?
This is due to some breaking changes in Solidity version 0.5. Namely that an address has to be marked as payable - otherwise it won't have the transfer function. More info here: https://solidity....
19
votes
Setup Ganache with Metamask. What and where is a Chain ID?
From the ganache-cli docs:
--chainId: Specify the Chain ID ganache-cli will use for eth_chainId RPC and the CHAINID opcode. For legacy reasons, the default is currently 1337 for eth_chainId RPC and 1 ...
18
votes
Truffle's Ganache VS Testrpc
Ganache is TestRPC, it is like a rebranding. The github repo for ethereumjs-testrpc now redirects to ganache-cli.
As of today 2017-12-20 if you install through npm, both npm install ethereumjs-...
13
votes
Accepted
How to get private keys on Truffle from Ganache accounts
You can start ganache with a mnemonic as a parameter ( -m 'jar boss sister abuse equal ....'). Doing this, you'll:
be guaranteed to have the same addresses generated with each run
be able to derive ...
11
votes
Time-dependent tests with Hardhat?
A new update to Ganache has added a time parameter to the evm_mine command. Now the best way to move time is
await ethers.provider.send("evm_mine", [newTimestampInSeconds]);
It is better ...
9
votes
Accepted
Solidity Exceeds block gas limit during Mocha Tests with Ganache-cli
The error message
"n: Exceeds block gas limit"
means your transaction has declared a gas value greater that the maximum allowed in the network. A client will reject such transaction.
With ganache-...
9
votes
Accepted
Attach to ganache-cli using geth
If you are running ganache at 8545:
geth attach http://127.0.0.1:8545
9
votes
Accepted
Comparison of Metamask vs Ganache
Those two products are completely different.
Metamask is a blockchain wallet (account management) that secures a private key and helps you to interact with an Ethereum Blockchain network (like ...
9
votes
UniswapV2 addLiquidity revert ds-math-sub-underflow
This also happens if the Uniswap token related to the pool has not been approved for the wallet sending the transaction.
Solution: Call the approve method of the new Pair contract with spender as ...
8
votes
Accepted
Understanding ganache timestamps
I wrote an entire article on this: Writing Accurate Time-Dependent Truffle Tests
TL;DR
The 1 second comes from run time costs, i.e. the time it takes for the javascript promises to resolve.
For ...
8
votes
Time-dependent tests with Hardhat?
const { expect } = require("chai");
const { ethers } = require('hardhat');
const sevenDays = 7 * 24 * 60 * 60;
const blockNumBefore = await ethers.provider.getBlockNumber();
const ...
8
votes
Accepted
UniswapV2 addLiquidity revert ds-math-sub-underflow
The problem was because when using UniswapV2Factory, only the precompiled UniswapV2Factory contract in the build directories from @uniswap should be deployed as stated in docs https://uniswap.org/docs/...
8
votes
Accepted
deploying smartcontract to ganache-desktop instead of ganache-cli with brownie
okay. I found the solution. I can add a local network in my network list with :
brownie networks add Ethereum ganache-local host=http://127.0.0.1:7545 chainid=5777
where ganache-local is a name i ...
7
votes
Accepted
Advantages of Infura over Ganache?
Ganache and Infura are two very different things.
Ganache is a tool for quickly creating a local network that can be used for development. It can be used to automatically run tests, etc. completely ...
7
votes
Accepted
contract.deployTransaction.wait(1) not working in ethers version 6
Changing this from ethers v5
const deploymentReceipt = await contract.deployTransaction.wait(1);
To this on ethers v6
const deploymentReceipt = await contract.deploymentTransaction().wait(1);
...
6
votes
Accepted
Is there a maximum number of public functions in a contract?
There is exactly one place in geth code where "oversized data" is thrown. It's in func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error.
Heuristic limit, reject transactions over ...
6
votes
Accepted
Want to run a local fork of Ropsten
Parity should be run in RPC mode as follows:
parity --chain ropsten --light --no-serve-light --jsonrpc-port=8545
And then the following command works to issue a fork:
ganache-cli --fork http://...
6
votes
Accepted
Difference between `0x01` and `0x1` status code?
There's no difference between 0x01 and 0x1. In hexadecimal notation 0x1, 0x01, 0x001, and so on, they all means 1. About transaction's status code, if it is set to 1 it always means a successful ...
6
votes
Accepted
Web3 server-side trouble connect with ganache
This line is wrong:
var web3 = new Web3.providers.HttpProvider('http://localhost:7545');
You're instantiating a provider instead of instantiating Web3. It should be this:
var web3 = new Web3(new ...
6
votes
Can we see events in ganache?
Update 2020
Events are now available in the 2.1.0 release.
Original Answer
It is not currently possible, but is on the roadmap.
6
votes
Difference between Ganache and Truffle
Truffle is a development environment, testing framework and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier. With Truffle, you get: Built-in smart contract compilation,...
6
votes
Truffle and Ganache - do I need to set the same gas-price and gas-limit in both of them?
TL;DR: Yes you can use the same value.
Here is why:
Ganache
Ganache is a local test Blockchain.
-l or --gasLimit is the block gas limit (total amount in gas unit that can fit in a block). Let's ...
6
votes
Increase block number on Ganache
In addition to goodvibration's answer, OpenZeppelin recently released their openzeppelin-test-helpers package. This library contains all kinds of helpers for testing smart contracts, including methods ...
6
votes
Accepted
How to increase the number of test accounts?
Ganache and Ganache CLI
With ganache-cli you can do this with the --accounts flag. For example:
ganache-cli --accounts=100
Ganache (the desktop application) comes with 100 accounts by default.
...
6
votes
Time-dependent tests with Hardhat?
For any future wanderers:
Hardhat added a network-helpers library with convenient JS interface:
https://hardhat.org/hardhat-network-helpers/docs/overview
https://www.npmjs.com/package/@...
6
votes
The endpoint returned a different chain ID: 0x539 (Ganache)
You either need to update your custom MetaMask Network to match the default chainId returned by Ganache (which is 1337) or, if you are using ganache-cli use a command like ganache-cli --port 7545 --...
6
votes
Explorer for Private Blockchain with Ganache
Ethernal (https://tryethernal.com/) is an open-source block explorer for private EVM-based chains. You'll have the same feature as Etherscan or Ganache UI but you can connect it to any chain.
(I am ...
6
votes
Error: chainId address mismatch
i found the answer i have been struggling with this for a week!
i just changed the Network Id in the ganache to 1337! and it got through!!! Awesome!
you can use this code instead to get the chainId ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
ganache × 643truffle × 228
solidity × 203
web3js × 126
metamask × 65
remix × 56
ganache-cli × 47
blockchain × 44
go-ethereum × 43
web3.py × 37
truffle-migration × 34
contract-development × 33
javascript × 29
contract-deployment × 27
testing × 27
nodejs × 24
truffle-test × 23
brownie × 23
testrpc × 21
truffle-contract × 18
dapps × 17
ethereumjs × 17
transactions × 15
private-blockchain × 14
ethereum-wallet-dapp × 14