💸#[ink(payable)]
#[ink::contract]
mod flipper {
#[ink(storage)]
pub struct Flipper {
value: bool,
}
impl Flipper {
#[ink(constructor)]
pub fn new(initial_value: bool) -> Self {
Flipper { value: false }
}
/// Flips the current value.
#[ink(message)]
#[ink(payable)] // You can either specify payable out-of-line.
pub fn flip(&mut self) {
self.value = !self.value;
}
/// Returns the current value.
#[ink(message, payable)] // or specify payable inline.
pub fn get(&self) -> bool {
self.value
}
}
}Exemplo
Last updated