Skip to content

Storage (env) ​

Per-contract KV (isolated prefix). Live host uses UTF-8 string keys/values. Writes are fuel-priced and capped.

get_storage live ​

text
get_storage(key_ptr, key_len, val_ptr, val_max) → i32

Copies min(value_len, val_max) bytes to val_ptr. Missing key → length 0. Bad UTF-8/ptr → -1.

Fuel: FUEL_STORAGE_READ_BASE + PER_BYTE × len (defaults 800 + 5×len). OOG → -1.

Analogs: CosmWasm storage.get, NEAR storage_read.

set_storage live ​

text
set_storage(key_ptr, key_len, val_ptr, val_len)

Writes into overlay + storage_changes. Denied (no write) on bad UTF-8, OOG, or growth cap.

Fuel: FUEL_STORAGE_WRITE_BASE + PER_BYTE × (key+val) (defaults 5000 + 50×nbytes).

Cap: cumulative new bytes ≤ MAX_STATE_GROWTH_BYTES_PER_TX (64 KiB).

remove_storage planned ​

text
remove_storage(key_ptr, key_len) → i32

1 if existed, 0 otherwise.

storage_has planned ​

text
storage_has(key_ptr, key_len) → i32

storage_usage planned ​

text
storage_usage() → i64

Total bytes stored by this contract (NEAR-compatible).