#[near_bindgen]
Expand description
This macro is deprecated. Use near instead. The difference between #[near]
and #[near_bindgen]
is that
with #[near_bindgen]
you have to manually add boilerplate code for structs and enums so that they become Json- and Borsh-serializable:
use near_sdk::{near_bindgen, NearSchema, borsh::{BorshSerialize, BorshDeserialize}};
#[near_bindgen]
#[derive(BorshSerialize, BorshDeserialize, NearSchema)]
#[borsh(crate = "near_sdk::borsh")]
struct MyStruct {
pub name: String,
}
Instead of:
use near_sdk::near;
#[near(serializers=[borsh])]
struct MyStruct {
pub name: String,
}