14 votes

How can I take a snapshot of Ganache or Truffle Develop state and reload later?

This can be done with the ganache-cli db command. For example, to run a setup similar to the GUI client, I do ganache-cli --db="./data/save/" -i="5777" -d --mnemonic="YOUR_12_WORDS_HERE" Which will ...
  • 795
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 ...
7 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 ...
  • 295
6 votes

Is there a way to retrieve private key of ganache account with web3?

You cannot get the private key from web3.eth.getAccounts() directly, but there's a few workarounds to do this with ganache: Specify a mnemonic phrase with the -m option, e.g. ganache-cli -m "...
  • 5,207
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
Accepted

How does the ganache-cli --fork work?

It relies on an external source (fork from) for pre-fork information and then relies on its own block producer and append new blocks after the fork. It will continue to rely on the external source for ...
  • 52.4k
5 votes

How does the ganache-cli --fork work?

Ganache fork allows to rely on an external source to get past chain state. This allows to query necessary data, and only that. Think of it more as a light client. When the fork is created, it means ...
4 votes
Accepted

Why do my events not emit the correct value?

The reason is because what is being emitted is an indexed dynamic variable, not static. Solidity stores a keccak256-hash when indexing a dynamic variable, so the string you are getting, 0xb6e... is ...
4 votes

How do I specify the network ID in the config file when migrating/testing contracts on my local ganache?

You can set the ganache-cli network ID by using a flag when running it: ganache-cli --networkId 4447
4 votes
Accepted

Dockerized Ganache-cli + HdWallet Provider?

Thank you for referring the ganache comment, It seems to work fine for you now with adding the port with the container's name ganache:8545 to further refer this URL. As per forwarding rules defined ...
  • 258
4 votes

How to fork the binance chain?

it's seems ganache-cli suport forking bsc network. ganache-cli -f https://bsc-dataseed.binance.org https://www.reddit.com/r/ethdev/comments/nih0zx/how_to_fork_bsc_mainet/gz3vhex?utm_source=share&...
4 votes
Accepted

TypeError: this._deployData.startsWith is not a function

I think you are not passing in your bytecode right. You are missing the bytecode object - compiledFactory.evm.bytecode.object. So it should look like this: factory = await new web3.eth.Contract(...
  • 156
3 votes
Accepted

revert ERC20: transfer amount exceeds balance

you right, I just use wrong address (credentials) of sender (that have empty balance). Thanks for answers!
  • 83
3 votes
Accepted

Creating workspace kind in ganache-cli

Ganache is a development and testing framework - fast and easy to set up and fast transaction blocks. Generally, it is preferable to start with an empty blockchain and rehearse the migration and ...
  • 52.4k
3 votes
Accepted

Difference between Puppeth and Ganache

TL;DR - Ganache and Puppeth are both tools to spin up your own blockchain. Ganache is meant to be used as a testbed where transactions can be created and contracts can be deployed freely and ...
3 votes
Accepted

Truffle ganache fork

Yes, the transactions mined inside block 11267664 are included in your fork. The word "from" in the ganache implies that this block is mined and then the fork happens: You can optionally ...
2 votes
Accepted

Can't deploy contract with web3.js and ganache-cli

Found the answer. It turns out that the web3 options aren't exactly optional for Ganache: I had to change: const provider = ganache.provider() const web3 = new Web3(provider); To: const provider ...
2 votes
Accepted

Store/retrieve data doesn't work using node

This is all wrong: var result = await contractDeployed.methods.getOwner().call(); console.log('\tgetOwner: ' + result); // Works contractDeployed.methods.setTestData('testing store ...
2 votes
Accepted

Connecting to a blockchain started with ganache-cli with Ganache GUI

You are getting the error because both the applications cannot use the same port. You have to kill the cli process to use the Ganache GUI in the same port. But this would mean you will loose the data ...
  • 1,179
2 votes

How to test chain reorganization with testrpc?

I don't know of a way to accomplish that with TestRPC. There might be a better way than described below. I think I would make a private chain with Geth and low-difficulty/fast blocks in the genesis ...
  • 52.4k
2 votes
Accepted

How to persist ganache-cli data when run from within a docker container

There are multiple solutions for you. Use docker's -v option to mount the volume for storing the ganache-cli db outside of the container, so it can survive the restart. Use ganache-cli --mnemonic ...
  • 7,224
2 votes
Accepted

Ganache-cli Fork unlocked account to make transactions

You need to specify the "from" sender account. If you're trying to make a contract interaction (functional call), then you want something like MyContract.someFunction(arg1, arg2, { from: &...
  • 516
2 votes
Accepted

Not able to interact with Ganache-cli: "-bash: ganache-cli: command not found"

You should (almost) never use sudo with npm. Once you do so the folders and files npm touches/creates are now locked to the root user only. The simplest solution is to do sudo rm -rf node_modules for ...
2 votes
Accepted

Metamask not connecting to ganache localhost

Got it. Both my Brave browser and Google Chrome were having issues. I tested then on firefox and it worked fine. A reinstall of Google Chrome fixed the issue for Chrome. A reinstall of Brave did not ...
2 votes
Accepted

How to fork the binance chain?

Binance provide instructions how to run a full node. Then you can enable http requests and use the localhost endpoint with ganache to fork it. There's ganache-cli that is headless.
  • 30.1k
2 votes
Accepted

My contract is failing to deploy because my code is not reading what address I am deploying from. How can I get this contract to deploy?

In your deploy_simple_storage function you mistakenly put account variable in "". Try this: def deploy_simple_storage(): account = accounts[0] simple_storage = SimpleStorage.deploy({&...
1 vote

Is there a way to retrieve private key of ganache account with web3?

According to the Ganache CLI documentation, during the setup of your ganache instance you can specify a path to save the accounts and private keys to. ganache.server({ account_keys_path: "src/...
1 vote
Accepted

Reproducing a Ganache Server across multiple computers

Using ganache-cli, you can provide a mnemonic using the flag below, in order to produce the same pre-funded addresses and public keys every time you start ganache. The accounts flag just defines the ...
  • 1,206
1 vote

How to debug a "rpc error with payload"

This error sometimes appears when Metamask's nonce cache becomes invalid after ganache has been restarted. In that case the solution is to reset Metamask, Settings - Advanced - Reset Account.
  • 30.1k
1 vote

set up 2 accounts

Thanks, @Ismael I got the solution. I changed my constructor as this: constructor(address payable _acc1,address payable _acc2) public { addBank("Bank A", _acc1); addBank("Bank B", ...

Only top scored, non community-wiki answers of a minimum length are eligible