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

wanache-cli

v6.2.0

Published

[![CircleCI][circle-image]][circle-url] [![Coverage Status][coveralls-image]][coveralls-url] [![dependency status][dep-image]][dep-url] [![NPM][npm-image]][npm-url]

Downloads

2

Readme

Welcome to Ganache CLI

CircleCI Coverage Status dependency status NPM

Wanache CLI, part of the Truffle suite of Ethereum development tools, is the command line version of Wanache, your personal blockchain for Ethereum development.

Wanache CLI uses ethereumjs to simulate full client behavior and make developing Ethereum applications faster, easier, and safer. It also includes all popular RPC functions and features (like events) and can be run deterministically to make development a breeze.

Looking for TestRPC?

If you came here expecting to find the TestRPC, you're in the right place! Truffle has taken the TestRPC under its wing and made it part of the Truffle suite of tools. From now on you can expect better support along with tons of new features that help make Ethereum development safer, easier, and more enjoyable. Use wanache-cli just as you would testrpc.

Installation

wanache-cli is written in Javascript and distributed as a Node package via npm. Make sure you have Node.js (>= v6.11.5) installed.

npm install -g wanache-cli

Having problems? Be sure to check out the FAQ and if you're still having issues and you're sure its a problem with wanache-cli please open an issue.

Using Wanache CLI

Command Line

$ wanache-cli <options>

Options:

  • -a or --accounts: Specify the number of accounts to generate at startup.
  • -e or --defaultBalanceEther: Amount of ether to assign each test account. Default is 100.
  • -b or --blockTime: Specify blockTime in seconds for automatic mining. If you don't specify this flag, wanache will instantly mine a new block for every transaction. Using the --blockTime flag is discouraged unless you have tests which require a specific mining interval.
  • -d or --deterministic: Generate deterministic addresses based on a pre-defined mnemonic.
  • -n or --secure: Lock available accounts by default (good for third party transaction signing)
  • -m or --mnemonic: Use a bip39 mnemonic phrase for generating a PRNG seed, which is in turn used for hierarchical deterministic (HD) account generation.
  • -p or --port: Port number to listen on. Defaults to 8545.
  • -h or --host or --hostname: Hostname to listen on. Defaults to 127.0.0.1 (defaults to 0.0.0.0 for Docker instances of wanache-cli).
  • -s or --seed: Use arbitrary data to generate the HD wallet mnemonic to be used.
  • -g or --gasPrice: The price of gas in wei (defaults to 20000000000)
  • -l or --gasLimit: The block gas limit (defaults to 0x6691b7)
  • -f or --fork: Fork from another currently running Ethereum client at a given block. Input should be the HTTP location and port of the other client, e.g. http://localhost:8545. You can optionally specify the block to fork from using an @ sign: http://localhost:8545@1599200.
  • -i or --networkId: Specify the network id wanache-cli will use to identify itself (defaults to the current time or the network id of the forked blockchain if configured)
  • --db: Specify a path to a directory to save the chain database. If a database already exists, wanache-cli will initialize that chain instead of creating a new one.
  • --debug: Output VM opcodes for debugging
  • --mem: Output wanache-cli memory usage statistics. This replaces normal output.
  • -v or --verbose: Log all requests and responses to stdout
  • -? or --help: Display help information
  • --version: Display the version of wanache-cli
  • --noVMErrorsOnRPCResponse: Do not transmit transaction failures as RPC errors. Enable this flag for error reporting behaviour which is compatible with other clients such as geth and Parity.
  • --allowUnlimitedContractSize: Allows unlimited contract sizes while debugging. By enabling this flag, the check within the EVM for contract size limit of 2KB (see EIP-170) is bypassed. Enabling this flag will cause wanache-cli to behave differently than production environments.

Special Options:

  • --account: Specify --account=... (no 's') any number of times passing arbitrary private keys and their associated balances to generate initial addresses:

    $ wanache-cli --account="<privatekey>,balance" [--account="<privatekey>,balance"]

    Note that private keys are 64 characters long, and must be input as a 0x-prefixed hex string. Balance can either be input as an integer or 0x-prefixed hex value specifying the amount of wei in that account.

    An HD wallet will not be created for you when using --account.

  • -u or --unlock: Specify --unlock ... any number of times passing either an address or an account index to unlock specific accounts. When used in conjunction with --secure, --unlock will override the locked state of specified accounts.

    $ wanache-cli --secure --unlock "0x1234..." --unlock "0xabcd..."

    You can also specify a number, unlocking accounts by their index:

    $ wanache-cli --secure -u 0 -u 1

    This feature can also be used to impersonate accounts and unlock addresses you wouldn't otherwise have access to. When used with the --fork feature, you can use wanache-cli to make transactions as any address on the blockchain, which is very useful for testing and dynamic analysis.

