智能合约使用(单机单节点单钱包)
最后更新于
最后更新于
nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin
cleos wallet create
#记住这个密钥,用来处理钱包操作
"PW5JAj9qw2tQsuVajLVXsiKUD7ULQnZ83qxpaB5YVFcs6qbhQ84J1"
#创建密钥
cleos create key
Private key: 5JJhx7BsRMKNnVcm4gSg7TCkK3B5Dwn2iqjUS6NoSRkJQyRPsxn
Public key: EOS5jXAL8pkuAb7gdkLT3dmqudCRXhMhAxfEkiFqsaM2yKK9CSzms
#导入密钥
cleos wallet import 5JJhx7BsRMKNnVcm4gSg7TCkK3B5Dwn2iqjUS6NoSRkJQyRPsxn
#创建三个账号hospital1, patient1, token1
cleos create account eosio hospital1 EOS5jXAL8pkuAb7gdkLT3dmqudCRXhMhAxfEkiFqsaM2yKK9CSzms EOS5jXAL8pkuAb7gdkLT3dmqudCRXhMhAxfEkiFqsaM2yKK9CSzms
cleos create account eosio patient1 EOS5jXAL8pkuAb7gdkLT3dmqudCRXhMhAxfEkiFqsaM2yKK9CSzms EOS5jXAL8pkuAb7gdkLT3dmqudCRXhMhAxfEkiFqsaM2yKK9CSzms
cleos create account eosio token1 EOS5jXAL8pkuAb7gdkLT3dmqudCRXhMhAxfEkiFqsaM2yKK9CSzms EOS5jXAL8pkuAb7gdkLT3dmqudCRXhMhAxfEkiFqsaM2yKK9CSzms
#查看账号列表
cleos get accounts EOS5jXAL8pkuAb7gdkLT3dmqudCRXhMhAxfEkiFqsaM2yKK9CSzms
#加载智能合约
cleos set contract token1 ../contracts/eosio.token -p token1
#发YR币,最多10000个
cleos push action token1 create '{"issuer":"token1", "maximum_supply":"10000.0000 YR", "can_freeze":0, "can_recall":0, "can_whitelist":0}' -p token1
#将200个币发给用户patient1
cleos push action token1 issue '["patient1", "100.0000 YR", "memo"]' -p token1
cleos push action token1 issue '["patient1", "100.0000 YR", "memo"]' -p token1 -d -j
#patient1用户向hospital1用户转账50
cleos push action token1 transfer '["patient1", "hospital1", "50.0000 YR", "One USB disk with CT Images" ]' -p patient1
#查看用户交易列表
cleos get transactions patient1
#查看某次交易的细节
cleos get transaction f217ea4d293a026ed010c527b84d2133c7c335f43234bb58a5c87c911c933b9e
#查看合约id
cleos get code token1
#获取合约描述
cleos get code -a token1.abi token1
账号ID
账号含义
钱包
eosio
矿工1
-
token1
交易所1
default
hospital1
医院1
default
patient1
患者1
default