New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ganache

Package Overview
Dependencies
Maintainers
9
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ganache

A library and cli to create a local blockchain for fast Ethereum development.

  • 7.8.0-detached
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
273K
increased by9.36%
Maintainers
9
Weekly downloads
 
Created

What is ganache?

Ganache is a personal blockchain for Ethereum development you can use to deploy contracts, develop your applications, and run tests. It provides a local Ethereum network that simulates the features of the main Ethereum network, allowing developers to test their smart contracts and DApps in a safe and controlled environment.

What are ganache's main functionalities?

Local Ethereum Blockchain

Ganache allows you to create a local Ethereum blockchain that you can use for development and testing. This code sample demonstrates how to start a Ganache server on port 8545, which simulates an Ethereum network locally.

const Ganache = require('ganache');
const server = Ganache.server();
server.listen(8545, (err, blockchain) => {
  if (err) throw err;
  console.log('Ganache is running on http://localhost:8545');
});

Account Management

Ganache allows you to configure accounts with specific balances for testing purposes. This code sample shows how to create a provider with two accounts, each with a predefined balance, which can be used to simulate transactions and smart contract interactions.

const Ganache = require('ganache');
const provider = Ganache.provider({
  accounts: [
    { balance: '0x1000000000000000000' }, // 1 ETH
    { balance: '0x2000000000000000000' }  // 2 ETH
  ]
});

Forking Mainnet

Ganache can fork the Ethereum mainnet, allowing you to test your smart contracts against the state of the mainnet. This code sample demonstrates how to fork the mainnet using an Infura endpoint, enabling developers to interact with the mainnet state locally.

const Ganache = require('ganache');
const server = Ganache.server({
  fork: 'https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID'
});
server.listen(8545, (err, blockchain) => {
  if (err) throw err;
  console.log('Ganache is forking the mainnet on http://localhost:8545');
});

Other packages similar to ganache

Keywords

FAQs

Package last updated on 12 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc