先啰嗦几句:本人区块链小白一枚,正在自学EOS应用开发(当然目前也没有培训班培训),我的这个系列文章是我的学习笔记,因此,鉴于水平有限,难免有许多错误之处,还希望各位读者海涵,若能留言勘误,更是感激不尽。同时也欢迎热爱EOS开发的朋友加我微信(微信号:361757),暗号EOS,我已经创建了一个交流群,发布本文时(2018年4月12日),群人数已经达到103人!好了,系好安全带,我们的EOS应用开发之旅,马上开始!
本系列文章共分4篇,学习的内容为EOS.IO Programs & Tools
本文为第二部分,重点探索cleos的set的用法。
在学习本文前,您需要先部署好EOS.IO运行环境,测试一下智能合约,然后再开始学习。
老样子,我们先测试一下get有哪些子命令:
$ cleos set
ERROR: RequiredError: Subcommand required
Set or update blockchain state
Usage: cleos set [OPTIONS] SUBCOMMAND
Options:
-h,--help Print this help message and exit
Subcommands:
contract Create or update the contract on an account
account set or update blockchain account state
action set or update blockchain action state
我们看到共有3个subcommand:
- contract 创建或更新一个账户的合约
- account 创建或更新区块链的账户状态
- action 创建或更新区块链的事务状态
接下来我们依次试试:
1. contract
设置合约
$ cleos set contract
ERROR: RequiredError: account
Create or update the contract on an account
Usage: cleos set contract [OPTIONS] account contract-dir [wast-file] [abi-file]
Positionals:
account TEXT The account to publish a contract for
contract-dir TEXT The the path containing the .wast and .abi
wast-file TEXT The file containing the contract WAST or WASM relative to contract-dir
abi-file TEXT The ABI for the contract relative to contract-dir
Options:
-h,--help Print this help message and exit
-a,--abi TEXT The ABI for the contract relative to contract-dir
-x,--expiration set the time in seconds before a transaction expires, defaults to 30s
-f,--force-unique force the transaction to be unique. this will consume extra bandwidth and remove any protections against accidently issuing the same transaction multiple times
-s,--skip-sign Specify if unlocked wallet keys should be used to sign transaction
-j,--json print result as json
-d,--dont-broadcast don''t broadcast transaction to the network (just print to stdout)
-p,--permission TEXT ... An account and permission level to authorize, as in 'account@permission' (defaults to 'account@active')
--max-cpu-usage UINT set an upper limit on the cpu usage budget, in instructions-retired, for the execution of the transaction (defaults to 0 which means no limit)
--max-net-usage UINT set an upper limit on the net usage budget, in bytes, for the transaction (defaults to 0 which means no limit)
很乱哦,我们先看看命令格式要求:
Usage: cleos set contract [OPTIONS] account contract-dir [wast-file] [abi-file]
下面紧跟着给出了各个参数的解释:
account,文本形式,发行合约的账户
contract-dir,文本形式,合约路径,包含.wast或.abi文件
wast-file,文本形式,包含WAST或WASM的相对目录
abi-file,文本形式,ABI文件的相对目录
由于我没有准备合约文件,这个测试就暂时不做了。
2.account
设置账户
$ cleos set account
ERROR: RequiredError: Subcommand required
set or update blockchain account state
Usage: cleos set account [OPTIONS] SUBCOMMAND
Options:
-h,--help Print this help message and exit
Subcommands:
permission set parameters dealing with account permissions
这个只有一个子命令permission,设置账户权限的参数
$ cleos set account permission
ERROR: RequiredError: account
set parmaters dealing with account permissions
Usage: cleos set account permission [OPTIONS] account permission authority [parent]
Positionals:
account TEXT The account to set/delete a permission authority for
permission TEXT The permission name to set/delete an authority for
authority TEXT [delete] NULL, [create/update] JSON string or filename defining the authority
parent TEXT [create] The permission name of this parents permission (Defaults to: "Active")
Options:
-h,--help Print this help message and exit
-x,--expiration set the time in seconds before a transaction expires, defaults to 30s
-f,--force-unique force the transaction to be unique. this will consume extra bandwidth and remove any protections against accidently issuing the same transaction multiple times
-s,--skip-sign Specify if unlocked wallet keys should be used to sign transaction
-j,--json print result as json
-d,--dont-broadcast don''t broadcast transaction to the network (just print to stdout)
-p,--permission TEXT ... An account and permission level to authorize, as in 'account@permission' (defaults to 'account@active')
--max-cpu-usage UINT set an upper limit on the cpu usage budget, in instructions-retired, for the execution of the transaction (defaults to 0 which means no limit)
--max-net-usage UINT set an upper limit on the net usage budget, in bytes, for the transaction (defaults to 0 which means no limit)
这里要求的格式:
$ cleos set account permission [OPTIONS] account permission authority [parent]
其中,account,表示要修改的账户
permission 表示要设置的权限
authority 权限内容,JSON字符串
parent 上级权限
3. action
设置事务状态
$ cleos set action
ERROR: RequiredError: Subcommand required
set or update blockchain action state
Usage: cleos set action [OPTIONS] SUBCOMMAND
Options:
-h,--help Print this help message and exit
Subcommands:
permission set parmaters dealing with account permissions
这里也只有一个子命令:permission,设置账户的详细参数?
$ cleos set acion permission
ERROR: RequiredError: account
set parmaters dealing with account permissions
Usage: cleos set action permission [OPTIONS] account code type requirement
Positionals:
account TEXT The account to set/delete a permission authority for
code TEXT The account that owns the code for the action
type TEXT the type of the action
requirement TEXT [delete] NULL, [set/update] The permission name require for executing the given action
Options:
-h,--help Print this help message and exit
-x,--expiration set the time in seconds before a transaction expires, defaults to 30s
-f,--force-unique force the transaction to be unique. this will consume extra bandwidth and remove any protections against accidently issuing the same transaction multiple times
-s,--skip-sign Specify if unlocked wallet keys should be used to sign transaction
-j,--json print result as json
-d,--dont-broadcast don''t broadcast transaction to the network (just print to stdout)
-p,--permission TEXT ... An account and permission level to authorize, as in 'account@permission' (defaults to 'account@active')
--max-cpu-usage UINT set an upper limit on the cpu usage budget, in instructions-retired, for the execution of the transaction (defaults to 0 which means no limit)
--max-net-usage UINT set an upper limit on the net usage budget, in bytes, for the transaction (defaults to 0 which means no limit)
要求的格式:
$ cleos set action permission account code type requirement
其中:
account是目标账户。
code是账户拥有者的code
type是action类型
requirement 是权限名称
由于目前的环境,我没有进行set的实际操作测试。暂时先了解一下,后续补充。
本篇完,下一篇一起探索transfer用法。
我是王越,EOS应用开发小白一枚,渴望与你链接,我已经建立了一个交流开发技术的微信群,期待你的加入!请加我微信 361757,暗号EOS。
网友评论