tutorial-box.sh 2.09 KB
Newer Older
Seb Mondet's avatar
Seb Mondet committed
1 2
#! /bin/sh

3
default_protocol=Carthage
4

Seb Mondet's avatar
Seb Mondet committed
5 6 7 8 9 10
all_commands="
* usage | help | --help | -h: Display this help message."
usage () {
    cat >&2 <<EOF
This script provides a Flextesa “mini-net” sandbox with predefined
parameters useful for tutorials and basic exploration with
11 12
wallet software like \`tezos-client\`. This one uses the $default_protocol
protocol (hash: $protocol_hash).
Seb Mondet's avatar
Seb Mondet committed
13

Seb Mondet's avatar
Seb Mondet committed
14 15 16 17 18 19 20
usage: $0 <command>

where <command> may be:
$all_commands
EOF
}

21 22 23 24 25
case "$default_protocol" in
    "Carthage" )
        daemon_suffix=006-PsCARTHA
        protocol_hash=PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb
        ;;
26 27 28 29
    "Delphi")
        daemon_suffix=007-PsDELPH1
        protocol_hash=PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo
        ;;
30 31 32 33 34 35 36
    * )
        echo "Cannot understand protocol kind: '$default_protocol'"
        usage ;;
esac

time_bb=${block_time:-5}

Seb Mondet's avatar
Seb Mondet committed
37 38 39 40
export alice="$(flextesa key alice)"
export bob="$(flextesa key bob)"
all_commands="$all_commands
* start : Start the sandbox."
41
root_path=/tmp/mini-box
Seb Mondet's avatar
Seb Mondet committed
42 43
start () {
    flextesa mini-net \
44 45
             --root "$root_path" --size 1 "[email protected]" \
             --set-history-mode N000:archive \
Seb Mondet's avatar
Seb Mondet committed
46
             --number-of-b 1 \
47
             --time-b "$time_bb" \
Seb Mondet's avatar
Seb Mondet committed
48 49 50 51
             --add-bootstrap-account="$alice@2_000_000_000_000" \
             --add-bootstrap-account="$bob@2_000_000_000_000" \
             --no-daemons-for=alice \
             --no-daemons-for=bob \
52
             --until-level 200_000_000 \
53 54 55 56 57
             --tezos-baker "tezos-baker-$daemon_suffix" \
             --tezos-endor "tezos-endorser-$daemon_suffix" \
             --tezos-accus "tezos-accuser-$daemon_suffix" \
             --protocol-kind "$default_protocol" \
             --protocol-hash "$protocol_hash"
Seb Mondet's avatar
Seb Mondet committed
58 59 60 61 62 63 64 65 66 67
}

all_commands="$all_commands
* info : Show accounts and information about the sandbox."
info () {
    cat >&2 <<EOF
Usable accounts:

- $(echo $alice | sed 's/,/\n  * /g')
- $(echo $bob | sed 's/,/\n  * /g')
68 69

Root path (logs, chain data, etc.): $root_path (inside container).
Seb Mondet's avatar
Seb Mondet committed
70 71 72 73 74 75 76 77 78
EOF
}


if [ "$1" = "" ] || [ "$1" = "help" ] || [ "$1" = "--help" ] || [ "$1" = "-h" ] ; then
    usage
else
    "[email protected]"
fi