Passionate about building scalable web applications and innovative blockchain solutions.
I specialize in creating robust, secure, and user-friendly applications that bridge traditional web development with cutting-edge blockchain technology.
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::{env, near_bindgen};
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize)]
pub struct Counter {
value: i32,
}
// Default implementation
impl Default for Counter {
fn default() -> Self {
Self { value: 0 }
}
}
#[near_bindgen]
impl Counter {
// Increment the counter
pub fn increment(&mut self) {
self.value += 1;
env::log_str(&format!("Counter incremented to {}", self.value));
}
// Decrement the counter
pub fn decrement(&mut self) {
self.value -= 1;
env::log_str(&format!("Counter decremented to {}", self.value));
}
// Get the current value
pub fn get_value(&self) -> i32 {
self.value
}
}