如何进行离线交易?
1 个回答
- 投票数
-
- 2019-01-30
Tezos中包含的所有交易必须引用过去60个区块哈希内的区块哈希.除了达成共识之外,这还充当了链公证的另一层,但这意味着您需要一些额外的步骤来离线签署交易.
一种方法是使用RPC:
/chains/main/blocks/head/helpers/forge/operations
此处.
为此,您需要一个运行中的节点,但是不必为此而将其连接到Internet.您还需要手动提供最近区块的哈希值.
您必须对从数据中获取的数据进行签名,才能获得"签名操作",但遗憾的是,CLI尚不支持该操作.然后您需要签署操作,您可以使用tezos cli与
./tezos-client sign bytes <bytes> for <src>
您将需要在操作之前添加" 03"字节.这充当签名者的水印.
最后,您需要将签名和未签名的操作结合起来,不幸的是CLI尚不支持.
另一种方法是使用智能合约,该合约接受已签名的迈克尔逊数据并根据该数据采取措施(例如,将资金发送到参数中指定的地址).这种方法的好处是,在对消息本身进行签名时,您不需要知道最近的哈希.您可以在命令中使用tezos cli
./tezos-client typecheck data <data> against type <type>
跟着
./tezos-client sign bytes <data> for <src>
然后,您将必须通过常规交易将此消息发送到智能合约,但是可以使用仅控制非常少量资金(只需支付交易费用)的密钥来执行该交易.
All transactions included in the Tezos must reference a block hash within the past 60 block hashes. This acts as an additional layer of notarization of the chain, besides the consensus but it means you need a few extra steps to sign transactions offline.
One way to do this is to use the RPC:
/chains/main/blocks/head/helpers/forge/operations
Documented here.
You need a running node for this, but it doesn't have to be connected to the Internet for this. You will also need to manually provide the hash of a recent block.
You'll have to sign the data you get out of it to get a "signed operation" but, unfortunately, that is not supported in the CLI yet.You then need to sign the operation, which you can do using the tezos cli with
./tezos-client sign bytes <bytes> for <src>
You will need to add the "03" byte in front of the operation. This acts as a watermark for the signer.
Finally you need to combine the signature and the unsigned operation, unfortunately that is not supported in the CLI yet.
Another way is to use a smart-contract that accepts signed Michelson data and takes action based on it (for instance, send funds to an address specified in the parameters). The benefit of this approach is that you do not need to know a recent hash when signing the message itself. You can just use the tezos cli with the command
./tezos-client typecheck data <data> against type <type>
followed by
./tezos-client sign bytes <data> for <src>
You will then have to send this message to the smart contract with a regular transaction, but that transaction can be performed with a key that only controls a very small amount of funds, just what is needed to pay for the transaction fee.
-
"不幸的是,CLI尚不支持".确实可以为
`签名字节0x03 ...,而不是(在第二种情况下)为 签名字节0x05..... "unfortunately, that is not supported in the CLI yet" -- One can indeed `sign bytes 0x03... for`, rather than (in the second situation) `sign bytes 0x05... for `. - 0
- 2019-01-30
- Tom
-
啊,我不确定"签收"是否适用于0x03,它会产生有效的签收交易吗?ah, I wasn't sure if "sign for" worked for 0x03, does it produce a valid signed transaction?
- 0
- 2019-01-30
- Arthur B
-
仍然没有给您签名的操作still doesn't give you a signed operation though
- 1
- 2019-01-30
- Arthur B
-
谢谢@ArthurB:thumbsup:我想使用CLI是一种安全且"官方"的方式.但是恕我直言,对于大多数人来说,这不是最人性化的方式.Thank you @ArthurB :thumbsup: I guess using the CLI would be a safe and "official" way. But IMHO it is not the most user-friendly way for the majority of people.
- 1
- 2019-01-31
- XTZST2O
如何在空白设备上创建脱机交易并将其广播到网络?