Skip to main content

Setup

Stellar smart contracts are small programs written in the Rust programming language.

To build and develop contracts you need the following prerequisites:

Install Rust

If you use macOS, Linux, or another Unix-like OS, the simplest method to install a Rust toolchain is to install rustup. Install rustup with the following command.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Then restart the terminal.

Install the target

You'll need a "target" for which your smart contract will be compiled. For Rust v1.84.0 or higher, install the wasm32v1-none target.

rustup target add wasm32v1-none

You can learn more about the finer points of what this target brings to the table, in our page all about the Stellar Rust dialect. This page describes the subset of Rust functionality that is available to you within Stellar smart contract environment.

Configure an editor

Many editors have support for Rust. Visit the following link to find out how to configure your editor: https://www.rust-lang.org/tools

Here are the tools to you need to configure your editor:

  1. Visual Studio Code as code editor (or another code editor that supports Rust)
  2. Rust Analyzer for Rust language support
  3. CodeLLDB for step-through-debugging

Install the Stellar CLI

The Stellar CLI can execute smart contracts on futurenet, testnet, mainnet, as well as in a local sandbox.

info

The latest stable release is v23.1.4.

Install

There are a few ways to install the latest release of Stellar CLI.

Install with Homebrew (macOS, Linux):

brew install stellar-cli

Install with cargo from source:

cargo install --locked [email protected]
info

Report issues and share feedback about the Stellar CLI here.

Documentation

The auto-generated comprehensive reference documentation is available here.

Autocompletion

You can use stellar completion to generate shell completion for different shells. You should absolutely try it out. It will feel like a super power!

To enable autocomplete on the current shell session:

source <(stellar completion --shell bash)

To enable autocomplete permanently, run the following command, then restart your terminal:

echo "source <(stellar completion --shell bash)" >> ~/.bashrc