合同的地址格式说明
1 个回答
- 投票数
-
- 2019-02-11
签订合同时,您将"操作"发送到网络.然后将此操作序列化为字节格式,并派生一个哈希-这是给定操作的操作哈希.
如果操作生成新合同,则可以通过对操作哈希值+索引字节(从0开始)进行哈希运算来手动计算新的KT1地址.我们使用索引,因为某些操作会产生多个新的KT1地址.eztz就是这样的: https://github.com/TezTech/eztz/blob/master/src/main.js#L751
我不确定为什么要这么做-您在发起之前不需要知道新地址吗?
When your originate a contract, you send an "operation" to the network. This operation is then serialized into byte format and a hash is derived - this is the operation hash for the given operation.
If an operation generates a new contract, you can manually calculate the new KT1 address by hashing the operation hash + an index byte (starting from 0). We use an index as some operations originate multiple new KT1 addresses. This is how eztz does it: https://github.com/TezTech/eztz/blob/master/src/main.js#L751
I'm unsure why you need this though - you don't need to know the new address before originating?
-
谢谢.因此,只能计算原始合同的地址,对吗?我问是因为我正在编写迈克尔逊的口译员,并且有"地址"指令.它总是返回合同的地址(不是" option"值).这是否意味着如果合同不是起源的,就不可能将合同放在堆栈中吗? 我使用" ./alphanet.sh客户端运行脚本"进行了实验.我计算了" SELF"和" PACK"的地址.然后将这些字节传递给另一个脚本,并成功对其进行"解包".但是这个合同不是起源的.它是如何工作的?Thanks. So it's only possible to compute address of originated contract, right? I am asking because I am writing an interpreter of Michelson and there is `ADDRESS` instruction. It always returns address of a contract (not `option` value). Does it imply that it's impossible to put a contract on stack if this contract hasn't been originated? I made an experiment using `./alphanet.sh client run script`. I computed address of `SELF` and `PACK`ed. Then passed those bytes to another script and succesfully `UNPACK`ed them. But this contract is not originated. How does it work?
- 1
- 2019-02-12
- Ivan Gromakovskii
-
还有哪些操作可以发起多个KT1地址?我在规范中发现了以下操作:`CREATE_CONTRACT`,`CREATE_ACCOUNT`,`TRANSFER_TOKENS`和`SET_DELEGATE`.据我了解,第一个源于1个KT1地址,而其他操作根本不会生成KT1地址.Also which operations can originate multiple KT1 addresses? I found the following operations in the spec: `CREATE_CONTRACT`, `CREATE_ACCOUNT`, `TRANSFER_TOKENS` and `SET_DELEGATE`. As far as I understand, the first one originates 1 KT1 address and other operations don't generate KT1 addresses at all.
- 1
- 2019-02-14
- Ivan Gromakovskii
-
另外,使用哪种哈希算法?两次都是blake2b吗?Also which hashing algorithm is used? Is it blake2b both times?
- 0
- 2019-02-15
- Ivan Gromakovskii
在某处有一个规范可以解释如何计算易于理解的合同地址吗?
为了签订合同,我需要提供其代码,初始存储值和其他一些数据,然后我将获取其地址.如何计算?