如何在巴比伦获得大地图价值
2 个回答
- 投票数
-
- 2019-10-16
新的 CLI 和 RPC 适用于大型地图脚本表达式的哈希,而不是原始表达式.要获取哈希,您可以例如:
tezos-client hash data '"tz1bwsEWCwSEXdRvnJxvegQZKeX5dj6oKEys"' of type address
这将以多种不同的格式打印哈希-您想要带有标签
Script-expression-ID-Hash
的哈希,例如exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN
.然后您可以在CLI中使用它:
tezos-client get element exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN of big map 22
和RPC位于:
/chains/main/blocks/head/context/big_maps/22/exprv6UsC1sN3Fk2XfgcJCL8NCerP5rCGy1PRESZAqr7L2JdzX55EN
编辑:
已添加新的CLI命令以简化大地图的访问:
tezos-client get big map value for '"tz1bwsEWCwSEXdRvnJxvegQZKeX5dj6oKEys"' of type address in <src>
其中
<src>
可以是别名,键或文字(在您的情况下为KT1DT9YwHdSbZuVuZDjd1SMUcfXm57R5bE9v
).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
Edit:
A new CLI command has been added for simpler big map access:
tezos-client get big map value for '"tz1bwsEWCwSEXdRvnJxvegQZKeX5dj6oKEys"' of type address in <src>
where
<src>
can be an alias, a key, or a literal (in your caseKT1DT9YwHdSbZuVuZDjd1SMUcfXm57R5bE9v
).-
也许值得一提的是为什么这已经改变了.1)对于此查询,使用GET而不是POST在语义上更加合理,此查询仅请求数据,并且不更改后端的任何内容.2)在迦太基网络之前,合同只能有一张大地图,而现在它可以有多张大地图.每个大地图都有唯一的识别码.It might be worth mention why this has changed. 1) Using GET instead of POST for this query is semantically more sound, this query only requests data and does not change anything on the backend. 2) Before Carthagenet, a contract could only have one big map, now it can have multiple big maps. Each of those big maps have a unique identifying key.
- 0
- 2020-06-18
- MCH
-
- 2019-10-15
cli命令是
tezos-client get big map value for <key> of type <type of the key> in <contract>
中.通过添加-l
选项,我们还获得了RPC:/chains/main/blocks/head/context/contracts/<contract address>/big_map_get
.>实际上,您不需要知道大地图索引,如果存储了多个具有相同键类型的big_map,则将全部搜索它们以寻找键.
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.
-
"获取大地图值"列为现在已弃用=(`get big map value` is listed as deprecated now =(
- 0
- 2020-03-02
- Justin
-
我会说,"获得巨大的地图价值"对于开发过程而言要容易得多.我仍然看到许多合同设计为即使它们已被弃用,它们也可以继续使用此命令.当然,它仅适用于位于合约存储顶部的一对左侧的大地图.I will say `get big map value` is much easier for the development process. I still see a lot of contracts designed such that they can continue using this command even though it is listed as deprecated. Of course, it only works for a big map that is in the left side of a pair at the top of a contracts storage.
- 0
- 2020-06-18
- MCH
巴比伦将根据此链接使用新的RPC查询大地图值 http://tezos.gitlab.io/babylonnet/api/rpc.html#get-block-id-context-big-maps-big -map-id-script-expr
我尝试将其与新合同一起使用.我已部署此合同 https://babylonnet.tzscan.io/KT1DT9YwHdSbZuVuZDjd1SMU>
如果我理解正确,那么我的大地图的ID应该为
22
知道我的大地图已用键
初始化了tz1bwsEWCwSEXdRvnJxvegQZKeX5dj6oKEys
使用cli或rpc获取值的正确方法是什么?
我尝试过:
tezos get element tz1bwsEWCwSEXdRvnJxvegQZKeX5dj6oKEys of big map 22
http://babylonnet-node.tzscan.io/chains/main/blocks/head/context/big_maps/22/tz1bwsEWCwSEXdRvnJxvegQZKeX5dj6oKEys
两者都不起作用.如果我理解正确,则可能需要对密钥进行编码.我不确定所需的编码是什么,而且似乎找不到有效的示例.