Build
Move examples

Example guides

Here are all Rooch examples introduction and source code indices.

About the sample project naming explanation

Rooch provides the command rooch move new to automatically create and initialize projects. When we want to write a new contract project, we can use this command to simplify our initialization work.

We can use any legal character as the project name, including -, but when we use a project name with -, the rooch move new command will automatically use the project name as the address of this project.

For example:

move rooch new hello-world

However, - is not a legal character for naming addresses (variables), so after we create the project using rooch move new, be sure to check the project address alias in the Move.toml file for illegal characters.

Use rooch move new to create a project (name) with -. We recommend manually modifying the Move.toml file and replacing - with _.

Another way is to directly use _ as the hyphen for the project name word when creating the project.

For example:

move rooch new hello_world

In Rooch's examples, the names of the projects we create use _ connection. As for the actual development, which style to use, please decide according to your preferences.

When we contribute a example to examples, after using rooch move new to initialize the project, in addition to replacing the project address of the Move.toml file with _ wildcards, we also need to add a [dev-addresses] table and fill in a field for unit testing. address.

The [dev-addresses] table not added to examples/quick_start_counter/Move.toml:

BUILDING quick_start_counter
Success
    Finished dev [unoptimized + debuginfo] target(s) in 0.53s
     Running `target/debug/rooch move test -p examples/quick_start_counter`
thread 'main' panicked at 'resolve package dep failed: Unresolved addresses found: [
Named address 'quick_start_counter' in package 'quick_start_counter'
]
To fix this, add an entry for each unresolved address to the [addresses] section of examples/quick_start_counter/Move.toml: e.g.,
[addresses]
Std = "0x1"
Alternatively, you can also define [dev-addresses] and call with the -d flag', crates/rooch/src/commands/move_cli/commands/unit_test.rs:64:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Process completed with exit code 101.

Basic object

This example introduces how to use the Rooch object.

Source code

basic_object (opens in a new tab)

Blog

This example introduces how to use a low-code tool to develop a blog sample application.

Source code

blog (opens in a new tab)

Coins

Source code

coins (opens in a new tab)

Complex struct

Source code

complex_struct (opens in a new tab)

Counter

Source code

counter (opens in a new tab)

Event

Source code

event (opens in a new tab)

KV store

Source code

kv_store (opens in a new tab)

Module init

Source code

module_init (opens in a new tab)

Noop auth validator

Source code

noop_auth_validator (opens in a new tab)

Private generics

Source code

private_generics (opens in a new tab)

References

Read private generic functions in one article (opens in a new tab)

Publish modules

Source code

publish_modules (opens in a new tab)

Simple blog

Source code

simple_blog (opens in a new tab)

Steal split

Source code

steal_split (opens in a new tab)