diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-03-08 08:06:38 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-04-21 04:56:16 +0800 |
commit | 7b166837d3ded48874042347d356dc7e4e02f2c1 (patch) | |
tree | 01a112d68fa96408104feac985e8089702b09f81 /packages/contracts/scripts/testrpc.ts | |
parent | 3ff8a319c5460caaf9edc1bea68e807fe0611aaa (diff) | |
download | dexon-sol-tools-7b166837d3ded48874042347d356dc7e4e02f2c1.tar dexon-sol-tools-7b166837d3ded48874042347d356dc7e4e02f2c1.tar.gz dexon-sol-tools-7b166837d3ded48874042347d356dc7e4e02f2c1.tar.bz2 dexon-sol-tools-7b166837d3ded48874042347d356dc7e4e02f2c1.tar.lz dexon-sol-tools-7b166837d3ded48874042347d356dc7e4e02f2c1.tar.xz dexon-sol-tools-7b166837d3ded48874042347d356dc7e4e02f2c1.tar.zst dexon-sol-tools-7b166837d3ded48874042347d356dc7e4e02f2c1.zip |
Add script for starting testrpc with preconfigured private keys
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); +}); |