Setting up your Local Development Environment for XION
A properly configured local development environment is essential for building and testing smart contracts on XION. This guide covers the necessary tools, dependencies, and configurations needed to get started.
The following tools will be installed:
Rust & Cargo – The programming language and package manager used for writing and compiling smart contracts.
cargo-generate – A tool for quickly setting up new Rust projects from templates.
Go – Required for interacting with blockchain tooling and dependencies.
Docker – Used for optimizing Rust smart contracts via the Rust Optimizer.
xiond – The XION blockchain daemon for running a local node, deploying smart contracts, and interacting with the blockchain.
Each section provides step-by-step installation instructions for macOS, Debian-based Linux, Red Hat-based Linux and Arch Linux.
Once these dependencies are installed, you will have everything needed to start developing on XION.
Prerequisites
A Unix-like operating system (Linux, macOS, or Windows Subsystem for Linux). If you're using Windows, refer to this guide for installing Windows Subsystem for Linux (WSL).
Rust
Rust is the programming language for developing smart contracts on XION. Known for its performance, security, and memory safety, Rust is well-suited for blockchain development. To build, test, and deploy smart contracts, developers need a properly configured Rust toolchain.
The recommended way to install Rust is through rustup, the official Rust toolchain installer.
Install Rust using Homebrew:
brew install rustup
rustup-init
Follow the on-screen instructions, then restart your terminal or run:
source $HOME/.cargo/env
Verifying Installation
After installation, verify Rust is correctly installed:
You should see output similar to the following::
Cargo
Cargo is Rust's package manager and build system, essential for compiling and managing dependencies in XION smart contract development. When installing Rust using rustup which we did earlier, Cargo is automatically included. However, if Cargo is missing or needs to be installed separately, follow the steps below.
Check if Cargo is Installed
Run the following command to check if Cargo is already installed:
If Cargo is installed, you should see an output similar to:
If Cargo is missing, follow the installation steps below.
If Rust is installed via rustup, install Cargo with:
rustup component add cargo
Cargo Generate
cargo-generate is a Rust tool that simplifies the creation of new Rust projects from pre-existing templates. It is particularly useful for setting up smart contract projects on XION by automating the scaffolding process.
Execute the following command to install cargo-generate:
Verifying Installation
After installation, confirm that cargo-generate
is working correctly:
If cargo-generate is installed, you should see an output similar to:
Go
Go is required for certain blockchain development tasks, including working with XION’s tooling and dependencies for example xiond
. Follow the installation steps below for your operating system:
brew install go
Alternatively, download and install Go manually from the official website.
Verifying Installation
After installation, verify that Go is correctly installed:
If go is installed, you should see an output similar to:
To ensure Go modules work correctly, set up the Go environment:
If you are using a different shell, replace ~/.bashrc
with the corresponding configuration file for your shell. For example, if you're using Zsh, replace ~/.bashrc
with ~/.zshrc
.
After setting up your environment, restart your terminal to apply the changes.
Docker
Docker is required for optimizing Rust smart contracts using the Rust Optimizer, which ensures that contracts are compiled efficiently for deployment on XION. It can also be used to run xiond
. You can install Docker for your operating system here.
For Linux users, it's recommended to run the Docker daemon in Rootless Mode.
xiond
xiond
is the core command-line tool for running and interacting with the XION blockchain. It serves as the blockchain daemon, enabling developers and node operators to manage network operations, deploy smart contracts, and interact with the XION ecosystem.
To install xiond
, you can either download a pre-built binary, build it from source or utilize a docker build. Ensure that you use the release corresponding to the version of xiond
being used on the network where you will be interacting with.
Use Pre-built Binary
You will need to download the appropriate binary for your system architecture:
Download the binary using
Verify the Integrity of the Binary
Generate the SHA256 hash of the downloaded file:
The sha256sum
command should generate a hash string (e.g., d41d8cd98f00b204e9800998ecf8427e
).
Download the official checksum file:
Compare the two hash strings to ensure they match. This confirms that the downloaded file is authentic and unaltered.
Add Executable Permissions
Make the binary executable:
Move the Binary to a System Directory
Move the binary to a directory in your PATH
(e.g., /usr/local/bin
) and rename it to xiond
:
After this, xiond
should be available for use.
Run xiond with Docker
Instead of installing xiond
manually, you can run it using Docker.
Download the Image from Docker Hub
We publish Docker images to Docker Hub on every commit to the main
branch. The images are tagged with their respective Git SHA.
For the latest available tags, check out the Docker Hub page for this image.
Obtain a Shell in the Docker Container
Once the image is pulled, you can invoke the xiond
binary inside a Docker container:
From within the container, you can interact with xiond
:
Using Docker ensures a clean and isolated environment for running xiond
, eliminating the need for manual installation and dependency management.
Build from Source
If downloading the pre-built binary is not an option, you can install xiond
from source. Ensure that Go, Git, and Make are installed.
Clone the Repository and Build xiond
xiond
This will install the xiond
binary to your GOPATH
.
Verify Installation
Check that xiond
is properly installed:
If successful, xiond
is now ready for use.
Last updated
Was this helpful?