Skip to main content

Vara Examples

This section contains a set of examples that can be used for familiarization with writing programs on Vara or as the basis for dApps: https://github.com/gear-foundation.

Programs can be written from scratch or built from provided examples.

Stable Environment

All program examples and JS applications have been tested in a stable environment with specific development tool versions necessary for implementing, building, and running programs and JS applications.

The latest releases of Gear librarires are avaible in the GitHub.

note

Stay up to date with the latest releases and updates from the development team by subscribing to this Telegram channel - https://t.me/GearVaraDev.

Compiler ToolsVersionHow to install / access
Linux users should generally install GCC and Clang, according to their distribution’s documentation.Latest

For example, on Ubuntu use:

sudo apt install -y build-essential clang cmake curl

On macOS, install a compiler toolset by running:

xcode-select --install
Ruststable

Install Rustup to get Rust compiler ready:

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

Add Wasm target to the toolchain:

rustup target add wasm32-unknown-unknown
Gear Sails librarylatest

Install the latest version of Sails library:

cargo install sails-cli
Gear Rust libraries: gstd, gtest, gclient, gear-wasm-builderlatest

The latest version is tagged in the Cargo.toml file autmatically when creating a new program (for example named 'vara-app'):

cargo sails new-program vara-app
Vara Network Testnetlatest

Ensure connection to the Vara Network Testnet. Switch networks by clicking on the network name in https://idea.gear-tech.io

Gear JS ToolsVersionHow to install / access
Gear JS API0.38.1Ensure this version is specified in the package.json file of the program repository
Sails JS0.1.8Ensure this version is specified in the package.json file of the program repository
Gear JS React Hooks0.13.0Ensure this version is specified in the package.json file of the program repository
Vara UI Kit0.0.11Ensure this version is specified in the package.json file of the program repository
Note

Windows users may encounter problems related to the installation of Rust components and dependencies. It is highly recommended to use Linux or macOS for compiling Vara nodes and programs.

First Steps

  • Create a new project (named, for example - vara-app) by running:

    cargo sails new-program vara-app

    Your vara-app directory tree should look like this

    vara-app

    ├── app
    │ └── src
    │ └── lib.rs

    ├── client
    │ └── ...

    ├── src
    │ └── lib.rs

    ├── tests
    │ └── gtest.rs

    ├── build.rs

    ├── Cargo.toml

    └── README.md

    Cargo.toml file is a project manifest in Rust. The essential libraries required for compiling a project are automatically included there.

  • Write your program's code

  • Compile the Wasm program in the app folder:

    cargo build --release

Refer to Getting Started for additional details.