pub fn init()
Expand description
Initialization Methods inner #[near]
annotation. More details can be found here
By default, the Default::default()
implementation of a contract will be used to initialize a contract. There can be a custom initialization function which takes parameters or performs custom logic with the following #[init]
annotation:
§Examples
§Basic example
use near_sdk::{log, near};
#[near(contract_state)]
#[derive(Default)]
pub struct Counter {
value: u64,
}
#[near]
impl Counter {
#[init]
pub fn new(value: u64) -> Self {
log!("Custom counter initialization!");
Self { value }
}
}