Version: 0.19.0

Big_map

A lazily deserialized map that's intended to store large amounts of data. "Lazily" means that storage is read or written per key on demand. Therefore there are no map, fold, and iter operations as there are in Map.

Compared to non-lazy maps, which have a high upfront gas cost to deserialize all the data and then have cheaper access costs thereafter, lazily-deserialized maps spread this cost out across each access, increasing the per-access gas costs, but providing a cheaper overall cost when only a small portion of a large dataset is needed.

let empty: big_map<'key, 'value>

Create an empty big_map.

type move = [int, int];
type register = big_map<address, move>;
let empty: register = Big_map.empty;
let literal: (items: list<['key, 'value]>) => big_map<'key, 'value>

Create a non-empty big_map.

let moves: register =
Big_map.literal (list([
[("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" as address), [1, 2]],
[("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" as address), [0, 3]]]));
let find_opt: (key: 'key, big_map: big_map <'key, 'value>) => option <'value>

Retrieve a value from a big map with the given key.

Because the key may be missing in the big map, the result is an optional value.

let my_balance: option <move> =
Big_map.find_opt(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" as address), moves);
let mem: (key: 'key, big_map: big_map <'key, 'value>) => bool

Test whether a given key exists within a big map.

let has_balance: bool =
Big_map.mem(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" as address), moves);
let update: (key: 'key, value: option<'value>, big_map: big_map<'key, 'value>) => big_map<'key, 'value>

Note: when None is used as a value, the value is removed from the big_map.

let updated_map: register =
Big_map.update
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" as address), Some([4,9]), moves);

Similar to update but it also returns the value that was previously stored in the big_map

let add: (key: 'key, value: 'value, big_map: big_map<'key, 'value>) => big_map<'key, 'value>
let add = (m: register): register =>
Big_map.add
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" as address), [4,9], m);
let remove: (key: 'key, big_map: big_map<'key, 'value>) => big_map<'key, 'value>
let updated_map: register =
Big_map.remove(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" as address), moves);