jcc-ethereum-tool 是一个命令行工具,可以快速的通过参数或者配置文件形式操作 ETH 链,实现转账,查询余额,ERC20,ERC721 等通证操作。
https://github.com/JCCDex/jcc-ethereum-tool jcc-ethereum-tool is a command tool, which is can be use to transfer, query balance, manipute ERC20, ERC721 by parameters or config file.
jcc-ethereum-tool 是一个命令行工具,可以快速的通过参数或者配置文件形式操作 ETH 链,实现转账,查询余额,ERC20,ERC721 等通证操作。
<pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 13.6px; margin-top: 0px; margin-bottom: 0px; overflow-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: rgb(246, 248, 250); border-radius: 6px; word-break: normal;">sudo npm install -g jcc-ethereum-tool --unsafe-perm=true</pre>
在用户的目录下存在.jcc-ethereum-tool/config.json 文件,类似配置
{ "server" : "http://localhost:8546", "network" : 101, "gasPrice" : 20000000000, "gasLimit" : 20000 "wallet" : {"address": "0x1234", "secret": "0x1223"} }
注意:不能确认在安全情况下,不要在配置文件中使用明文保存密钥,尽量使用 keystore 文件
用户可以指定配置文件路径
jcc-ethereum-tool --config myconfig.json
jcc-ethereum-tool --wallet_create
jcc-ethereum-tool --wallet_create --save_wallet
jcc-ethereum-tool --import_private_to_keystore
jcc-ethereum-tool --network 99 --balance 0x1111 --server http://localhost:8545
<pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 13.6px; margin-top: 0px; margin-bottom: 0px; overflow-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: rgb(246, 248, 250); border-radius: 6px; word-break: normal;"># <span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">从配置</span> <span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-s1" style="box-sizing: border-box;">config</span><span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">json</span><span class="pl-kos" style="box-sizing: border-box;">)</span> <span class="pl-s1" style="box-sizing: border-box;">的钱包向目的地址转账</span> <span class="pl-s1" style="box-sizing: border-box;">jcc</span><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">-</span><span class="pl-s1" style="box-sizing: border-box;">ethereum</span><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">-</span><span class="pl-s1" style="box-sizing: border-box;">tool</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">--</span><span class="pl-s1" style="box-sizing: border-box;">transfer</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">0x2222</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">--</span><span class="pl-s1" style="box-sizing: border-box;">amount</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">0.000001</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">--</span><span class="pl-s1" style="box-sizing: border-box;">network</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">101</span></pre>
jcc-ethereum-tool --block latest 或者 jcc-ethereum-tool --block 1234
jcc-ethereum-tool --transaction 0xbb15e089f12c9d4fcd82e47c3d3b56940c9ad6e51a9c7b5dfec4337f5fb4f58e
jcc-ethereum-tool --receipt 0xbb15e089f12c9d4fcd82e47c3d3b56940c9ad6e51a9c7b5dfec4337f5fb4f58e
jcc-ethereum-tool --deploy "./MAYAToken.json" --gas_limit 3800000 --gas_limit 800000 --parameters '"parameter1","parameter2"'
// 合约大小会影响gas limit,所以请自己设置合适的gas limit // 其次是创建合约可能是有参数的,请按照参数顺序在--parameters中设置
jcc-ethereum-tool 支持任意合约的调用,一般来说需要以下几个参数
jcc-ethereum-tool --abi erc20abi.json --contractAddr "0x2bbe1b5b974aa75369ec72200c9c7da717faa627" --method "name" jcc-ethereum-tool --abi erc20abi.json --contractAddr "0x2bbe1b5b974aa75369ec72200c9c7da717faa627" --method "symbol" jcc-ethereum-tool --abi erc20abi.json --contractAddr "0x2bbe1b5b974aa75369ec72200c9c7da717faa627" --method "decimals" jcc-ethereum-tool --abi erc20abi.json --contractAddr "0x2bbe1b5b974aa75369ec72200c9c7da717faa627" --method "totalSupply"
jcc-ethereum-tool --abi erc20abi.json --contractAddr "0x2bbe1b5b974aa75369ec72200c9c7da717faa627" --method "balanceOf" --parameters '"0xaddress......"' // 请注意 地址参数分别用单双引号,是为了传递正确的地址
jcc-ethereum-tool --abi erc20abi.json --contractAddr "0x2bbe1b5b974aa75369ec72200c9c7da717faa627" --method "transfer" --parameters '"0xaddress.....",chain3.toSha("23.1")' // chain3.toSha("23.1") 这个可以利用函数转义方式将ERC20的数量展开,但是ERC20也有不是标准的18位小数的,如果需要自行处理小数位,要书写成下面的样子 jcc-ethereum-tool --abi erc20abi.json --contractAddr "0x2bbe1b5b974aa75369ec72200c9c7da717faa627" --method "transfer" --parameters '"0xaddress.....",BigNumber(23.1*10**18)'
// 授权0x5d819874014dfc29ec6d56caacc4e95f2dd33352从指定账户转账额度 jcc-ethereum-tool --abi erc20abi.json --contractAddr "0x2bbe1b5b974aa75369ec72200c9c7da717faa627" --keystore keystorefile.json --password yourkeystorepassword --gas_limit 50000 --method "approve" --parameters '"0xspender address", chain3.toSha("333")'
// 查询授权数量 jcc-ethereum-tool --abi erc20abi.json --contractAddr "0x2bbe1b5b974aa75369ec72200c9c7da717faa627" --method "allowance" --parameters '"0xowner address","0xspender address"'
// 授权转账 jcc-ethereum-tool --abi erc20abi.json --contractAddr "0x2bbe1b5b974aa75369ec72200c9c7da717faa627" --keystore keystorefile.json --password yourkeystorepassword --gas_limit 50000 --gas_price 1000000000 --method "transferFrom" --parameters '"0xowner address","0xdestination address", chain3.toSha("300")'
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!