Skip to main content
Version: 0.9.1

Bigmaps

Bigmaps are key-value stores where smart contracts keep large amounts of data. Values in bigmaps are accessed by unique keys. The TzStats bigmap index supports different keys, a hash (script expression hash) and the native typed version of a key. For convenience, both variants are present in responses as hash and key.

Types A bigmap is defined by a key_type and a value_type. While the key type is most often a simple type (int, string, bytes, address, etc) it can also be an object. Values are represented as unfolded (decoded) form and optionally as original Michelson primitives.

Unfolding uses Micheline type annotations from the smart contract to decompose native primitives into nested JSON objects. Annotations become JSON property names. To request the original Micheline primitives, add query parameter prim=1 (bool).

Packed Data When data is packed using the PACK instruction, an unpacked version can be obtained with the unpack=1 (bool) query argument. In this case both key and value contain the unpacked version. We also try to recursively unpack all embedded values of type bytes so that URLs, names and other packed data becomes easier to access.

Metadata Each bigmap entry comes with a set of metadata that describes its latest update time, block hash and height as well as the bigmap id and its owner contract.

Pagination The Bigmap API support paginated queries for keys, values and updates using limit and cursor or offset.

Historic Values To query a bigmap at a certain point in time add the block (int64|hash) query argument. Using block hashes is reorg-aware, i.e. in case you execute a query on a block that becomes orphaned, the API returns a 409 Conflict error.

Use since (int64|hash) argument to query for changes after a block.

Security Warning​

danger

Unlike typical on-chain data where values and ranges are predictable the contents of bigmaps is user-controlled and unpredictable. IT MAY CONTAIN MALICIOUS DATA INTENDED TO ATTACK YOUR APPLICATIONS AND USERS! Sanitize data before processing or displaying it.

Bigmap Info​

GET /explorer/bigmap/{id}

Returns information about the identity and type of a bigmap. At access native Micheline type info, add prim=1 (boolean)

FieldDescription
alloc_block hashHash of the block where the bigmap was allocated.
alloc_height int64Height when the bigmap was allocated.
alloc_time datetimeTimestamp when the bigmap was allocated.
bigmap_id int64Unique on-chain id of this bigmap.
contract hashContract that owns the bigmap.
key_type objectTypedef describing bigmap keys.
value_type objectTypedef describing bigmap values.
n_keys int64Current number of live keys in bigmap.
n_updates int64Total update count.
update_height int64Last update height.
update_block hashHash of the block containing the latest update.
update_time datetimeLast update timestamp.
delete_height int64Height of bigmap deletion (when bigmap was fully removed)
delete_block hashHash of block containing the deletion.
delete_time datetimeDeletion timestamp.
key_type_prim objectNative Micheline type for key.
value_type_prim objectNative Micheline type for value.

Bigmap Values​

GET /explorer/bigmap/{id}/values
GET /explorer/bigmap/{id}/{key}

Lists key/value pairs in bigmaps with optional metadata, native primitives and unpacking. The second variant returns a single bigmap value stored at key if exists. Key can be a key hash (script expr hash) or the native key representation (i.e. an address or integer). For pair keys, separate the pair's elements with comma. Supports

  • paging with limit and cursor / offset
  • historic key listing using block (int64|hash)
  • native Micheline primitives prim=1
  • unpacking of packed data withh unpack=1
FieldDescription
key polymorphThe native representation of the key. Integers are bigints wrapped in strings, other types are rendered according to type rules, e.g. addresses, keys and signatures are base58check encoded, timestamps are ISO8601, etc).
key_hash hashThe script expression hash for this key.
value objectUnfolded and optionally unpacked value, such as simple string or nested JSON objects/arrays to represent records, lists, sets, and maps.
meta objectMetadata for the current bigmap entry (optional, use meta=1).
meta.contract hashContract that owns the bigmap.
meta.bigmap_id int64Unique on-chain id of this bigmap.
meta.time datetimeUpdate timestamp for this key/value pair.
meta.height int64Update height for this key/value pair.
key_prim objectNative Micheline primitive for key (optional, use prim=1).
value_prim objectNative Micheline primitive for value (optional, use prim=1).

Bigmap Updates​

GET /explorer/bigmap/{id}/updates
GET /explorer/bigmap/{id}/updates/{key}

List historic updates to a bigmap in chronological order, including keys that have been deleted. The second variant lists updates for a specific key only.Key can be a key hash (script expr hash) or the native key representation (i.e. an address or integer). For pair keys, separate the pair's elements with comma. Supports

  • paging with limit and cursor / offset
  • native Micheline primitives prim=1
  • unpacking of packed data withh unpack=1
FieldDescription
action enumUpdate kind, one of alloc, update, remove, copy.
bigmap_id int64Unique on-chain id of this bigmap.
key polymorphThe native representation of the key. Integers are bigints wrapped in strings, other types are rendered according to type rules, e.g. addresses, keys and signatures are base58check encoded, timestamps are ISO8601, etc).
key_hash hashThe script expression hash for this key.
value objectUnfolded and optionally unpacked value, such as simple string or nested JSON objects/arrays to represent records, lists, sets, and maps.
meta objectMetadata for the current bigmap entry (optional, use meta=1).
meta.contract hashContract that owns the bigmap.
meta.bigmap_id int64Unique on-chain id of this bigmap.
meta.time datetimeUpdate timestamp for this key/value pair.
meta.height int64Update height for this key/value pair.
meta.block hashHash of the block containing the latest update.
key_prim objectNative Micheline primitive for key (optional, use prim=1).
value_prim objectNative Micheline primitive for value (optional, use prim=1).
source_big_map int64Source bigmap copied (only for action=copy).
destination_big_map int64Destination bigmap created (only for action=copy).