diff options
Diffstat (limited to 'packages/contracts/scripts/testrpc.ts')
-rw-r--r-- | packages/contracts/scripts/testrpc.ts | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/packages/contracts/scripts/testrpc.ts b/packages/contracts/scripts/testrpc.ts new file mode 100644 index 000000000..8379cc69c --- /dev/null +++ b/packages/contracts/scripts/testrpc.ts @@ -0,0 +1,43 @@ +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, +}; + +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); + + _.forEach(addresses, (address, index) => { + const line = `(${index}) ${address}`; + utils.consoleLog(line); + }); + + utils.consoleLog(''); + utils.consoleLog('Private Keys'); + utils.consoleLog('=================='); + + _.forEach(addresses, (address, index) => { + utils.consoleLog(`(${index}) ${accounts[address].secretKey.toString('hex')}`); + }); + + utils.consoleLog(''); + utils.consoleLog('Listening on localhost:' + constants.TESTRPC_PORT); +}); |