4

Babylon will have a new RPC to query big map value according to this link http://tezos.gitlab.io/babylonnet/api/rpc.html#get-block-id-context-big-maps-big-map-id-script-expr

I tried using it with a new contract. I deployed this contract https://babylonnet.tzscan.io/KT1DT9YwHdSbZuVuZDjd1SMUcfXm57R5bE9v

If I understood correctly, the id of my big map should be 22

Knowing that my big map got initialized with a key tz1bwsEWCwSEXdRvnJxvegQZKeX5dj6oKEys

What is the correct way to get the value using either the cli or rpc?

I have tried:

tezos get element tz1bwsEWCwSEXdRvnJxvegQZKeX5dj6oKEys of big map 22

http://babylonnet-node.tzscan.io/chains/main/blocks/head/context/big_maps/22/tz1bwsEWCwSEXdRvnJxvegQZKeX5dj6oKEys

Both do not work. If I understand correctly, I will probably need to encode my key. I am unsure about what the required encoding is and can't seem to find an example that works.

1

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, they will all be searched for the key.

1

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. exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN.

Then you can use this with the CLI:

tezos-client get element exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN of big map 22

and RPC at:

/chains/main/blocks/head/context/big_maps/22/exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.