命令行工具

youchain.java的完整jar文件分发包对每一次发布都提供命令行工具。命令行允许你从终端(terminal)使用youchain.java的一些功能:

这些工具提供:

  • 钱包创建
  • 钱包密码管理
  • 从一个钱包转移到另一个钱包YOU(需要联网)
  • 离线交易签名
  • 使用离线交易签名发送交易(需要联网)
  • solidity智能合约封装包的产生

可以点击这里zipfile/tarball包,或者通过源代码自己编译获得;

Source code (zip)

Source code (tar.gz)

要通过zipfile的使用的话,只需解压zipfile并运行命令:

$ unzip YOUChainj-1.1.5.zip
  Archive:  YOUChainj-1.1.5.zip
     creating: YOUChainj-1.1.5/
     creating: YOUChainj-1.1.5/lib/
    inflating: YOUChainj-1.1.5/lib/console-1.1.5.jar  
    inflating: YOUChainj-1.1.5/lib/codegen-1.1.5.jar  
    inflating: YOUChainj-1.1.5/lib/core-1.1.5.jar  
    inflating: YOUChainj-1.1.5/lib/abi-1.1.5.jar  
 ... 
     creating: YOUChainj-1.1.5/bin/
    inflating: YOUChainj-1.1.5/bin/YOUChainj.bat  
    inflating: YOUChainj-1.1.5/bin/YOUChainj
$ ./bin/YOUChainj version

   __     ______  _    _  _____ _           _       
   \ \   / / __ \| |  | |/ ____| |         (_)      
    \ \_/ / |  | | |  | | |    | |__   __ _ _ _ __  
     \   /| |  | | |  | | |    | '_ \ / _` | | '_ \ 
      | | | |__| | |__| | |____| | | | (_| | | | | |
      |_|  \____/ \____/ \_____|_| |_|\__,_|_|_| |_|

  Version: 1.1.5
  Build timestamp: 2020-05-18 06:19:17.236 UTC

命令行工具作为钱包工具

生成一个新的钱包:

$ YOUChainj wallet create

更新现有钱包的密码:

$ YOUChainj wallet update <walletfile>

导入一个钱包:

$ YOUChainj wallet fromkey <priveteKey>

将YOU发送到另一个地址:

$ YOUChainj wallet send <walletfile> <destination-address>

离线交易签名:

$ YOUChainj wallet sign <walletfile> <destination-address>

示例如下:

./YOUChainj wallet sign /Users/xxx/keystore/youchain/1.json 0xfe1593732af8935b89166e6b43e5689a1c2af8c5

 __     ______  _    _  _____ _           _
 \ \   / / __ \| |  | |/ ____| |         (_)
  \ \_/ / |  | | |  | | |    | |__   __ _ _ _ __
   \   /| |  | | |  | | |    | '_ \ / _` | | '_ \
    | | | |__| | |__| | |____| | | | (_| | | | | |
    |_|  \____/ \____/ \_____|_| |_|\__,_|_|_| |_|

Please enter your existing wallet file password:
Wallet for address 0x942d6cc8a1b4a06b2818277978a4975b651d8038 loaded
How many YOU would you like to transfer (unit YOU) (please enter a numeric value): 1.23
the amount is: 1.23YOU (1230000000000000000lu)
What is the latest nonce of the sender address (please enter a hex value from the you_getTransactionCount interface): 0xa
the nonce is: 10
Please specify the gasPrice (please enter a hex value from the you_gasPrice interface): 0x746a528800
the gasPrice is: 500000000000
Please specify the Network (1 mainnet 2 testnet) (please enter 1 or 2) : 2
Funds have been successfully signed
send 1.23 YOU from 0x942d6cc8a1b4a06b2818277978a4975b651d8038 to 0xfe1593732af8935b89166e6b43e5689a1c2af8c5
the rawTransaction is: 0xf86d0a85746a52880083015f9094fe1593732af8935b89166e6b43e5689a1c2af8c5881111d67bb1bb00008028a0661af6556d0d33b3acb914e98a8fd24333947642979aa005b1c40c35883d3552a0573a7b3c2d27bee665bc34031c01109f2d4d1e80cade099a8ad07c55fafcb9df
you can use you_sendRawTransaction interface to send this transaction
also you can use ./YOUChainj wallet sendRaw <rawTransaction> to send this transaction

使用离线交易签名发送交易(需要联网)

./YOUChainj wallet sendRaw 0xf86d0f85746a52880083015f9094fe1593732af8935b89166e6b43e5689a1c2af8c58822b1c8c1227a00008027a033747dbee82c0b274aee90ea5582b2c2841d75ca0db2da40442aee0c5debfa38a03ecb117f88948bbde9aef4cad108efbbf06c9dc606020dcb7412116e2f5779af

 __     ______  _    _  _____ _           _       
 \ \   / / __ \| |  | |/ ____| |         (_)      
  \ \_/ / |  | | |  | | |    | |__   __ _ _ _ __  
   \   /| |  | | |  | | |    | '_ \ / _` | | '_ \ 
    | | | |__| | |__| | |____| | | | (_| | | | | |
    |_|  \____/ \____/ \_____|_| |_|\__,_|_|_| |_|

Please confirm address of running YOUChain client you wish to send the transfer request to [http://localhost:8283/]: http://test-node.iyouchain.com:80
Connected successfully to client: YOUChain/linux-amd64/go1.13.4
the rawTransaction has been successfully sent 
the hash is 0x2c52aaf19d4d57d5e9ad0df643f0e8b6b7f0de0027f6535a2e5aae541c3468cc

生成智能合约函数封装包

$ YOUChainj solidity generate [--javaTypes|--solidityTypes] /path/to/<smart-contract>.bin /path/to/<smart-contract>.abi -o /path/to/src/main/java -p com.your.organization.name