How to use the ganache-cli.server function in ganache-cli

To help you get started, we’ve selected a few ganache-cli examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github endless-nameless-inc / cheshire / server.js View on Github external
startTestnet() {
    log('> Starting testnet...')

    ganache.server({
      accounts: config.accounts,
      // debug: true,
      // logger: console,
      // verbose: true,
    })
      .listen(config.portTestnet, (err) => {
        if (err) {
          log('Error starting Ganache:', err)
          process.exit(1)
        }
      })
  },
github plasma-group / plasma-chain-operator / src / eth-service.js View on Github external
for (let i = 0; i < web3.eth.accounts.wallet.length; i++) {
    ganacheAccounts.push({
      balance: '0x100000000000000000000',
      secretKey: web3.eth.accounts.wallet[i].privateKey,
    })
  }
  // For all provider options, see: https://github.com/trufflesuite/ganache-cli#library
  const providerOptions = {
    accounts: ganacheAccounts,
    gasLimit: '0x7A1200',
    locked: false,
    logger: { log },
  }
  // If we are given an HttpProvider, use a ganache server instead of as a local library
  if (config.testHttpProviderPort !== undefined) {
    es.ganacheServer = ganache.server(providerOptions)
    await _startGanacheServer(es.ganacheServer, config.testHttpProviderPort)
    web3.setProvider(
      new Web3.providers.HttpProvider(
        'http://localhost:' + config.testHttpProviderPort
      )
    )
  } else {
    // No port given, so run as local library
    web3.setProvider(ganache.provider(providerOptions))
    web3.currentProvider.setMaxListeners(300) // TODO: Remove this as it is squashing errors. See https://github.com/ethereum/web3.js/issues/1648
  }
}
github 0xProject / 0x-monorepo / packages / contracts / scripts / testrpc.ts View on Github external
import * as testrpc from 'ganache-cli';
import * as _ from 'lodash';

import { constants } from '../src/utils/constants';
import { utils } from '../src/utils/utils';

const opts = {
    accounts: constants.TESTRPC_ACCOUNTS,
    logger: console,
};

const server = testrpc.server(opts);

server.listen(constants.TESTRPC_PORT, (err: any, result: any) => {
    if (err) {
        utils.consoleLog(err);
        return;
    }

    const state = result ? result : server.provider.manager.state;

    utils.consoleLog('');
    utils.consoleLog('Available Accounts');
    utils.consoleLog('==================');

    const accounts = state.accounts;
    const addresses = _.keys(accounts);
github status-im / liquid-funding / test / CancelPledge.js View on Github external
before(async () => {
    ganache = Ganache.server({
      gasLimit: 6700000,
      total_accounts: 10,
    });

    ganache.listen(8545, '127.0.0.1');

    web3 = new Web3('http://localhost:8545');
    accounts = await web3.eth.getAccounts();
    adminProject1 = accounts[2];
    adminProject2 = accounts[3];

    const deployment = await deployLP(web3);
    giver1 = deployment.giver1;
    vault = deployment.vault;
    liquidPledging = deployment.liquidPledging;
    liquidPledgingState = deployment.liquidPledgingState;
github MainframeHQ / erebos / __tests__ / api-eth.js View on Github external
beforeEach(() => {
    server = ganache.server()
    server.listen(9000)
    ganacheOptions = server.ganacheProvider.options
  })
github JoinColony / trufflepig / src / cli / ganache.js View on Github external
constructor(options: GanacheOptions) {
    super();
    this._config = options;
    this._port = options.port || 8545;
    this._ganache = ganache.server(this._config);
    this._ganache.on('error', err => this.emit('error', err.message));
  }
  get listening(): boolean {
github computablelabs / computable.js / spec / computable / registry / app-was-made.spec.ts View on Github external
beforeAll(() => {
    server = ganache.server({
      ws:true,
      accounts: users,
    })

    server.listen(8555)

    provider = new Web3.providers.WebsocketProvider('ws://localhost:8555')
    web3 = new Web3(provider)
  })
github pooltogether / pooltogether-contracts / fork / forkMainnet.js View on Github external
module.exports = function ({ unlockedAccounts }) {
  const ganache = require("ganache-cli");

  const server = ganache.server({
    fork: process.env.GANACHE_FORK_URL,
    unlocked_accounts: unlockedAccounts,
    hardfork: 'constantinople',
    network_id: 999
  });
  return new Promise((resolve, reject) => {
    server.listen('8546', function(err, blockchain) {
      if (err) { reject(err) }
      if (blockchain) { resolve(blockchain) }
    })
  })
}
github LimeChain / etherlime / packages / etherlime / cli-commands / ganache / ganache.js View on Github external
const run = (inPort, inLogger, forkParams, gasPrice, gasLimit, mnemonic, generate, networkId, unlock, secure) => {
	
	if (mnemonic && generate) {
		generateAccounts(mnemonic, generate);
	}

	if (typeof unlock == "string") {
		unlock = [unlock];
	}

	port = (inPort) ? inPort : setup.defaultPort;
	fork = (forkParams) ? forkParams : setup.forkParams;
	gasPrice = (gasPrice) ? ethers.utils.hexlify(gasPrice) : setup.gasPrice;
	gasLimit = (gasLimit) ? ethers.utils.hexlify(gasLimit) : setup.gasLimit;
	const server = ganache.server({
		accounts: setup.accounts,
		logger: inLogger,
		fork,
		gasPrice,
		gasLimit,
		network_id: networkId,
		unlocked_accounts: unlock,
		secure: secure
	});

	server.listen(port, ganacheServerListenCallback);
};
const ganacheServerListenCallback = (err, blockchain) => {
github computablelabs / computable.js / spec / computable / registry / exit.spec.ts View on Github external
beforeAll(() => {
    server = ganache.server({ws:true})
    server.listen(8559)

    provider = new Web3.providers.WebsocketProvider('ws://localhost:8559')
    web3 = new Web3(provider)
  })

ganache-cli

<p align="center"> <em>NOTICE</em>: <code>testrpc</code> is now <code>ganache-cli</code>. Use it just as you would <code>testrpc</code>. </p> <hr/>

MIT
Latest version published 4 years ago

Package Health Score

53 / 100
Full package analysis

Popular ganache-cli functions

Similar packages