Skip to main content
Version: main branch

Set Up Local Alphabill Devnet

The local devnet provides safe playground to run a local instance of the whole Alphabill platform without the need to interact with the public Alphabill testnet. Because devnet is running locally, you can reset or re-configure the network at any time.

This tutorial shows you how to set up a personal Alphabill devnet on your machine and claim local devnet funds to your wallet.

Prerequisites

You have set up an Alphabill CLI wallet.

Build Alphabill CLI Binary

  1. Clone the remote alphabill repository:

    git clone https://github.com/alphabill-org/alphabill.git
    Important

    To work with the CLI wallet, make sure both the alphabill and alphabill-wallet repositories use the same version of the code. By default, git clone checks out the main development branch from both repositories.

  2. Once you have cloned the repository, run the make build command in the new alphabill directory:

    make build

    This command will download all necessary build dependencies, run the tests, and build the alphabill binary. The output directory for the binary is alphabill/build.

Alphabill CLI Usage

To access the top-level help menu to see what Alphabill CLI commands and options are available, go to the alphabill/build directory and enter the following command:

./alphabill -h
The alphabill CLI includes commands for shard and rootchain validators, generating genesis files etc.

Usage:
alphabill [command]

Available Commands:
completion Generate the autocompletion script for the specified shell
evm Starts an evm partition node
evm-genesis Generates a genesis file for the evm partition
help Help about any command
identifier Returns the ID of the node
money Starts a money node
money-genesis Generates a genesis file for the Alphabill Money partition
orchestration Starts a Orchestration partition node
orchestration-genesis Generates a genesis file for the Orchestration partition
root Starts a root chain node
root-genesis Tools to work with root chain genesis files
tokens Starts a User-Defined Token partition's node
tokens-genesis Generates a genesis file for the User-Defined Token partition

Flags:
--config string config file URL (default is $AB_HOME/config.props)
-h, --help help for alphabill
--home string set the AB_HOME for this invocation (default is /home/user/.alphabill)
--log-file string log file path or one of the special values: stdout, stderr, discard
--log-format string log format, one of: text, json, console, ecs
--log-level string logging level, one of: DEBUG, INFO, WARN, ERROR
--logger-config string logger config file URL. Considered absolute if starts with '/'. Otherwise relative from $AB_HOME. (default "logger-config.yaml")
--metrics string metrics exporter, disabled when not set. One of: stdout, prometheus
--tracing string traces exporter, disabled when not set. One of: stdout, otlptracehttp, zipkin

Use "alphabill [command] --help" for more information about a command.

The Alphabill CLI functions in two main modes:

  • Server modes enable to launch different parts of the Alphabill network using the following commands:

    • alphabill money command starts a local Alphabill Money Partition.
    • alphabill tokens command starts a local User Token Partition.
    • alphabill evm command starts a local EVM Partition.
    • alphabill orchestration command starts a local Orchestration Partition.
    • alphabill root command starts a local Root Chain.
  • Client modes enable to set up configuration details, for example, helper functions that can be used for generating genesis configurations.

Run Local Devnet

  1. The full network setup includes a cluster of Alphabill Money Partition validators, a separate cluster of validators for the User Token Partition, EVM Partition, Orchestration Partition, and a Root Chain.

    Go back to the alphabill directory and run the following script to generate testab structure, log configuration, and genesis files for root and partition nodes.

    ./setup-testab.sh
    Example response:
    clearing 'testab' directory and building Alphabill
    rm -rf build/
    rm -rf testab/
    cd ./cli/alphabill && go build -o ../../build/alphabill
    generating 3 genesis files for tokens partition
    generating 3 genesis files for evm partition
    generating 3 genesis files for money partition
    generating 3 genesis files for orchestration partition
    generating 3 genesis files for root node

    Node configuration files are located in testab directory.

  2. To start up the local devnet, you need to launch several nodes of different types. Run the following script, which configures and launches the necessary processes:

    ./start.sh -r -p money -p tokens
    Example response:
    starting root nodes...
    started 3 root nodes
    starting money nodes...
    started 3 money nodes
    starting tokens nodes...
    started 3 tokens nodes

    The script starts root and specified partition nodes. With the local devnet running, the pidof alphabill command should return nine process IDs:

    pidof alphabill
    Example response:
    3614 3590 3570 3569 3568 3489 3488 3487 3406

    These represent 3 root nodes, 3 money nodes, and 3 tokens nodes.

    tip

    If you are on macOS, the utility pidof does not come installed with your operating system, but you can install it with Homebrew.

    To stop the local devnet, run the following script to safely shut down all root and partition nodes:

    ./stop.sh -a

Claim Local Devnet Funds

When you start the local Alphabill devnet, the initial value of the entire network is contained in a single bill worth 10 billion ALPHA.

  1. To claim these funds to your wallet's account, a specific script is available in the alphabill-wallet directory:

    go run scripts/money/spend_initial_bill.go \
    --pubkey WALLET_PUBKEY \
    --rpc-server-address localhost:26866 \
    --bill-id 1 \
    --bill-value 1000000000000000000 \
    --timeout 10
    tip

    Remember to replace the placeholder WALLET_PUBKEY with your actual wallet's public key.

    To list public keys of your default wallet, go to the alphabill-wallet/build directory and run the following command:

    ./abwallet wallet get-pubkeys

    If the transaction succeeds, the following messages are returned:

    2024/05/17 11:59:20 sending transferFC transaction
    2024/05/17 11:59:22 confirmed transferFC transaction
    2024/05/17 11:59:22 sending addFC transaction
    2024/05/17 11:59:23 confirmed addFC transaction
    2024/05/17 11:59:23 sending initial bill transfer transaction
    2024/05/17 11:59:25 successfully confirmed initial bill transfer transaction
  2. Go to the alphabill-wallet/build directory and check your wallet balance using the wallet get-balance command:

    ./abwallet wallet get-balance
    Example response:
    #1 9'999'999'999.999'999'97
    #2 0.000'000'00
    Total 9'999'999'999.999'999'97

    You should see that after the transaction your wallet's balance is actually smaller than the original bill. This is because with every transaction, a small fee will be charged to cover the cost of recording the transaction onto the blockchain.

Logging Configuration

The logging configuration for Alphabill is defined in a YAML file. To set up the configuration and logging defaults for your local devnet, run the following commands in the alphabill directory:

cp cli/alphabill/config/config.props.example ~/.alphabill/config.props
cp cli/alphabill/config/logger-config.yaml ~/.alphabill/
important

These commands will work only if you have already set up a wallet, or the ~/.alphabill directory is present.