ink! is a Rust embedded domain-specific language (eDSL) targeting WebAssembly (`pallet_contracts`) and Polkadot Revive (RISC-V). ink! 5.0 provides memory-efficient cross-contract calls, constructor return flags, and e2e testing.
rust
#[ink::contract]
mod flipper {
#[ink(storage)]
pub struct Flipper {
value: bool,
}
impl Flipper {
#[ink(constructor)]
pub fn new(init_value: bool) -> Self {
Self { value: init_value }
}
#[ink(message)]
pub fn flip(&mut self) {
self.value = !self.value;
}
}
}