交易处理

HyperCli提供了交易处理相关的功能,以下是该功能的参数:

  1. $ ./hypercli tx --help
  2. NAME:
  3. hypercli tx - transaction related commands
  4.  
  5. USAGE:
  6. hypercli tx command [command options] [arguments...]
  7.  
  8. COMMANDS:
  9. send send normal transactions
  10. info query the transaction info by hash
  11. receipt query the transaction receipt by hash
  12.  
  13. OPTIONS:
  14. --help, -h show help

可以看到tx命令有三个子命令,下面我们将介绍这三个命令。

发送交易

send命令可以用来发送普通的交易,以下是它的参数:

  1. $ ./hypercli tx send --help
  2. NAME:
  3. hypercli tx send - send normal transactions
  4.  
  5. USAGE:
  6. hypercli tx send [command options] [arguments...]
  7.  
  8. OPTIONS:
  9. --count value, -c value send how many transactions (default: 1)
  10. --namespace value, -n value specify the namespace to send transactions to (default: "global")
  11. --from value, -f value specify the account (default: "000f1a7a08ccc48e5d30f80850cf1cf283aa3abd")
  12. --to value, -t value specify the contract address
  13. --password value, -p value specify the password used to generate signature (default: "123")
  14. --amount value, -a value specify the amount to transfer (default: 0)
  15. --extra value, -e value specify the extra information
  16. --snapshot value, -s value specify the snapshot ID
  17. --simulate simulate execute or not

您可以用以下命令发送交易,它的意思是连续发送10笔交易:

  1. ./hypercli tx send -c 10

如果命令执行正确,您将看到以下输出结果:

  1. {"jsonrpc":"2.0","namespace":"global","id":1,"code":0,"message":"SUCCESS","result":{"version":"1.3","txHash":"0xefbc9f9b5048337fbaf64047ad5eff03c40c1c76991b0364686ba3620e2c5ea3","vmType":"EVM","contractAddress":"0x0000000000000000000000000000000000000000","gasUsed":0,"ret":"0x0","log":[]}}
  2.  
  3. ...
  4. ...
  5.  
  6. {"jsonrpc":"2.0","namespace":"global","id":1,"code":0,"message":"SUCCESS","result":{"version":"1.3","txHash":"0xc47b64ddad2be542bfdc5164d447317f5152142ac7961c88332b25f04b31783d","vmType":"EVM","contractAddress":"0x0000000000000000000000000000000000000000","gasUsed":0,"ret":"0x0","log":[]}}

选取结果中的一条txHash,它之后将被用于查看交易的信息和回执。在这个例子中,我们选取这一个txHash:

  1. 0xc47b64ddad2be542bfdc5164d447317f5152142ac7961c88332b25f04b31783d

交易信息

info命令可以用来获取交易的信息,以下是它的参数:

  1. ./hypercli tx info --help
  2. NAME:
  3. hypercli tx info - query the transaction info by hash
  4.  
  5. USAGE:
  6. hypercli tx info [command options] [arguments...]
  7.  
  8. OPTIONS:
  9. --hash value specify the tx hash used to query the detailed information
  10. --namespace value, -n value specify the namespace to query transaction information (default: "global")

您可以用以下命令获取交易信息,它的意思是获取某一笔指定txHash的交易信息:

  1. ./hypercli tx info --hash 0xc47b64ddad2be542bfdc5164d447317f5152142ac7961c88332b25f04b31783d

如果命令执行正确,您将看到以下输出结果:

  1. {"jsonrpc":"2.0","namespace":"global","id":1,"code":0,"message":"SUCCESS","result":{"version":"1.3","hash":"0xc47b64ddad2be542bfdc5164d447317f5152142ac7961c88332b25f04b31783d","blockNumber":"0xf","blockHash":"0x2592e0f3e1f156effe93325a60b1190533be2053aa102eb182bd64f95b28080a","txIndex":"0x0","from":"0x000f1a7a08ccc48e5d30f80850cf1cf283aa3abd","to":"0x6201cb0448964ac597faf6fdf1f472edf2a22b89","amount":"0x8","timestamp":1512022032747286761,"nonce":5475154203949975728,"extra":"","executeTime":"0x5","payload":"0x0"}}

交易回执

receipt命令可以用来获取交易的回执,以下是它的参数:

  1. $ ./hypercli tx receipt --help
  2. NAME:
  3. hypercli tx receipt - query the transaction receipt by hash
  4.  
  5. USAGE:
  6. hypercli tx receipt [command options] [arguments...]
  7.  
  8. OPTIONS:
  9. --hash value specify the tx hash used to query the transaction receipt
  10. --namespace value, -n value specify the namespace to query transaction receipt (default: "global")

您可以用以下命令获取交易回执,它的意思是获取某一笔指定txHash的交易回执:

  1. ./hypercli tx receipt --hash 0xc47b64ddad2be542bfdc5164d447317f5152142ac7961c88332b25f04b31783d

如果命令执行正确,您将看到以下输出结果:

  1. {"jsonrpc":"2.0","namespace":"global","id":1,"code":0,"message":"SUCCESS","result":{"version":"1.3","txHash":"0xc47b64ddad2be542bfdc5164d447317f5152142ac7961c88332b25f04b31783d","vmType":"EVM","contractAddress":"0x0000000000000000000000000000000000000000","gasUsed":0,"ret":"0x0","log":[]}}