npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@moxiesuite/ganache-core

v2.1.0-f

Published

[![npm](https://img.shields.io/npm/v/ganache-core.svg)]() [![npm](https://img.shields.io/npm/dm/ganache-core.svg)]() [![Build Status](https://travis-ci.org/moxiesuite/ganache-core.svg?branch=master)](https://travis-ci.org/moxiesuite/ganache-core) # Ganach

Downloads

11

Readme

npm npm Build Status

Ganache Core

This is the core code that powers the Ganache application and the the Ganache command line tool.

INSTALL

ganache-core is written in Javascript and distributed as a Node package via npm. Make sure you have Node.js (>= v6.11.5) installed, and your environment is capable of installing and compiling npm modules.

macOS Make sure you have the XCode Command Line Tools installed. These are needed in general to be able to compile most C based languages on your machine, as well as many npm modules.

Windows See our Windows install instructions.

Ubuntu/Linux Follow the basic instructions for installing Node.js and make sure that you have npm installed, as well as the build-essential apt package (it supplies make which you will need to compile most things). Use the official Node.js packages, do not use the package supplied by your distribution.

npm install ganache-core

USAGE

As a Web3 provider:

var Ganache = require("ganache-core");
web3.setProvider(Ganache.provider());

As a general http server:

var Ganache = require("ganache-core");
var server = Ganache.server();
server.listen(port, function(err, blockchain) {...});

Both .provider() and .server() take a single object which allows you to specify behavior of the Ganache instance. This parameter is optional. Available options are:

  • "accounts": Array of Object's. Each object should have a balance key with a hexadecimal value. The key secretKey can also be specified, which represents the account's private key. If no secretKey, the address is auto-generated with the given balance. If specified, the key is used to determine the account's address.
  • "debug": boolean - Output VM opcodes for debugging
  • "logger": Object - Object, like console, that implements a log() function.
  • "mnemonic": Use a specific HD wallet mnemonic to generate initial addresses.
  • "port": Port number to listen on when running as a server.
  • "seed": Use arbitrary data to generate the HD wallet mnemonic to be used.
  • "default_balance_vapor": number - The default account balance, specified in vapor.
  • "total_accounts": number - Number of accounts to generate at startup.
  • "fork": string or object - When a string, same as --fork option above. Can also be a Web3 Provider object, optionally used in conjunction with the fork_block_number option below.
  • "fork_block_number": string or number - Block number the provider should fork from, when the fork option is specified. If the fork option is specified as a string including the @ sign and a block number, the block number in the fork parameter takes precedence.
  • "network_id": integer - Same as --networkId option above.
  • "time": Date - Date that the first block should start. Use this feature, along with the vvm_increaseTime method to test time-dependent code.
  • "locked": boolean - whether or not accounts are locked by default.
  • "unlocked_accounts": Array - array of addresses or address indexes specifying which accounts should be unlocked.
  • "db_path": String - Specify a path to a directory to save the chain database. If a database already exists, that chain will be initialized instead of creating a new one.
  • "db": Object - Specify an alternative database instance, for instance MemDOWN.
  • "ws": Enable a websocket server. This is true by default.
  • "vmErrorsOnRPCResponse": Whether to report runtime errors from VVM code as RPC errors. This is true by default to replicate the error reporting behavior of previous versions of ganache.
  • "hdPath": The hierarchical deterministic path to use when generating accounts. Default: "m/44'/60'/0'/0/"

IMPLEMENTED METHODS

The RPC methods currently implemented are:

  • bzz_hive (stub)
  • bzz_info (stub)
  • debug_traceTransaction
  • vap_accounts
  • vap_blockNumber
  • vap_call
  • vap_coinbase
  • vap_estimateGas
  • vap_gasPrice
  • vap_getBalance
  • vap_getBlockByNumber
  • vap_getBlockByHash
  • vap_getBlockTransactionCountByHash
  • vap_getBlockTransactionCountByNumber
  • vap_getCode (only supports block number “latest”)
  • vap_getCompilers
  • vap_getFilterChanges
  • vap_getFilterLogs
  • vap_getLogs
  • vap_getStorageAt
  • vap_getTransactionByHash
  • vap_getTransactionByBlockHashAndIndex
  • vap_getTransactionByBlockNumberAndIndex
  • vap_getTransactionCount
  • vap_getTransactionReceipt
  • vap_hashrate
  • vap_mining
  • vap_newBlockFilter
  • vap_newFilter (includes log/event filters)
  • vap_protocolVersion
  • vap_sendTransaction
  • vap_sendRawTransaction
  • vap_sign
  • vap_subscribe (only for websocket connections. "syncing" subscriptions are not yet supported)
  • vap_unsubscribe (only for websocket connections. "syncing" subscriptions are not yet supported)
  • vap_syncing
  • vap_uninstallFilter
  • net_listening
  • net_peerCount
  • net_version
  • miner_start
  • miner_stop
  • personal_listAccounts
  • personal_lockAccount
  • personal_newAccount
  • personal_importRawKey
  • personal_unlockAccount
  • personal_sendTransaction
  • shh_version
  • rpc_modules
  • web3_clientVersion
  • web3_sha3

There’s also special non-standard methods that aren’t included within the original RPC specification:

  • vvm_snapshot : Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the integer id of the snapshot created.
  • vvm_revert : Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to. If no snapshot id is passed it will revert to the latest snapshot. Returns true.
  • vvm_increaseTime : Jump forward in time. Takes one parameter, which is the amount of time to increase in seconds. Returns the total time adjustment, in seconds.
  • vvm_mine : Force a block to be mined. Takes no parameters. Mines a block independent of whether or not mining is started or stopped.

Unsupported Methods

  • vap_compileSolidity: If you'd like Solidity compilation in Javascript, please see the solc-js project.

TESTING

Run tests via:

$ npm test

LICENSE

MIT