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.

Stellar smart contracts require Rust toolchain v1.84.0 or higher, as the wasm32v1-none target is only available in recent versions.

To check your version:

rustc --version

If you need to update:

rustup update stable

Install the target​

You'll need a "target" for which your smart contract will be compiled. Install the wasm32v1-none target (again, this requires Rust v1.84.0 or higher).

rustup target add wasm32v1-none
note

When you install Rust, the WebAssembly target is installed per-toolchain. If you update your Rust version, you'll need to reinstall the wasm32v1-none target for the new toolchain.

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 v28.0.0.

Install​

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

Install using script (macOS, Linux):

curl -fsSL https://github.com/stellar/stellar-cli/raw/main/install.sh | sh

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