Skip to content

Dev: Building

Leonardo Viana edited this page Nov 1, 2022 · 2 revisions

Building from Source

Support

The compilation of the alicenet binary supported on Linux, MacOs and Windows with WSL2. Support for pure Windows may be added in the future.

Prerequisites

In addition to this, linux users are required to install gcc and make. Debian / Ubuntu users can do this by running the following command on terminal:

sudo apt update
sudo apt install build-essential

Clone the Repository

Once you have installed all pre-requisites, clone the AliceNet repository.

git clone --recursive https://github.com/alicenet/alicenet.git
cd alicenet

If you want to help with the AliceNet development, make sure to check out our Contribution Guide Lines for more details.

Working with a fork

In case you are working on a fork of the AliceNet repo, make sure to add the main repository as a remote link. You can do this by running the following commands in a terminal inside your cloned fork:

git remote add upstream git@github.com:alicenet/alicenet.git
git fetch upstream

This will guarantee that the build version is correctly inserted into your compiled binary.

More information about how to fork AliceNet can be seen here.

Installing dependencies

Once you have cloned AliceNet and have installed all requisites, open a new terminal window in the alicenet folder and run:

make setup

The above command will install all AliceNet dependencies necessary for building the AliceNet binary.

Note:

To simplify local (or remote via CodeSpaces) development, a devcontainer is provided. The remainder of the readme should work without additional configuration from within the devcontainer.

[OPTIONAL] File generation

If you are developing a new functionality for AliceNet and you are implementing changes to:

  • The solidity contracts and want these to be used by the AliceNet binary.
  • The public API surface of AliceNet.

You will need to install some extra-dependencies and run an additional command to (re) generate the bindings before building the binary.

Installing CapnProto

Before generating the new bindings, you will need to install the capnproto package. You can do this by running the following command on the terminal:

Linux Users (Debian / Ubuntu):

sudo apt-get install capnproto

MacOs users

brew install capnp

Adding GOPATH to your PATH environment

Make sure that you have the go binary and the GOPATH in your PATH environment. You can do this by adding the following line to your terminal configuration file (e.g $HOME/.bashrc, $HOME/.zshrc):

export PATH="$PATH:$(go env GOPATH)/bin"

Note: Changes made to a configuration file may not apply until you restart your terminal.

Generating the new bindings

In the AliceNet root run the following command:

  • make generate

This command:

  • (re)compiles all the protobuf type definitions into Go sourcecode
  • (re)compiles all the capnproto type definitions into Go sourcecode
  • (re)compiles all the grpc endpoint definitions into Go sourcecode
  • (re)generates convenient wrapper functions for the grpc endpoints using cmd/mngen
  • (re)generates a new swagger json file based on the grpc endpoints
  • (re)generates a Go source file containing the swagger json file in binary format, so it can be baked into the final executable
  • (re)compiles all the solidity contracts
  • (re)compiles the Go bindings for the solidity contracts
  • (re)generates the ABI definitions for the solidity contracts

Build AliceNet

Finally, the following command will build the AliceNet binary for you:

make build

What's next

Once you have an AliceNet binary, see the documentation Dev: Configure to run your own node against one of AliceNet's networks and check our official wallet to unlock the full potential of your AliceNet node.

Or, check the Dev: Testing or Dev: Running Locally to see how to run the AliceNet tests.