Skip to content

Add minimal Hello World smart program (Gear)#1

Open
A-mont wants to merge 2 commits intoVara-Lab:mainfrom
A-mont:feature/auto-pr
Open

Add minimal Hello World smart program (Gear)#1
A-mont wants to merge 2 commits intoVara-Lab:mainfrom
A-mont:feature/auto-pr

Conversation

@A-mont
Copy link
Member

@A-mont A-mont commented Feb 14, 2026

What

  • Introduces a minimal Gear smart program under contracts/hello_world that replies with a friendly greeting.

Why

  • Provides a simple, self-contained example for internal training and a quick starting point to understand message handling and replies in Gear smart programs.

How

  • A no_std cdylib WASM program using gstd that:
    • Stores an optional greeting on init (default: "Hello").
    • On handle, reads a String name (default: "World") and replies with ", !".
    • On state, returns the current greeting.
  • Program is standalone and does not modify any existing workspace files. It can be built independently.

How to test

  1. Build
  • Ensure you have the wasm target: rustup target add wasm32-unknown-unknown
  • Build the program: cargo build --release --target wasm32-unknown-unknown --manifest-path contracts/hello_world/Cargo.toml
  • The compiled artifact will be at: contracts/hello_world/target/wasm32-unknown-unknown/release/hello_world.wasm
  1. Deploy (example using any Gear-compatible tool)
  • Upload the WASM to a local node or testnet via your preferred UI/tooling.
  • Init payload: optional String (SCALE-encoded). If omitted, the greeting defaults to "Hello".
  1. Interact
  • Send a handle message with a String payload (SCALE-encoded), e.g. "Alice".
  • Expected reply: "Hello, Alice!" (or using your custom greeting if set during init).
  • Query the state function to retrieve the current greeting string.

Notes

  • If your workspace requires adding crates explicitly, you can include this crate into the workspace members in the top-level Cargo.toml (not included here to keep changes minimal).
  • TODO: Add metadata generation (gmeta) and simple integration tests if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant