Getting Started
Getting started in 5 minutes
This guide provides a general overview of running programs on the Vara Network. It guides you through how to write a program, compile it to Wasm and deploy it to the network.
Level Up Your Skills
Want to become a pro Vara developer? 🔥
Take our interactive Sails Tutorial to master blockchain development from scratch.
Prerequisites
System dependencies
- Linux: install build tools according to your distribution.
For Ubuntu:
sudo apt install -y build-essential clang cmake curl- macOS: install Xcode Command Line Tools:
xcode-select --install- Windows: install Build Tools for Visual Studio.
Download: https://visualstudio.microsoft.com/downloads/?q=build+tools
Rust toolchain
Install Rust using Rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shFix 'Command Not Found' Error
If you just installed Rust and see command not found: rustup or cargo, your terminal needs to reload the environment.
Run this command to update your PATH:
source "$HOME/.cargo/env"Alternatively, simply restart your terminal (or VS Code) to apply the changes.
Wasm target
Add the Wasm target:
rustup target add wasm32v1-noneRequired Build Target
Starting from Gear v1.8.0, you must use the wasm32v1-none target to build programs for the Vara Network.
Note: The old wasm32-unknown-unknown target is now considered legacy and should only be used for older projects.
Creating your first Vara program
To get started, install the sails-cli tool using the following command:
cargo install sails-cliAfter installation, you can create a new Vara project named vara-app by running:
cargo sails program vara-appYour vara-app directory tree should look like this:
vara-app
│
├── app
│ └── src
│ └── lib.rs
│
├── client
│ └── ...
│
├── src
│ └── lib.rs
│
├── tests
│ └── gtest.rs
│
├── build.rs
│
├── Cargo.lock
│
├── Cargo.toml
│
└── README.mdIn Cargo.toml, the essential libraries required for building your first project have been included, for example:
[package]
name = "vara-app"
version = "0.1.0"
edition = "2024"
[dependencies]
sails-rs = "0.9.1"
vara-app-app = { version = "0.1.0", path = "app" }
[workspace]
resolver = "3"
members = ["app", "client"]
[workspace.package]
version = "0.1.0"
edition = "2024"
[build-dependencies]
sails-rs = { version = "0.9.1", features = ["build"] }
vara-app-app = { version = "0.1.0", path = "app" }
[dev-dependencies]
sails-rs = { version = "0.9.1", features = ["gtest", "gclient"] }
tokio = { version = "1.47.1", features = ["rt", "macros"] }
vara-app-app = { path = "app" }
vara-app-client = { path = "client" }Let's move on to the main code:
This Rust code defines a simple program for the Vara Network, now updated with a new structure. The program consists of a VaraAppProgram struct with a method to instantiate it and another method to return a VaraAppService struct. The VaraAppService struct has a service method that returns the string "Hello from VaraApp!". This example demonstrates the basic structure and functionality of a Vara program using the sails_rs library.
#![no_std]
use sails_rs::prelude::*;
struct Service(());
impl Service {
pub fn new() -> Self {
Self(())
}
}
#[sails_rs::service]
impl Service {
// Service's method (command)
#[export]
pub fn do_something(&mut self) -> String {
"Hello from Service!".to_string()
}
}
#[derive(Default)]
pub struct Program(());
#[sails_rs::program]
impl Program {
// Program's constructor
pub fn new() -> Self {
Self(())
}
// Exposed service
pub fn service(&self) -> Service {
Service::new()
}
}Build your program with a single command:
cargo build --releaseAfter a successful build, you can execute your tests to verify that everything is functioning correctly:
cargo test --releaseIf everything has been executed successfully, your working directory should now contain a target directory structured as follows:
vara-app
├── ...
├── target
├── ...
└── wasm32-gear
└── release
├── vara_app.wasm <---- this is our built .wasm file
├── vara_app.opt.wasm <---- this is optimized .wasm file
└── vara_app.idl <---- this is our application interface .idl filevara_app.wasmis the output Wasm binary built from source filesvara_app.opt.wasmis the optimized Wasm aimed to be uploaded to the blockchain
(Optimization include reducing the file size and improving performance)vara_app.idlis the Interface Definition Language (IDL) file that describes the application's interface, defining the structure and methods callable on thevara_appprogram. It's essential for interacting with the application on the blockchain, specifying available functions and their inputs and outputs. This file is crucial for developers and clients to ensure they use the correct method signatures and data types when interacting with the deployed program.
Deploy your program to the Testnet
Gear provides an application for developers (Gear Idea) that implements all of the possibilities of interaction with programs in Vara networks (mainnet and testnet), available at idea.gear-tech.io.
Create account
-
Download the Polkadot extension for your browser via https://polkadot.js.org/extension/. This extension manages accounts and allows the signing of transactions with those accounts. It is a secure tool that allows injecting your accounts into any Substrate-based dapp. It does not perform wallet functions, e.g send funds.
-
Once downloaded, click + button to create a new account:

-
Make sure you save your 12-word mnemonic seed securely.

-
Select the network that will be used for this account - choose "Allow to use on any chain". Provide any name to this account and password and click "Add the account with the generated seed" to complete account registration.

-
Go to idea.gear-tech.io. You will be prompted to grant access to your account for the application, click "Yes, allow this application access".

-
Make sure you are connected to the
Vara Network Testnet. The network name is at the bottom left corner of the page.
-
You may switch the network by clicking on the network name.

-
Click the
Connectbutton on the top-right to select an account that will be connected to Vara.

-
In accordance with the Actor model, programs are uploaded to a network via messages. Vara node charges a gas fee during message processing. Your account balance needs to have enough funds to upload a program to the
TestNet. Click the following button to get the test balance:
A notification about successful balance replenishment will appear after passing captcha at the bottom of the window. You can also see the current account balance next to the account name in the upper right corner.

Upload program
-
When your account balance is sufficient, click the Upload program button to open a popup window for uploading your new program.

-
In the popup, click the Select file button and navigate to the
.opt.wasmfile we have pointed to above
-
After uploading the
.opt.wasmfile, you need to upload theIDLfile. Click the Select file button and navigate to the.idlfile referenced earlier.
-
Specify the program name, click the Calculate Gas button to set the gas limit automatically, and then click the Submit button.

-
Sign the
gear.uploadProgramtransaction to Vara. It is recommended to set the checkboxRemember my password for the next 15 minutesfor your convenience.
-
Once your program is uploaded, go to the
Programssection, find your program, and select it.
-
Click on your program to see more information, such as
Metadata/Sails,Messages,Events, and theVoucherspane.
Send message to a program
-
Send your newly uploaded program a message to see how it responds! Click the Send message button.
-
Click the Calculate Gas button to set the gas limit automatically, then click the Send Message button.

-
Sign the
gear.sendMessagetransaction as it is shown in step 5 of the section Upload Program. -
After your message has been successfully processed, you will see corresponding notifications:

You have just sent a
DoSomethingcommand to your program! -
Go back to your program by either clicking the Cancel button or using the browser's back button.
-
In the message pane, you can view the corresponding response.

-
Click on the message response to see more information. The expected "Hello from VaraApp!" response can be seen in the
Payload.
Further reading
For more info about writing programs for Vara and the specifics behind the program implementation, refer to this article.