14
votes
Accepted
What is the BigMap container and why does it matter?
The BigMap container is a special map (dictionary) whose storage is only read or written per key on demand.
The motivation to have such a container is the following. Suppose that you have a contract ...
8
votes
Accepted
How to get big map value on Babylon
The new CLI and RPC for big map expect hash of a script expression, instead of the raw expression. To obtain the hash you can e.g.:
tezos-client hash data '"tz1bwsEWCwSEXdRvnJxvegQZKeX5dj6oKEys&...
7
votes
Accepted
Relative gas cost of map vs bigmap
Let's find out. We start by running a sandbox node. We'll originate two contracts, one for maps, the other for bigmap.
parameter (pair address nat);
storage (big_map address nat);
code
{
UNPAIR;
...
6
votes
How to get big map value on Babylon
The cli command is tezos-client get big map value for <key> of type <type of the key> in <contract>. By adding the -l option, we also get the RPC: /chains/main/blocks/head/context/...
6
votes
Accepted
How to retrieve data from smart-contract using javascript?
As of the current Babylon protocol and the upcoming Carthage, the RPC only provides you the ability to retrieve the value for a known key that you provide to the RPC. But even in this scenario you ...
5
votes
Accepted
How do I get the storage value of a bigmap using pair datatype as key with taquito library?
As of Taquito release v6.1.0-beta.0 Taquito offers a new API for Maps which support pairs as keys in Maps and BigMaps.
Here's a link to documentation & examples on Accessing Map values using Pairs
5
votes
How do I get the contents of a big_map through the RPC interface?
As of 004_Pt24m4xi:
You can use the big_map_get RPC to get individual values out.
There is also a tezos-client command for this. (By passing -l we can see how it works through the RPC.)
$ tezos-...
4
votes
Accepted
How do you discover the indexes of the big maps of a contract?
The tezos-client and tezos-node RPC have no such feature.
If you don't mind using an API other then the node RPC you can find this in the new version of the tzstats indexer (GET /explorer/contract/{...
4
votes
Accepted
Get number of entries in bigmap
This is not something you will be able to achieve with Taquito (at least not for now, that will change in the future) and you have to use an indexer API. I recommend Better Call Dev API, you can ...
3
votes
Accepted
Why is this big map update using up so many bytes?
big_map is extremely expensive. It allows you to put as much data as you want in the contract, but you end up paying more in counterpart.
Check this example:
It produces 2 identical contacts, one uses ...
3
votes
Accepted
Big maps in Zeronet
AFAIK a restriction in Athens is that a bigmap must be first element in the storage definition. Thats why KT1JPvBo4Sv7n1WDzcKWEXTVRDU9HQhaZdzd does not have a bigmap but ...
3
votes
How to retrieve data from smart-contract using javascript?
We maintain an index of all historic bigmap data at TzStats. To fetch all current keys and values in a bigmap call
https://api.tzstats.com/explorer/bigmap/:id/values
If your bigmap is very large you ...
3
votes
Can I iterate over a big_map using Taquito?
It is not possible using Taquito alone. You must use an indexer to extract all the key/value pairs from a big map (Better Call Dev is developed by Baking Bad who also offers an indexer API).
This will ...
2
votes
Accepted
How to total smartpy.TMutez type stored as values in smartpy.bigmap?
There is no way of iterating over all values in a big_map in the language to which SmartPy compiles (Michelson). So it doesn't surprise me that this doesn't work in SmartPy either. Indeed, according ...
2
votes
bigmap.get(key, "") with default param in case of no entry for key in the map with Taquito
As of Taquito release v6.1.0-beta.0 Taquito offers a new API for Maps which provides you with get and set calls.
The API does not offer an optional default value param, You will have to catch the ...
2
votes
Accepted
how do you find the action of a big map diff from RPC JSON?
If RPC's bigmap diff doesn't contain value, like this:
{
"key_hash": "exprv5CuRy2eC8Z7n2KyRX4wyHDSFPosiRqL4cQTRqErC358jpYj7X",
"key": {
"bytes": "...
2
votes
Accepted
Are bigmaps stored on-chain or off-chain?
big_maps are stored lazily onchain. Regarding using information from inside a big_map inside an onchain view, you can do that, but you can't have the view return the whole big_map, only specific ...
2
votes
Accepted
How to access Big Map value for a specific key
Quick way (using Pytezos library):
>>> from pytezos.michelson.pack import get_key_hash
>>> get_key_hash({"string": "KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn"}, {"...
1
vote
dump entire bigmap as key/value pairs
You can do that with TzKT API: https://api.tzkt.io/#operation/BigMaps_GetKeys. However, if there are more than 10k keys, you will still have to do multiple requests (i.e. paginate), because the max ...
1
vote
Accepted
How do I query a BigMap using Netezos?
I was kindly answered on the Netezos support chat on Discord.
The first answer was to simply use the tzkt API, I won't detail that part because it's well documented.
The second answer was given ...
1
vote
Are bigmaps stored on-chain or off-chain?
BigMaps are indeed stored on-chain. There is no IPFS integration in Tezos.
See this previously answered question about fetching bigmap data from the chain.
1
vote
Is it possible to get all big_map keys using node RPC?
Big map keys are not stored so a tezos-node has no way to provide them.
1
vote
Why is this big map update using up so many bytes?
The main benefit of big_maps with respect to maps is that the gas costs of big_map operations don't depend on the number of elements stored in the big_map.
Regarding storage size, when you store a key-...
1
vote
Accepted
How to fetch all the values in a big map using taquito?
You have 2 solutions for this problem:
Use an indexer to get the values contained in the big map;
Use an off-chain view to paginate the values if they can be accessed sequentially
Off-chain example:
...
1
vote
Accepted
If you query storage or big map at block X does it include changes from operations of block X?
Yes, the context queried in the RPC is the context resulting from the
operations in that block. This can be demonstrated thus:
Consider the contract store_string.tz:
parameter string ;
storage (option ...
1
vote
Accepted
What is script_expr?
What is script_expr?
Prior to the Babylon protocol, a contract could only have one big map. This big
map had to be located in a storage structured like this: or (big_map ...) ....
There is a ...
1
vote
What is script_expr?
script_expr in this RPC means any Michelson expression. It is used to specify the key of the big_map that the RPC queries.
1
vote
How to access Big Map value for a specific key
I ended up using ConseilJS for this. I used the TezosMessageUtils.encodeBigMapKey function in ConseilJS to create the hash key. Here's an example of how to convert the key to the hash :
const ...
1
vote
How to total smartpy.TMutez type stored as values in smartpy.bigmap?
@arvidj is right of course and you cannot iterate on a bigmap. You need to keep your sum in the storage.
You also have another error: if it was a map, you would still need to use a local variable to ...
1
vote
How do you discover the indexes of the big maps of a contract?
If you are using the RPC you have to query all the block ids since the origination of the contract and collect the big_map_diff's from the contract's applied transactions. This is a slow process so ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
bigmap × 26smart-contracts × 9
rpc × 7
storage × 6
taquito × 5
smartpy × 4
michelson × 4
gas × 2
performance × 2
tezos-client × 1
ledger × 1
contract × 1
api × 1
javascript × 1
key × 1
testing × 1
dapps × 1
truffle × 1
python × 1
json × 1
zeronet × 1
dry-run × 1
ipfs × 1
entrypoint × 1
lazy-entrypoint × 1