如何创建交易
3 个回答
- 投票数
-
- 2019-02-07
在线上有多个参考资料,它们提供了一些材料来理解其中涉及的步骤.您可以检查此或那.其他问题中也提供了一些元素
基本上步骤是
- 获取依赖
- 分支哈希:
/chains/main/blocks/head/hash
- 计数器:
/chains/main/blocks/head/context/contracts/<source_pkh>/counter
- 协议哈希:
/protocols
- 分支哈希:
- forge操作(
/chains/main/blocks/head/helpers/forge/operations
)请注意,虽然很容易从本地客户端复制此逻辑 - 符号字节(
tezos-client sign bytes
) - 预先应用操作(
/chains/main/blocks/head/helpers/preapply/operations/)
- 将签名解码为十六进制格式
- 注入操作(
/inject/operation
)
There are multiple references online which provide material to understand the steps involved in this. You can check this or that. Some elements are also provided in this other question
Basically the steps are
- get dependencies
- branch hash:
/chains/main/blocks/head/hash
- counter:
/chains/main/blocks/head/context/contracts/<source_pkh>/counter
- protocol hash:
/protocols
- branch hash:
- forge operation (
/chains/main/blocks/head/helpers/forge/operations
) Note sure if it's easy to replicate this logic outside from the native client though - sign bytes (
tezos-client sign bytes
) - preapply operation (
/chains/main/blocks/head/helpers/preapply/operations/)
- decode signature to hexadecimal format
- inject operation (
/inject/operation
)
-
- 2019-02-07
helpers/scripts/run_operation
对于模拟无需签名的操作非常有用(您可以使用零字节进行签名),以便估算天然气和储存要求.您将在此处看到tezos-client -l
将gas_limit和storage_limit设置为最大值,然后使用结果将实际的gas_limit和storage_limit设置为(取决于用户的最大可接受的storage_limit,称为"-烧伤帽").要了解二进制操作如何编码,您可以查看
tezos-client describe unsigned operation
.helpers/scripts/run_operation
is useful to simulate an operation without signing it (you may use zero bytes for the signature), in order to estimate the gas and storage requirements. You will seetezos-client -l
setting gas_limit and storage_limit to the maximum values here, and then using the result to set the actual gas_limit and storage_limit (subject to the user's maximum acceptable storage_limit, called "--burn-cap").To learn how the operation is encoded in binary, you can see
tezos-client describe unsigned operation
.-
我注意到我的回答并不能解释为什么需要预先申请.为什么不只是run_operation?I noticed my answer does not explain why preapply is needed. Why not just run_operation?
- 0
- 2019-03-02
- Tom
-
- 2019-02-07
Easiest would be checking out how e.g.
eztz
implements transfers.Then see how the transfer operations is forged here.
And finally how the forged operation is injected here.
By the looks of it, seems like eztz's
forge
is done remotely by/helpers/forge/operations
.-
实际上eztz是在本地伪造的,但是暂时我们使用远程伪造来仔细检查我们伪造的内容是否匹配.将来,我们将删除远程伪造检查:-)Actually eztz forges locally, but for the time being we use the remote forge as a way to double check that what we forged locally matches. In future, we will remove the remote forge check :-)
- 1
- 2019-02-08
- Stephen Andrews
我试图了解创建交易操作所涉及的不同步骤.
Tezos-client -l
显示了许多RPC调用,其中:run_operation
和preapply
做什么,为什么都需要它们?此外,要注入的操作是二进制编码的,使用什么编码?(可以使用
/chains/main/blocks/head/helpers/forge/operations
获得编码,但我想自己对操作进行编码).