EOS一直宣传自己的账号权限机制,下面将演示针对账号bcskill三个权限组的增删改查
- owner 账号拥有者,拥有账号全部的权限,等于超级管理员 (新建账号预设)
- active 拥有账号大部分账户的权限,等于管理员 (新建账号预设)
- custom 自定义添加,用于下面演示针对权限组的增删改查
拥有哪些组的私钥,就拥有当前账号哪些权限。每个组可以有多个授权key,也可以多个授权账户。
1. 生成多组公钥私钥 (在线生成)
权限名 |
公钥 |
私钥 |
owner |
EOS6fQzsc9Bn5buFbNxHgGMNh9zr2gcbHz2YaaBCfMApw3E8vADu3 |
5Hvpv1qkoBymEb8DA1MfrgHdcPbxGkE7Ux9DPzhRnb8kHBoAuBn |
active |
EOS5G45ChvRSTjQJGvHX8gBEV2ZrUvbxnh6WEd1qfXKox7KqnZb7j |
5Jqq6ztSk41Y6duygrFwCKKVBTaat8zLExG3owwnJSHZMKRcZC4 |
custom |
EOS5QxpwkWLAAWQqcT8teKrUceYr5Nj6PsBmCVoLaQQVqcoP2ZjF5 |
5JewRAyyYoNoTfwmy32CLBiyqS2DfQ8njY4ENuzqJ5Rrp7Zft2o |
账户名 |
公钥 |
私钥 |
temporary |
EOS7Yfs4kL6j9G8nmCTFt5ycLUpV4NmPaZKfuVfYC8XJbuDYPPdnA |
5JnHkERVzDec7j31gAscy39mDbZvTr2XvGS7SZgwQCgNca3McL1 |
公钥 |
私钥 |
EOS7UKzLPHVUTYpex48pRZokvBNEEp5KKXFGwcb5Qv6dZTWUYHGeP |
5JUhVJetKVxZ1vKPBwxKe458g7Zz3LnAz9kLhmirVs7tiSF2bGk |
2.导入私钥
cleos wallet import 5Hvpv1qkoBymEb8DA1MfrgHdcPbxGkE7Ux9DPzhRnb8kHBoAuBn
cleos wallet import 5Jqq6ztSk41Y6duygrFwCKKVBTaat8zLExG3owwnJSHZMKRcZC4
cleos wallet import 5JewRAyyYoNoTfwmy32CLBiyqS2DfQ8njY4ENuzqJ5Rrp7Zft2o
3.创建账号
cleos system newaccount eosio bcskill EOS6fQzsc9Bn5buFbNxHgGMNh9zr2gcbHz2YaaBCfMApw3E8vADu3 EOS5G45ChvRSTjQJGvHX8gBEV2ZrUvbxnh6WEd1qfXKox7KqnZb7j --stake-net '50.00 SYS' --stake-cpu '50.00 SYS' --buy-ram-kbytes 10000
![](https://www.bcskill.com/usr/uploads/2018/06/983778251.png)
创建账户时,会一同加入owner,active两个组,(两个组的公钥可以用同一个,但不建议)
4.查看账户信息
cleos get account bcskill -j
![](https://www.bcskill.com/usr/uploads/2018/06/2626443733.png)
也就是只要有EOS6fQzsc9Bn5buFbNxHgGMNh9zr2gcbHz2YaaBCfMApw3E8vADu3的私钥,就拥有对账户bcskill的owner权限组的权限
拥有EOS5G45ChvRSTjQJGvHX8gBEV2ZrUvbxnh6WEd1qfXKox7KqnZb7j的私钥,就拥有对账户bcskill的active权限组的权限
5.为bcskill账号增加自定义权限组custom,基于active
cleos set account permission bcskill custom '{"threshold":1,"keys":[{"key":"EOS5QxpwkWLAAWQqcT8teKrUceYr5Nj6PsBmCVoLaQQVqcoP2ZjF5","weight":1}],"accounts":[]}' active
![](https://www.bcskill.com/usr/uploads/2018/06/25045480.png)
6.查看账户信息
cleos get account bcskill -j
![](https://www.bcskill.com/usr/uploads/2018/06/2223680096.png)
7.为权限组custom更换权限key
cleos set account permission bcskill custom '{"threshold": 1, "keys": [{"key": "EOS7UKzLPHVUTYpex48pRZokvBNEEp5KKXFGwcb5Qv6dZTWUYHGeP", "weight": 1}], "accounts": []}' active
![](https://www.bcskill.com/usr/uploads/2018/06/1363190047.png)
8.查看账户信息
cleos get account bcskill -j
![](https://www.bcskill.com/usr/uploads/2018/06/1947476114.png)
custom授权key已更新
9.为custom添加多个授权key
cleos set account permission bcskill custom '{"threshold":1,"keys":[{"key":"EOS5QxpwkWLAAWQqcT8teKrUceYr5Nj6PsBmCVoLaQQVqcoP2ZjF5","weight":1},{"key":"EOS7UKzLPHVUTYpex48pRZokvBNEEp5KKXFGwcb5Qv6dZTWUYHGeP","weight":1}],"accounts":[]}' active
![](https://www.bcskill.com/usr/uploads/2018/06/1207064238.png)
10.查看账户信息
cleos get account bcskill -j
![](https://www.bcskill.com/usr/uploads/2018/06/744582058.png)
custom已有两个授权key
11.创建账号temporary
cleos system newaccount eosio temporary EOS7Yfs4kL6j9G8nmCTFt5ycLUpV4NmPaZKfuVfYC8XJbuDYPPdnA EOS7Yfs4kL6j9G8nmCTFt5ycLUpV4NmPaZKfuVfYC8XJbuDYPPdnA --stake-net '50.00 SYS' --stake-cpu '50.00 SYS' --buy-ram-kbytes 10000
![](https://www.bcskill.com/usr/uploads/2018/06/1657941666.png)
12.为custom添加其他授权账号temporary
cleos set account permission bcskill custom '{"threshold":2,"keys":[{"key":"EOS5QxpwkWLAAWQqcT8teKrUceYr5Nj6PsBmCVoLaQQVqcoP2ZjF5","weight":1}],"accounts":[{"permission":{"actor":"temporary","permission":"active"},"weight":1}]}' active
![](https://www.bcskill.com/usr/uploads/2018/06/3586099317.png)
13.查看账户信息
cleos get account bcskill -j
![](https://www.bcskill.com/usr/uploads/2018/06/24295958.png)
custom已有授权账号temporary
14.删除custom权限组
cleos set account permission bcskill custom 'NULL' active
![](https://www.bcskill.com/usr/uploads/2018/06/2440426288.png)
15.查看账户信息
cleos get account bcskill -j
![](https://www.bcskill.com/usr/uploads/2018/06/151889483.png)
custom权限组已被删除
下一篇将讲解EOS账户权限的使用