Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions templates/new/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@

use ink_lang as ink;

#[ink::contract(version = "0.1.0")]
#[ink::contract]
mod {{name}} {

/// Defines the storage of your contract.
/// Add new fields to the below struct in order
/// to add new static storage fields to your contract.
#[ink(storage)]
struct {{camel_name}} {
pub struct {{camel_name}} {
/// Stores a single `bool` value on the storage.
value: bool,
}

impl {{camel_name}} {
/// Constructor that initializes the `bool` value to the given `init_value`.
#[ink(constructor)]
fn new(init_value: bool) -> Self {
pub fn new(init_value: bool) -> Self {
Self { value: init_value }
}

/// Constructor that initializes the `bool` value to `false`.
///
/// Constructors can delegate to other constructors.
#[ink(constructor)]
fn default() -> Self {
pub fn default() -> Self {
Self::new(Default::default())
}

/// A message that can be called on instantiated contracts.
/// This one flips the value of the stored `bool` from `true`
/// to `false` and vice versa.
#[ink(message)]
fn flip(&mut self) {
pub fn flip(&mut self) {
self.value = !self.value;
}

/// Simply returns the current value of our `bool`.
#[ink(message)]
fn get(&self) -> bool {
pub fn get(&self) -> bool {
self.value
}
}
Expand Down