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.
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
- Install Brew: https://brew.sh/
- Install Rust, Cargo and Pop CLI
Build the contract:
pop build --releaseRun the unit tests:
pop testDeploy 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:9944Shut down the local node:
You can use this script
./scripts/shut-down-ink-node.shInvoke deployed contract:
- After deploying your contract, update the hash passed into the
--contractflag below: - This will invoke the
flipmessage on the deployed contract on your local node
pop call contract --path . \
--contract 0x5801b439a678d9d3a68b8019da6a4abfa507de11 \
--message flip \
--url ws://localhost:9944/ \
--suri //Alice \
--executeRead the Current Contract Storage Value
- After deploying your contract, update the hash passed into the
--contractflag 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/- Rust (edition 2024)
- ink! 6.0.0-beta.1
- Cargo
- Contract module:
helloink(inlib.rs)- Storage:
Helloink { value: bool } - Constructor:
new(init_value: bool) -> Self - Messages:
flip(&mut self)— togglesvalueget(&self) -> bool— readsvalue
- Storage:
This project is licensed under the MIT License. See the LICENSE file for details.