EOSIO cleos命令汇总

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

创建或更新帐户上的合约权限

命令格式:$ cleos set account ${account} ${permission} ${authority} ${parent}

参数:

account TEXT - 设置/删除权限的帐户 permission TEXT - 设置/删除权限的权限名称 authority TEXT - [delete] NULL、[create/update] 公钥、JSON字符串或定义权限的文件名 parent TEXT - [create]此权限的父权限名(默认为“Active”)

返回结果参数:

-h,--help - 打印帮助消息并退出 -a,--abi TEXT - 合约 ABI -x,--expiration TEXT - 在交易到期之前以秒为单位设置时间,默认值为30s -f,--force-unique - 强制交易成为唯一,这将消耗额外的带宽,并消除对多次发布同一交易的任何保护。 -s,--skip-sign - 指定未锁钱包密钥是否用于签署交易。跳过签署直接交易。 -d,--dont-broadcast - 不要向网络广播交易(只需打印到stdout) -r,--ref-block TEXT - 设置用于PoS的块num或块ID(交易证明PoS) -p,--permission TEXT - 授权的帐户和权限级别,如“帐户@权限” (默认值'account@active') --max-cpu-usage-ms UINT - 设置CPU使用预算的毫秒上限,用于执行交易(默认为0,这意味着没有限制) --max-net-usage UINT - 设置网络使用预算的上限,以字节为单位(默认为0,这意味着没有限制)。

要修改帐户的权限,必须具有帐户上的权限和正在修改的权限。

基本用法,为权限设置新的密钥:

$ ./cleos set account permission testaccount active EOSPUBLICKEY owner -p testaccount@owner

基本用法,将帐户(而不是密钥)设置为权限:

$ ./cleos set account permission testaccount active diffaccount owner -p testaccount@owner

高级用法,weight/thresholds:

$ ./cleos set account permission testaccount active '{"threshold" : 100, "keys" : [], "accounts" : [{"permission":{"actor":"user1","permission":"active"},"weight":25}, {"permission":{"actor":"user2","permission":"active"},"weight":75}]}' owner -p testaccount@owner

这个命令中使用的JSON对象实际上由两种不同类型的对象组成。

权限JSON对象:

{
  "threshold"       : 100,    /*An integer that defines cumulative signature weight required for authorization*/
  "keys"            : [],     /*An array made up of individual permissions defined with an EOSIO-style PUBLIC KEY*/
  "accounts"        : []      /*An array made up of individual permissions defined with an EOSIO-style ACCOUNT*/
}

返回结果:

1.密钥数组中包含0个或更多个对象:

{
  "key"           : "EOS8X7Mp7apQWtL6T2sfSZzBcQNUqZB7tARFEm9gA9Tn9nbMdsvBB",
  "weight"        : 25      /*Set the weight of a signature from this permission*/
}
  1. 账号数组中包含0个或更多个对象
{
  "permission" : {
    "actor"       : "sandwich",
    "permission"  : "active"
  },
  "weight"      : 75      /*Set the weight of a signature from this permission*/
}

====================================================

安利个本站的《EOS开发智能合约与DApp入门实战》:

EOS教程

本课程帮助你快速入门EOS区块链去中心化应用的开发,内容涵盖EOS工具链、账户与钱包、发行代币、智能合约开发与部署、使用代码与智能合约交互等核心知识点,最后综合运用各知识点和React一起完成便签DApp的开发。