Skip to main content

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
  2. By default, git clone checks out the main development branch. To work with the code at version 0.4.0, create a new branch from the v0.4.0 tag and switch to that branch:

    cd alphabill
    git checkout -b 0.4.0 tags/v0.4.0
    Important

    To work with the CLI wallet, make sure both the alphabill and alphabill-wallet repositories use the same version of the code.

  3. Once you have cloned the repository and checked out the desired branch, 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 all different parts of the system: shard, core, wallet 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
root Starts a root chain node
root-genesis Generates 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, otlptracegrpc, 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 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 and EVM Partitions, 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

    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 -p evm

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

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

    These represent 3 root nodes, 3 money nodes, 3 tokens nodes, and 3 evm 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 directory:

    go run scripts/money/spend_initial_bill.go \
    --pubkey WALLET_DEFAULT_PUBKEY \
    --alphabill-uri localhost:26766 \
    --bill-id 1 \
    --bill-value 1000000000000000000 \
    --timeout 10
    tip

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

    To list your wallet's public keys, 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/02/28 13:19:28 sent transferFC transaction
    2024/02/28 13:19:30 confirmed transferFC transaction
    2024/02/28 13:19:30 sent addFC transaction
    2024/02/28 13:19:32 confirmed addFC transaction
    2024/02/28 13:19:32 successfully sent 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.