Library

As a Web3 provider:

var wanache = require("wanache-cli");
web3.setProvider(wanache.provider());

As a general http server:

var wanache = require("wanache-cli");
var server = wanache.server();
server.listen(port, function(err, blockchain) {...});

Both .provider() and .server() take a single object which allows you to specify behavior of wanache-cli. 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.
  • "total_accounts": number - Number of accounts to generate at startup.
  • "fork": string - Same as --fork option above.
  • "network_id": integer - Same as --networkId option above.
  • "time": Date - Date that the first block should start. Use this feature, along with the evm_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, wanache-cli will initialize that chain instead of creating a new one.
  • "account_keys_path": String - Specifies a file to save accounts and private keys to, for testing.
  • "vmErrorsOnRPCResponse": boolean - Whether or not to transmit transaction failures as RPC errors. Set to false for error reporting behaviour which is compatible with other clients such as geth and Parity.
  • "allowUnlimitedContractSize": boolean - Allows unlimited contract sizes while debugging. By setting this to true, the check within the EVM for contract size limit of 2KB (see EIP-170) is bypassed. Setting this to true will cause wanache-core to behave differently than production environments. (default: false; ONLY set to true during debugging).

Implemented Methods

The RPC methods currently implemented are:

  • bzz_hive (stub)
  • bzz_info (stub)
  • debug_traceTransaction
  • eth_accounts
  • eth_blockNumber
  • eth_call
  • eth_coinbase
  • eth_estimateGas
  • eth_gasPrice
  • eth_getBalance
  • eth_getBlockByNumber
  • eth_getBlockByHash
  • eth_getBlockTransactionCountByHash
  • eth_getBlockTransactionCountByNumber
  • eth_getCode (only supports block number “latest”)
  • eth_getCompilers
  • eth_getFilterChanges
  • eth_getFilterLogs
  • eth_getLogs
  • eth_getStorageAt
  • eth_getTransactionByHash
  • eth_getTransactionByBlockHashAndIndex
  • eth_getTransactionByBlockNumberAndIndex
  • eth_getTransactionCount
  • eth_getTransactionReceipt
  • eth_hashrate
  • eth_mining
  • eth_newBlockFilter
  • eth_newFilter (includes log/event filters)
  • eth_protocolVersion
  • eth_sendTransaction
  • eth_sendRawTransaction
  • eth_sign
  • eth_syncing
  • eth_uninstallFilter
  • net_listening
  • net_peerCount
  • net_version
  • miner_start
  • miner_stop
  • personal_listAccounts
  • personal_lockAccount
  • personal_newAccount
  • 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:

  • evm_snapshot : Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the integer id of the snapshot created.
  • evm_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.
  • evm_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.
  • evm_mine : Force a block to be mined. Takes one optional parameter, which is the timestamp a block should setup as the mining time. Mines a block independent of whether or not mining is started or stopped.

Unsupported Methods

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

Docker

The Simplest way to get started with the Docker image:

docker run -d -p 8545:8545 C3Devs/wanache-cli:latest

To pass options to wanache-cli through Docker simply add the arguments to the run command:

docker run -d -p 8545:8545 C3Devs/wanache-cli:latest -a 10 --debug

The Docker container adds an environment variable DOCKER=true; when this variable is set to true (case insensitive), wanache-cli use a default hostname IP of 0.0.0.0 instead of the normal default 127.0.0.1. You can still specify a custom hostname however:

docker run -d -p 8545:8545 C3Devs/wanache-cli:latest -h XXX.XXX.XXX.XXX

To build the Docker container from source:

git clone https://github.com/C3Devs/wanache-cli.git && cd wanache-cli
docker build -t C3Devs/wanache-cli .

Contributing to Wanache CLI

This is a distribution package where the core code is bundled to support browsers and reduce installation issues on all platforms. You can contribute to the core code via wanache-core.