智能合约使用(单机单节点多钱包)

本节延续上一节内容

账号列表

账号ID

账号含义

钱包

eosio

矿工1

-

token1

交易所1

default

hospital1

医院1

default

patient1

患者1

default

hospital2

医院2

hospital2

doctor2

医生2

hospital2

创建钱包及用户

#创建钱包
cleos wallet create -n hospital2
"PW5JxnbBTTbTQKUHHNvYojU1xrcjxQduz2wU6gfMEgiZjwT5S6xJ6"

#查看钱包列表
cleos wallet list

#创建并导入key
cleos create key
Private key: 5KZS8Q9MVniCbLY2RxjSWruM5YvfDPteP3qQDM23YP5ngwvqHMt
Public key: EOS8K9wqRtD8cCuHvbdzcquEhYHnSaFvyQSWm8kVxYFHavraNeue2

cleos wallet import -n hospital2 5KZS8Q9MVniCbLY2RxjSWruM5YvfDPteP3qQDM23YP5ngwvqHMt 

#创建用户
cleos create account eosio hospital2 EOS8K9wqRtD8cCuHvbdzcquEhYHnSaFvyQSWm8kVxYFHavraNeue2 EOS8K9wqRtD8cCuHvbdzcquEhYHnSaFvyQSWm8kVxYFHavraNeue2 
cleos create account eosio doctor2 EOS8K9wqRtD8cCuHvbdzcquEhYHnSaFvyQSWm8kVxYFHavraNeue2 EOS8K9wqRtD8cCuHvbdzcquEhYHnSaFvyQSWm8kVxYFHavraNeue2 

#查看用户列表
cleos get accounts EOS8K9wqRtD8cCuHvbdzcquEhYHnSaFvyQSWm8kVxYFHavraNeue2

#查看eosio下级用户
cleos get servants eosio

跨钱包转账

cleos push action token1 transfer '["patient1", "hospital2", "50.0000 YR", "Remote Diagnose" ]' -p patient1

钱包锁定后,不能花钱,只能收钱

#锁定patient1所在钱包
cleos wallet lock -n default

#转账会失败
cleos push action token1 transfer '["patient1", "hospital2", "50.0000 YR", "Remote Diagnose" ]' -p patient1

#解锁patient1所在钱包,锁定hospital2所在钱包
cleos wallet unlock -n default
cleos wallet lock -n hospital2

#转账会成功
cleos push action token1 transfer '["patient1", "hospital2", "50.0000 YR", "Remote Diagnose" ]' -p patient1

最后更新于