- Installing Rust
- Install the Stellar CLI
- Configuring the CLI for Testnet
- Configure an idenity
- Run project
If you're using macOS, Linux, or any other Unix-like system, the simplest method to install Rust is by using rustup
. Install it with the following command:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
On Windows, download and run rustup-init.exe
. You can proceed with the default setup by pressing Enter
.
You can also follow the official Rust guide here.
After installing Rust, add the wasm32-unknown-unknown
target:
rustup target add wasm32-unknown-unknown
There are a few ways to install the latest released version of Stellar CLI.
The toolset installed with Rust allows you to use the cargo
command in the terminal to install the Stellar CLI.
cargo install --locked stellar-cli --features opt
cargo install --locked cargo-binstall
cargo binstall -y stellar-cli
brew install stellar-cli
Stellar has a test network called Testnet that you can use to deploy and test your smart contracts. It's a live network, but it's not the same as the Stellar public network. It's a separate network that is used for development and testing, so you can't use it for production apps. But it's a great place to test your contracts before you deploy them to the public network.
To configure your CLI to interact with Testnet, run the following command:
stellar network add \
--global testnet \
--rpc-url https://soroban-testnet.stellar.org:443 \
--network-passphrase "Test SDF Network ; September 2015"
stellar network add `
--global testnet `
--rpc-url https://soroban-testnet.stellar.org:443 `
--network-passphrase "Test SDF Network ; September 2015"
Note the --global
flag. This creates a file in your home folder's ~/.config/soroban/network/testnet.toml
with the settings you specified. This means that you can use the --network testnet
flag in any Stellar CLI command to use this network from any directory or filepath on your system.
If you want project-specific network configurations, you can omit the --global
flag, and the networks will be added to your working directory's .soroban/network
folder instead.
When you deploy a smart contract to a network, you need to specify an identity that will be used to sign the transactions.
Let's configure an identity called alice
. You can use any name you want, but it might be nice to have some named identities that you can use for testing, such as alice
, bob
, and carol
.
stellar keys generate --global alice --network testnet
You can see the public key of alice
with:
stellar keys address alice
You can use this link to verify the identity you create for the testnet.