EOS发币过程记录

参考: medium

创建钱包

cleos wallet create -n alex-wallet --to-console

输出:

Creating wallet: alex-wallet
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5KbQdy5YxYyKgcUMvbxk82tjm5xMEF67qvKCeDohvpiJFwb5hgV"

查看钱包

cleos wallet list

输出:


Wallets:
[
  "alex-wallet *"
]

创建密钥

cleos create key --to-console

输出:

Private key: 5KM58X55iTQiKamSszmCPQRXS1CvA3hMw3h96u6KnX2mrR8e7qj
Public key: EOS7tmDEWoc6qJHAvkbffod7kpXPaJTazNY2uJcVAfYg9QiQ5pmyM

Private key: 5J8esD5uZsrJ72gunW5TfPQTzJyAeY262YPtPZxMDZEBsaimDEg
Public key: EOS7bxXDrUAZoYTR6udrcWEYndDHeV5sHJju6M6opy9qvibc8w8H6


## 密钥导入钱包

cleos wallet import -n alex-wallet --private-key 5KM58X55iTQiKamSszmCPQRXS1CvA3hMw3h96u6KnX2mrR8e7qj

cleos wallet import -n alex-wallet --private-key 5J8esD5uZsrJ72gunW5TfPQTzJyAeY262YPtPZxMDZEBsaimDEg


> 另外还要导入EOSIO的私钥

cleos wallet import -n alex-wallet --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3


##  创建账户

cleos create account eosio eosio.token EOS7bxXDrUAZoYTR6udrcWEYndDHeV5sHJju6M6opy9qvibc8w8H6 EOS7tmDEWoc6qJHAvkbffod7kpXPaJTazNY2uJcVAfYg9QiQ5pmyM


输出:

executed transaction: 968224dd6b597e598430d960ffd30c07834cd23201a4ea655be57977781bc187 200 bytes 28129 us

eosio <= eosio::newaccount {"creator":"eosio","name":"eosio.token","owner":{"threshold":1,"keys":[{"key":"EOS7bxXDrUAZoYTR6udrc...

warning: transaction executed locally, but may not be confirmed by the network yet ]


> 对应owner key: 5J8esD5uZsrJ72gunW5TfPQTzJyAeY262YPtPZxMDZEBsaimDEg
> active key: 5KM58X55iTQiKamSszmCPQRXS1CvA3hMw3h96u6KnX2mrR8e7qj

## 再创建另外两个账户usera userb , 用于转账

> 简单点, 直接用相同的key了

cleos create account eosio usera EOS7bxXDrUAZoYTR6udrcWEYndDHeV5sHJju6M6opy9qvibc8w8H6 EOS7tmDEWoc6qJHAvkbffod7kpXPaJTazNY2uJcVAfYg9QiQ5pmyM

cleos create account eosio userb EOS7bxXDrUAZoYTR6udrcWEYndDHeV5sHJju6M6opy9qvibc8w8H6 EOS7tmDEWoc6qJHAvkbffod7kpXPaJTazNY2uJcVAfYg9QiQ5pmyM


## 生成合约

eosiocpp -n eosio.token


输出:

created eosio.token from skeleton


> 发现生成的合约里面内容居然是helloworld的内容, 所以拷贝过去了

## 编译

eosiocpp -o eosio.token.wast eosio.token.cpp

eosiocpp -g eosio.token.abi eosio.token.cpp


## 部署

cleos set contract eosio.token /eosio.token

输出:

Reading WASM from /eosio.token/eosio.token.wasm...
Publishing contract...
executed transaction: 0b9ff9c12794b6a52cdf310b21fb0aaef03428616d8222ba1e9978105de89d2e 8144 bytes 32370 us

eosio <= eosio::setcode {"account":"eosio.token","vmtype":0,"vmversion":0,"code":"0061736d01000000017e1560037f7e7f0060057f7e...

eosio <= eosio::setabi {"account":"eosio.token","abi":"0e656f73696f3a3a6162692f312e300007076163636f756e7400010762616c616e63..


检查下是否部署成功:

cleos get code eosio.token

输出:

code hash: 373148ead5436184456da0f048d45afdded95e8276c1454619ddf87c65a70a05


## 调用合约, 执行create

cleos push action eosio.token create '["usera","21000000.0000 DEMO"]' -p eosio.token

## 查询状态:

cleos get table eosio.token DEMO stat

输出:

{
"rows": [{

  "supply": "0.0000 DEMO",
  "max_supply": "21000000.0000 DEMO",
  "issuer": "usera"
}

],
"more": false
}

cleos get table eosio.token usera accounts

输出:

{
"rows": [],
"more": false
}


## 调用合约, 执行issue

cleos push action eosio.token issue '["usera","21000000.0000 DEMO","issuance"]' -p usera

输出:

executed transaction: 820c1aa07b55536e3ff11bd0e8f2cb3b4c1d79c18a8df1ecbed7d25ad5fae115 128 bytes 3401 us

eosio.token <= eosio.token::issue {"to":"usera","quantity":"21000000.0000 DEMO","memo":"issuance"


## issue后查询状态

cleos get table eosio.token DEMO stat

输出:

{
"rows": [{

  "supply": "21000000.0000 DEMO",
  "max_supply": "21000000.0000 DEMO",
  "issuer": "usera"
}

],
"more": false
}

> issue之后supply变了

cleos get table eosio.token usera accounts

输出:

{
"rows": [{

  "balance": "21000000.0000 DEMO"
}

],
"more": false
}


> issue 之后usera的accounts信息里的balance有余额了


## 调用合约, 执行转账

cleos push action eosio.token transfer '["usera","userb","1000000.0000 DEMO","here you go"]' -p usera

输出: 

executed transaction: c4b79a6a8ab89b59075e3dbe4fc126bcc8991ef54a2e42b1c98ee729bca228af 136 bytes 2012 us

eosio.token <= eosio.token::transfer {"from":"usera","to":"userb","quantity":"1000000.0000 DEMO","memo":"here you go"}

usera <= eosio.token::transfer {"from":"usera","to":"userb","quantity":"1000000.0000 DEMO","memo":"here you go"}

userb <= eosio.token::transfer {"from":"usera","to":"userb","quantity":"1000000.0000 DEMO","memo":"here you go"}


## 调用转账后查询状态

cleos get table eosio.token DEMO stat

输出:

{
"rows": [{

  "supply": "21000000.0000 DEMO",
  "max_supply": "21000000.0000 DEMO",
  "issuer": "usera"
}

],
"more": false
}

> 没有变化


查询usera账户余额:

cleos get table eosio.token usera accounts

输出:
{
  "rows": [{
      "balance": "20000000.0000 DEMO"
    }
  ],
  "more": false
}
usera 少了100万

查询userb账户余额:

cleos get table eosio.token userb accounts

输出:

{
  "rows": [{
      "balance": "1000000.0000 DEMO"
    }
  ],
  "more": false
}
userb 已经有了100万余额

你可能感兴趣的:(EOS发币过程记录)