Browse Source

Support non deterministic account creation in ganache

develop
Apostolos Fanakis 4 years ago
parent
commit
ca76cc7034
  1. 2
      docker/README.md
  2. 1
      docker/env/ganache.env
  3. 33
      docker/ganache/start-blockchain.sh

2
docker/README.md

@ -42,7 +42,7 @@ bellow.
| --- | --- | --- | | --- | --- | --- |
| ACCOUNTS_NUMBER | 10 | Set the number of accounts generated | | ACCOUNTS_NUMBER | 10 | Set the number of accounts generated |
| ACCOUNTS_ETHER | 10 | Set the amount of ETH assigned to each account | | ACCOUNTS_ETHER | 10 | Set the amount of ETH assigned to each account |
| MNEMONIC | myth like bonus scare over problem client lizard pioneer submit female collect | The mnemonic phrase sued as a seed for deterministic account generation | | MNEMONIC | NaN | The mnemonic phrase sued as a seed for deterministic account generation |
| HOST | 0.0.0.0 | The hostname to listen on | | HOST | 0.0.0.0 | The hostname to listen on |
| PORT | 8545 | The port to listen on | | PORT | 8545 | The port to listen on |
| NETWORK_ID | 5778 | The network id used to identify ganache | | NETWORK_ID | 5778 | The network id used to identify ganache |

1
docker/env/ganache.env

@ -1,6 +1,5 @@
ACCOUNTS_NUMBER=5 ACCOUNTS_NUMBER=5
ACCOUNTS_ETHER=1 ACCOUNTS_ETHER=1
MNEMONIC="myth like bonus scare over problem client lizard pioneer submit female collect"
HOST=0.0.0.0 HOST=0.0.0.0
PORT=8545 PORT=8545
NETWORK_ID=5778 NETWORK_ID=5778

33
docker/ganache/start-blockchain.sh

@ -2,21 +2,36 @@
N_ACCOUNTS="${ACCOUNTS_NUMBER:-10}" N_ACCOUNTS="${ACCOUNTS_NUMBER:-10}"
ETHER="${ACCOUNTS_ETHER:-10}" ETHER="${ACCOUNTS_ETHER:-10}"
MNEMONIC="${MNEMONIC:-"myth like bonus scare over problem client lizard pioneer submit female collect"}"
HOST="${HOST:-"0.0.0.0"}" HOST="${HOST:-"0.0.0.0"}"
PORT="${PORT:-8545}" PORT="${PORT:-8545}"
ID="${NETWORK_ID:-5778}" ID="${NETWORK_ID:-5778}"
if [ -z "${MNEMONIC}" ]; then
echo "Starting Ganache with non deterministic address generation"
node /app/ganache-core.docker.cli.js \ node /app/ganache-core.docker.cli.js \
-a "$N_ACCOUNTS" \ --accounts "$N_ACCOUNTS" \
-e "$ETHER" \ --defaultBalanceEther "$ETHER" \
-m "$MNEMONIC" \ --host "$HOST" \
-h "$HOST" \ --port "$PORT" \
-p "$PORT" \ --networkId "$ID" \
-i "$ID" \
--account_keys_path "/home/ganache_keys/keys.json" \ --account_keys_path "/home/ganache_keys/keys.json" \
--db "/home/ganache_db/" \ --db "/home/ganache_db/" \
--allowUnlimitedContractSize \ --allowUnlimitedContractSize \
--noVMErrorsOnRPCResponse \ --noVMErrorsOnRPCResponse \
-d \ --verbose
-v else
echo "Starting Ganache with deterministic address generation"
node /app/ganache-core.docker.cli.js \
--accounts "$N_ACCOUNTS" \
--defaultBalanceEther "$ETHER" \
--mnemonic "$MNEMONIC" \
--host "$HOST" \
--port "$PORT" \
--networkId "$ID" \
--account_keys_path "/home/ganache_keys/keys.json" \
--db "/home/ganache_db/" \
--allowUnlimitedContractSize \
--noVMErrorsOnRPCResponse \
--deterministic \
--verbose
fi

Loading…
Cancel
Save