Attribute Macro zink::storage

#[storage]
Expand description

Order-based storage macro. Currently only i32 is supported

use zink::storage;

#[storage]
pub type Counter = i32;

will generate:

struct Counter;

impl zink::Storage<i32> for Counter {
    // if this macro were the second one in the project, this key would be 1i32
    const STORAGE_KEY: i32 = 0i32;

    fn get() -> i32 {
        zink::ffi::evm::sload(Self::STORAGE_KEY)
    }

    fn set(value: i32) {
        zink::ffi::evm::sstore(Self::STORAGE_KEY, value);
    }
}