Skip to main content

Gear Examples

Gear provides a set of examples that can be used for your familiarization with writing programs on Gear or become the basis for your own dApp:

You can write your own smart contract or try to build from examples. Let's Rock!


To develop your first Rust smart-contract you would have to:

  • Install Rustup:

    curl --proto '=https' --tlsv1.2 -sSf | sh
  • Add wasm target to your toolchain:

    rustup toolchain add nightly
    rustup target add wasm32-unknown-unknown --toolchain nightly

First steps

To create our app project use the command cargo:

cargo new gear-app --lib

The project structure is following:

  └── gear-app // Your contract dir

├── src // Source files of your program
│ ├── // Additional module if needed
│ └── // Main file of your program

└── Cargo.toml // Manifest of your program

Create file with the following code:

fn main() {

Cargo.toml is a project manifest in Rust, it contains all metadata necessary for compiling the project. Configure the Cargo.toml similarly to how it is configured ping/Cargo.toml. You can refer to Getting Started for additional details.

Building Rust Contract

We should compile our smart contract in the app folder:

cargo build --release

Our application should compile successfully and the final file target/wasm32-unknown-unknown/release/gear-app.wasm should appear.