Hot answers tagged

11

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 containing lots of more or less independent data and you don't want to read / write all of the data at once but only a small part of it. Think of crypto-kitties,...


8

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"' of type address This will print hashes in bunch of different formats - you want the one with the label Script-expression-ID-Hash, e.g. ...


7

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; UNPAIR; DIP { SOME }; UPDATE; NIL operation; PAIR; }; (this is the big_map version, the map version is the same with the type "bigmap" ...


5

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

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/contracts/<contract address>/big_map_get. Actually, you do not need to know the big map index, if several big_maps with the same type of keys are stored, ...


4

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/{hash} returns an object with a key bigmap_ids which is an array) see https://api.babylonnet.tzstats.com/explorer/contract/KT1E5toJrALhVPuKpHWTbRVjgEvWWR98sVKj ...


4

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-client -l get big map value for 1 of type nat in KT1Qu32f8N5RLPoku5n8itiGaJ1a3eJDj5gu ... >>>>2: http://localhost:18731/chains/main/blocks/head/context/...


4

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 need to provide not the readable key you stored, but a hash of that key as that is how it is represented internally. This answer describes how to call the RPC The ...


4

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 easily get the number of keys with a fetch call to api.better-call.dev/v1/bigmap/${network}/${big_map_id}/keys (the big map ID should be available in Taquito by ...


3

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 KT1EMy5cDrUQgNYZgtN4wX2n39MBqHGQQCiK does. If you use type big_map somewhere else it gets translated into a regular map.


2

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 can page through the result with limit and offset parameters (default is 100 entries, max is 500). See our bigmap docu for more details and examples. If you ...


2

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 error and assign your value. We will change the behaviour of get to return undefined on the unknown key. I will update this issue when it is released. You can ...


2

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 the SmartPy documentation: e.values(): Returns the list of values of a map, sorted by keys. Here, I presume that map refers exclusively to normal, "simple" ...


2

Quick way (using Pytezos library): >>> from pytezos.michelson.pack import get_key_hash >>> get_key_hash({"string": "KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn"}, {"prim": "address"}) 'exprvAHu1SyoiSzyh9w7GPfifvyrNiMb442y7Q2MA8tcPCGPajxRH6' Where first argument is the key (Micheline JSON), and the second ...


1

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 packedKey = TezosMessageUtils.encodeBigMapKey(Buffer.from(TezosMessageUtils.writePackedData(secretHash, "bytes"), "hex")); You need to put the ...


1

@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 accumulate the sum. This is introduced by total = sp.newLocal('total', ...). What the error is telling you is that your v is escaping it`s scope. With 1, we ...


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