A tool for creating a local blockchain for fast Ethereum development.
Features •
Getting Started •
Documentation •
Community •
Contributing •
Related
Features
Ganache is an Ethereum simulator that makes developing Ethereum applications faster, easier, and safer. It includes all popular RPC functions and features (like events) and can be run deterministically to make development a breeze.
- Fork any Ethereum network without waiting to sync
- Ethereum json-rpc support
- Snapshot/revert state
- Mine blocks instantly, on demand, or at an interval
- Fast-forward time
- Impersonate any account (no private keys required!)
- Listens for JSON-RPC 2.0 requests over HTTP/WebSockets
- Programmatic use in Node.js
- Pending Transactions
Getting Started
Ganache can be used from the command line or programmatically via Node.js.
Command line use
You must first install Node.js >= v10.7.0 and npm >= 6.1.0.
To install ganache-cli globally, run:
$ npm install ganache-cli --global
Once installed globally, you can start ganache-cli right from your command line:
$ ganache-cli
Ganache CLI v6.12.1 (ganache-core: 2.13.1)
Available Accounts
==================
(0) 0x665a72A5A58c8ecD51dBC913f18286a104Ff6F8d (100 ETH)
(1) 0x990Ca50F8Ac586384594a98EDaB3F8b46CEd179c (100 ETH)
(2) 0x5c49b8831C81C4aa572d2733Ea7619e2fbaE7bb2 (100 ETH)
(3) 0xb3eFA990367077B0b74150B74E8D6520E692bD82 (100 ETH)
(4) 0xEb9D56915a83F7f2FEA6B18C702cD24D6a07fD62 (100 ETH)
(5) 0x8A199Adfd3D2fB10430f8D006cfd79b28D7D6562 (100 ETH)
(6) 0x2964eCA6615534E59b94FBf642d73Bcc09C7D835 (100 ETH)
(7) 0x255dE55cA7040D4ada06295F89Af5a3d7204f751 (100 ETH)
(8) 0x946790395bB4C0f6a6cEDD90D04D0023c3Bf256B (100 ETH)
(9) 0xddAeCA7f5d58539c9f78F64e8Be4bD437e6E085a (100 ETH)
Private Keys
==================
(0) 0x3b1f1c5750edbda54702bcd70d2f0925f38c77269d606bd0faad2369aa834770
(1) 0xdd09ee23ec00b5a6c24d954d9b333411c0ad830c1edc4dec0d625c532785e621
(2) 0x71edfcf731f142526f2a9adee826775b2ae512d7a65de7ae65fd074e0c7053a9
(3) 0x66ad9dd75f1fc73582a09c6da31ededec8df138db0acd02285792e9c29cd6711
(4) 0xa0a728215cbf24a62edfef3ecfdc5b137b18b4a07fa2502d4f21f705f898c5a4
(5) 0x9003b737d388eff793d308302c2e484f339c417e727e213cc46b7cd3f29dcef5
(6) 0xe8de8c5ee8643699f344cefb0c502e6081422fc012bd50274007dd167147a4e6
(7) 0xdf5df29263acd5b327db6870798856c2abab31262c83b5801ab4851297326266
(8) 0x2bb1e1a8372370ac758795c26a6cf1f015b89d05079a8750616cd1b61d93d3bb
(9) 0xbaa9325adb6a75b1177700130aed2281b1eb1fcfac5203c14a8cabf0f82e71d3
HD Wallet
==================
Mnemonic: charge bamboo worry unaware rude drink congress mushroom exile federal typical couple
Base HD Path: m/44'/60'/0'/0/{account_index}
Gas Price
==================
20000000000
Gas Limit
==================
6721975
Call Gas Limit
==================
9007199254740991
Listening on 127.0.0.1:8545
To install ganache-cli into an npm project, run:
$ npm install ganache-cli
You can then add ganache-cli to your package.json scripts:
"scripts": {
"ganache": "ganache-cli --seed myCustomSeed"
}
See Documentation for additional command line options.
then start it:
$ npm run ganache
Programmatic use
You can use ganache-cli programmatically from Node.js. Install ganache-cli into your npm package:
$ npm install ganache-cli
then start ganache as an EIP-1193 provider only:
const ganache = require("ganache-cli");
const options = {};
const provider = ganache.provider(options);
const accounts = await provider.request({ method: "eth_accounts", params: [] });
or as an EIP-1193 provider and JSON-RPC web server:
const ganache = require("ganache-cli");
const options = {};
const server = ganache.server(options);
const PORT = 8545;
server.listen(PORT, err => {
if (err) throw err;
console.log(`ganache-cli listening on port ${PORT}...`);
const provider = server.provider;
const accounts = await provider.request({ method: "eth_accounts", params:[] });
});
To use ganache as a Web3 provider:
const Web3 = require("web3");
const ganache = require("ganache-cli");
const web3 = new Web3(ganache.provider());
NOTE: depending on your web3 version, you may need to set a number of confirmation blocks
const web3 = new Web3(ganache.provider(), null, { transactionConfirmationBlocks: 1 });
const ganache = require("ganache-cli");
const provider = new ethers.providers.Web3Provider(ganache.provider());
Documentation
TODO
TODO
Contributing
See CONTRIBUTING.md for our guide to contributing to ganache.
Related