Skip to content
/ helloink Public template

This repository contains a minimal ink! smart contract written in Rust that demonstrates key concepts and serves as a companion repo for the tutorial linked below. It contains a devcontainer config with rust, cargo and pop-cli pre-installed.

License

Notifications You must be signed in to change notification settings

anataliocs/helloink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ink Contract banner

helloink — ink! smart contract (Rust)

Polkadot badge Polkadot badge


Overview

A minimal ink! smart contract written in Rust. The contract stores a single boolean in on-chain storage and provides:

  • Constructor: new(init_value: bool) — initializes the stored value.
  • Message: flip() — toggles the stored boolean.
  • Message: get() -> bool — returns the current value.

The contract is implemented in lib.rs using the #[ink::contract] macro and includes unit tests and optional end-to-end (E2E) tests using ink_e2e.

Config

The included .devcontainer config creates a GitHub codespace pre-installed with Rust, Cargo, and the Pop CLI so you can hit the ground running. Learn more about Devcontainers.

Start up a Github Codespace or perform the local config steps below:

https://use.ink/docs/v6/getting-started/setup

Quickstart

Build the contract:

pop build --release

Run the unit tests:

pop test

Deploy to local:

  • Spins up a local ink node
  • You will have to download the local ink binary during the first run
pop up --path . \
  --constructor new \
  --args true \
  --suri //Alice \
  --url ws://localhost:9944

Shut down the local node:

You can use this script

./scripts/shut-down-ink-node.sh

Invoke deployed contract:

  • After deploying your contract, update the hash passed into the --contract flag below:
  • This will invoke the flip message on the deployed contract on your local node
 pop call contract --path . \
 --contract 0x5801b439a678d9d3a68b8019da6a4abfa507de11 \
 --message flip \
 --url ws://localhost:9944/ \
 --suri //Alice \
 --execute

Read the Current Contract Storage Value

  • After deploying your contract, update the hash passed into the --contract flag below:
  • This retrieves and displays the current state of the boolean storage variable
pop call contract --path . \
--contract 0x124954f324ab6253b8efc74c3073a7e88338cda5 \
--message value \
--url ws://localhost:9944/

Tech stack

  • Rust (edition 2024)
  • ink! 6.0.0-beta.1
  • Cargo

Key Features

  • Contract module: helloink (in lib.rs)
    • Storage: Helloink { value: bool }
    • Constructor: new(init_value: bool) -> Self
    • Messages:
      • flip(&mut self) — toggles value
      • get(&self) -> bool — reads value

License

This project is licensed under the MIT License. See the LICENSE file for details.


Polkadot badge

About

This repository contains a minimal ink! smart contract written in Rust that demonstrates key concepts and serves as a companion repo for the tutorial linked below. It contains a devcontainer config with rust, cargo and pop-cli pre-installed.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published