Crate near_sdk_macros

Source

Attribute Macros§

callbackDeprecated
callback is a marker attribute it does not generate code by itself.
callback_vecDeprecated
callback_args_vec is a marker attribute it does not generate code by itself.
ext_contract
ext_contract takes a Rust Trait and converts it to a module with static methods. Each of these static methods takes positional arguments defined by the Trait, then the receiver_id, the attached deposit and the amount of gas and returns a new Promise.
initDeprecated
init is a marker attribute it does not generate code by itself.
near
This attribute macro is used on a struct and its implementations to generate the necessary code to expose pub methods from the contract as well as generating the glue code to be a valid NEAR contract.
near_bindgen
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:
result_serializerDeprecated
result_serializer is a marker attribute it does not generate code by itself.
serializerDeprecated
serializer is a marker attribute it does not generate code by itself.

Derive Macros§

BorshStorageKey
BorshStorageKey generates implementation for BorshIntoStorageKey trait. It allows the type to be passed as a unique prefix for persistent collections. The type should also implement or derive BorshSerialize trait.
EventMetadata
NOTE: This is an internal implementation for #[near_bindgen(events(standard = ...))] attribute.
FunctionError
FunctionError generates implementation for near_sdk::FunctionError trait. It allows contract runtime to panic with the type using its ToString implementation as the message.
NearSchema
NearSchema is a derive macro that generates BorshSchema and / or JsonSchema implementations. Use #[abi(json)] attribute to generate code for JsonSchema. And #[abi(borsh)] for BorshSchema. You can use both and none as well.
PanicOnDefault
PanicOnDefault generates implementation for Default trait that panics with the following message The contract is not initialized when default() is called. This is a helpful macro in case the contract is required to be initialized with either init or init(ignore_state).