What if @BerrryComputer could build NEAR apps? Let's dream together!
Describe what kind of NEAR app you'd love to see built...
Seamless NEAR wallet integration
Deploy and interact with contracts
Handle NEAR token transfers
Create and manage NFTs
Experience what NEAR wallet integration could feel like...
Let's make some noise and show there's interest!
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::{env, near_bindgen, AccountId, Balance};
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize)]
pub struct BerryMarket {
owner: AccountId,
berry_price: Balance,
}
impl Default for BerryMarket {
fn default() -> Self {
Self {
owner: env::predecessor_account_id(),
berry_price: 1_000_000_000_000_000_000_000_000, // 1 NEAR
}
}
}
#[near_bindgen]
impl BerryMarket {
pub fn buy_berry(&mut self) -> String {
let buyer = env::predecessor_account_id();
let amount = env::attached_deposit();
assert!(amount >= self.berry_price, "Not enough NEAR for berry!");
format!("🍓 {} bought a delicious berry!", buyer)
}
pub fn get_berry_price(&self) -> Balance {
self.berry_price
}
}