Hot answers tagged

13 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 ...
user avatar
  • 3,185
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&...
user avatar
7 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 ...
user avatar
  • 1,979
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; ...
user avatar
  • 4,409
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/...
user avatar
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
user avatar
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-...
user avatar
  • 2,526
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/{...
user avatar
  • 434
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 ...
user avatar
4 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 ...
user avatar
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 ...
user avatar
3 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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 2,348
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 ...
user avatar
2 votes

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.
user avatar
  • 3,364
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"}, {"...
user avatar
1 vote

What is the guideline on when you can and cannot use lazy entrypoints, and are there any limitations to using them?

Do you know the article Understand your Bigmap from Marigold? Could be maybe helpful for your question.
user avatar
  • 141
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.
user avatar
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-...
user avatar
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: ...
user avatar
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 ...
user avatar
  • 2,348
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 ...
user avatar
  • 670
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.
user avatar
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 ...
user avatar
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 ...
user avatar
  • 3,185
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 ...
user avatar
  • 670

Only top scored, non community-wiki answers of a minimum length are eligible