UOS系列教程:账户、钱包、权限更改
首先,假设您有一个UOS账号,以及安装了UOS节点程序的电脑。如果没有
官方申请:请下载“优壹号” app
节点安装(ubuntu 16.04):
1, wget ftp://tools.ulord.one/UOS_Mainnet.tar.gz
2,tar -zxvf~/UOS_Mainnet.tar.gz
3,chmod +x ~/uos/noduos ~/uos/cluos ~/uos/kuosd ~/uos/install.sh ~/uos/uninstall.sh ~/uos/mongodb/bin/mongod
4,sudo ~/uos/install.sh
uos的账户是由数字1-5,小写字母a-z组成,普通用户的长度为12位,小于12位的账户叫做“短号”,需要竞拍获得。
一:账户组成
我们使用命令行查看一个UOS链上的任一账户,比如“aaaaaaaaaaaa”
cluos -u https://rpc3.uosio.org:8080 get account aaaaaaaaaaaa
created: 2019-01-29T08:13:31.000
permissions: owner 1: 1 UOS5RCcMUXDKNk9YQDq2CNxG68LF9zRYVn21o7s2TWb7BNFnJDzUk
active 1: 1 UOS7wHa9AjtNuys1PquLbEBGgnvLHig4YyspDwdW1wtJfWWMGBdVo
memory: quota: 7.37 KiB
used: 3.756 KiB
net bandwidth: staked: 0.1000 UOS (total stake delegated from account to self)delegated: 0.0000 UOS
(total staked delegated to account from others)
used: 129
bytesavailable: 67.11 MiB
limit: 67.11 MiB
cpu bandwidth:staked: 0.1000 UOS (total stake delegated from account to self)delegated: 0.0000 UOS
(total staked delegated to account from others)
used: 2.271 ms
available: 14.26 sec
limit: 14.26 sec
UOS balances:
liquid: 7.1000 UOS
staked: 0.2000 UOS
unstaking: 0.0000
UOStotal: 7.3000 UOS
producers:staked: 0.2000 UOS<not voted>
total: 0.0000 UOS
可以看到账户的许多信息,包含:
1,账户"aaaaaaaaaaaa"创建与2019年1月29日
2,账户owner权限的公钥是“UOS5RCcMUXDKNk9YQDq2CNxG68LF9zRYVn21o7s2TWb7BNFnJDzUk”
3,账户active权限的公钥是“UOS7wHa9AjtNuys1PquLbEBGgnvLHig4YyspDwdW1wtJfWWMGBdVo” 4,账户的可用余额为7.1UOS
5,账户的cpu以及net的抵押数量接下来,将用此账号创建一个新的账号,并且更改它的权限。
二,钱包
命令行运行:
kuosd
大约5s,关闭此进程"ctrl+c",这时会在用户目录生成uosio-wallet文件夹,这个文件夹就是钱包文件夹。一个钱包文件夹里头可以包含多个钱包,现在我们在文件夹里面创建两个钱包,钱包的名称分别为testera,testerb。
cluos wallet create -n testera --to-console
Creating wallet: testera Save password to use in the future to unlock this wallet. Without password imported keys will not be retrievable.
"PW5KMVW7A9LUnfxe1YPf2krHcRMbrVGBQZUzVHoBbke7rLkLZDbZB"
cluos wallet create -n testerb --to-console
Creating wallet: testerb Save password to use in the future to unlock this wallet. Without password imported keys will not be retrievable.
"PW5JCBNM89tUkfbimh5foFAf3XFnhRdffohK6wcDVYMCfh9jJ1gQH"
"-n"是名称的意思,这样,我们就在钱包文件夹创建了两个钱包:”testera“和”testerb“。可以使用如下命令查看:
cluos wallet listWallets:
[ "testera *" ,
"testerb *" ]
可以看到,钱包文件夹里面已经包含名为”testera“和名为”testerb“的钱包了。这个时候,钱包文件夹里面是没有任何私钥的,仅仅定义了两个名称而已。想要使用账户“aaaaaaaaaaaa”创建一个新的账户,必须把账户的私钥导入到钱包里面,这样程序才能使用钱包里面私钥授权“aaaaaaaaaaaa”创建账户的行为。“*”代表钱包未被锁定。
将账户“aaaaaaaaaaaa”的owner权限的私钥导入钱包testerb中,其中“xxxxxxx”代表私钥
cluos wallet import -n testerb --private-key xxxxxxxx
查看testerb钱包中收藏的公私钥对:
cluos wallet private_keys -n testerb
然后输入上文中testerb钱包的密码:
PW5JCBNM89tUkfbimh5foFAf3XFnhRdffohK6wcDVYMCfh9jJ1gQH(可以粘贴一次性输入)
结果如下:
password: [[ "UOS5RCcMUXDKNk9YQDq2CNxG68LF9zRYVn21o7s2TWb7BNFnJDzUk", "xxxxxxxx" ]]
这样我们就可以对账号"aaaaaaaaaaaa"进行操作了。假如在某些过程中,钱包提示锁定。可以用如下命令解锁:
cluos wallet unlock -n testerb --password PW5JCBNM89tUkfbimh5foFAf3XFnhRdffohK6wcDVYMCfh9jJ1gQH
三,创建账户
先生成一个公私钥对,然后用记事本保存下来:
cluos create key --to-consolePrivate key: xxxxxxxxxxxxPublic key: UOS5AmeHzY6jreyPLKFaAj4hPSETSNvx2afC4K8w5pydPXDLkSVUE
然后搜遍脑袋想了一个名字“baodaotulong”,心想这个不错,武林至尊,宝刀屠龙。然后在链上查看是否账号已经存在:
cluos -u https://rpc3.uosio.org:8080 get account baodaotulong
返回一个错误,确实不存在。。。。然后调用命令,因为上文中导入的是owner公钥,故签名时使用的owner权限,即@owner。owner权限是向下包含active权限的。
cluos -u https://rpc3.uosio.org:8080 system newaccount aaaaaaaaaaaa --transfer baodaotulong UOS5AmeHzY6jreyPLKFaAj4hPSETSNvx2afC4K8w5pydPXDLkSVUE UOS5AmeHzY6jreyPLKFaAj4hPSETSNvx2afC4K8w5pydPXDLkSVUE --stake-net "0.1000 UOS" --stake-cpu "0.1000 UOS" --buy-ram-kbytes 4 -p aaaaaaaaaaaa@owner
这条命令解释为:aaaaaaaaaaaa创建一个baodaotulong的账号,该账号的owner公钥为UOS5AmeHzY6jreyPLKFaAj4hPSETSNvx2afC4K8w5pydPXDLkSVUE,active公钥为:UOS5AmeHzY6jreyPLKFaAj4hPSETSNvx2afC4K8w5pydPXDLkSVUE,aaaaaaaaaaaa出钱给其购买4K内存,抵押0.1UOS的cpu和net。
这样,baodaotulong就创建成功了。要使用baodaotulong这个账号,同样也需要他的私钥导入钱包。
cluos wallet import -n testerb --private-key xxxxxxxx
同样可以查看testerb钱包,这样testerb钱包中就拥有了两个公私钥对:
cluos wallet private_keys -n testerbpassword: [[ "UOS5AmeHzY6jreyPLKFaAj4hPSETSNvx2afC4K8w5pydPXDLkSVUE", "xxxxxxxx" ],[ "UOS5RCcMUXDKNk9YQDq2CNxG68LF9zRYVn21o7s2TWb7BNFnJDzUk", "xxxxxxxxx" ]]
接下来可以卖出一部分内存试试能否操作baodaotulong账户了:
cluos -u https://rpc3.uosio.org:8080 system sellram baodaotulong 500 -p baodaotulong@active
executed transaction: 4c55852428b3910411d51cccdf8dc3fbaae3c1c2d091b9583f30b740674fe475
112 bytes 1544 us
# uosio <= uosio::sellram {"account":"baodaotulong","bytes":500}# uosio.token <= uosio.token::transfer {"from":"uosio.ram","to":"baodaotulong","quantity":"1.3717 UOS","memo":"sell ram"}
# uosio.ram <= uosio.token::transfer {"from":"uosio.ram","to":"baodaotulong","quantity":"1.3717 UOS","memo":"sell ram"}
# baodaotulong <= uosio.token::transfer {"from":"uosio.ram","to":"baodaotulong","quantity":"1.3717 UOS","memo":"sell ram"}
# uosio.token <= uosio.token::transfer {"from":"baodaotulong","to":"uosio.ramfee","quantity":"0.0069 UOS","memo":"sell ram fee"}
# baodaotulong <= uosio.token::transfer {"from":"baodaotulong","to":"uosio.ramfee","quantity":"0.0069 UOS","memo":"sell ram fee"}
# uosio.ramfee <= uosio.token::transfer {"from":"baodaotulong","to":"uosio.ramfee","quantity":"0.0069 UOS","memo":"sell ram fee"}
# uosio <= uosio::payfee {"payer":"baodaotulong","net_usage":112,"virtule_net_limit":2097152000,"act_account":"uosio","act_na...warn 2019-03-29T08:57:45.730 thread-0 main.cpp:487
print_resuwarning: transaction executed locally, but may not be confirmed by the network yet
四,更改权限
武侠迷小明出了1000个UOS想跟我购买这个baodaotulong的这个账户。小明向我提供了一个公钥UOS5A4sYXU6SA5kyKjbu76r9xapgrzotjhLEgPSZzDzMBJpw1559Y。于是,我运行如下命令,更改了baodaotulong的权限,这样我就不再拥有baodaotulong的控制权了。
cluos -u https://rpc3.uosio.org:8080 set account permission baodaotulong active '{"threshold":1,"keys":[{"key":"UOS5A4sYXU6SA5kyKjbu76r9xapgrzotjhLEgPSZzDzMBJpw1559Y","weight":1}],"accounts":[]}' owner -p baodaotulong@owner
cluos -u https://rpc3.uosio.org:8080 set account permission baodaotulong owner '{"threshold":1,"keys":[{"key":"UOS5A4sYXU6SA5kyKjbu76r9xapgrzotjhLEgPSZzDzMBJpw1559Y","weight":1}],"accounts":[]}' -p baodaotulong@owner
小明查看了baodaotulong的账户:
cluos -u https://rpc3.uosio.org:8080 get account baodaotulong
created: 2019-03-29T08:46:56.000
permissions: owner 1: 1 UOS5A4sYXU6SA5kyKjbu76r9xapgrzotjhLEgPSZzDzMBJpw1559Y
active 1: 1 UOS5A4sYXU6SA5kyKjbu76r9xapgrzotjhLEgPSZzDzMBJpw1559Y
.....
小明发现账户的owner和active权限都由自己提供的公钥组成,愉快的通过优壹号转给了我1000UOS
|