EOS私有网络发行代币

1.进入github上clone下来的eos目录

$ cd ~/eos

2.创建eosio.token

$ cleos create account eosio eosio.token EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV

executed transaction: 29abbafdd8c01c4895db000d2c30338462cf2792b7f5ca55c94544e46167d91e 200 bytes 360 us # eosio <= eosio::newaccount "0000000000ea305500a6823403ea305501000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca56... warning: transaction executed locally, but may not be confirmed by the network yet ]

3.添加eosio.bios合约

eosio.bios合约用于控制资源分配和权限管理

cleos set contract eosio build/contracts/eosio.bios -p eosio@active

4.部署token合约

$ cleos set contract eosio.token build/contracts/eosio.token -p eosio.token

Reading WASM from build/contracts/eosio.token/eosio.token.wasm... Publishing contract... executed transaction: 894586b86e0489e125a425c0cfe5af23e4d1f35748c9df2d74e228dd0a370907 8104 bytes 1907 us # eosio <= eosio::setcode "00a6823403ea305500009594010061736d01000000017e1560037f7e7f0060057f7e7e7f7f0060047f7e7f7f00600000600... # eosio <= eosio::setabi "00a6823403ea3055b4030e656f73696f3a3a6162692f312e30010c6163636f756e745f6e616d65046e616d6505087472616... warning: transaction executed locally, but may not be confirmed by the network yet ] -p,–permission TEXT 表示授权账号,该合约授权给eosio.token账号。
代币合约eosio.token能让许多不同的代币同时在一个智能合约上发行,但是却能被不同用户管理。

5.创建代币

$ cleos push action eosio.token create '[ "eosio.token", "1000000000.0000 SYS"]' -p eosio.token

executed transaction: 50506b4723126945574fdee524c34f4bf349988fbcc4d015a35c0fb0ff9cdb5e 120 bytes 442 us # eosio.token <= eosio.token::create {"issuer":"eosio","maximum_supply":"1000000000.0000 SYS"} warning: transaction executed locally, but may not be confirmed by the network yet ]

create 函数是用来新建一种代币,并输入代币的各种属性,同时 create 函数也是一个 action。action 是 eos 智能合约的接口函数,定义外界可以对智能合约做什么动作。 结合操作命令,说明各个参数的定义: create(
account_name issuer,/发行方账号的名称为”eosio”/
asset maximum_supply,/总供应量为10亿和代币名称/

6.发行代币

$ cleos push action eosio.token issue '[ "111111111111", "10000.0000 SYS", "first SYS issue" ]' -p eosio.token

executed transaction: 87ad76b03fbace95ec435d22d474dffd402d571e51b31bf31f5fd9a2a057aca9 144 bytes 1846 us # eosio.token <= eosio.token::issue {"to":"111111111111","quantity":"10000.0000 SYS","memo":"first ColorBayToken issue"} # eosio.token <= eosio.token::transfer {"from":"eosio","to":"111111111111","quantity":"10000.0000 SYS","memo":"first ColorBayToken issue"} # eosio <= eosio.token::transfer {"from":"eosio","to":"111111111111","quantity":"10000.0000 SYS","memo":"first ColorBayToken issue"} # 111111111111 <= eosio.token::transfer {"from":"eosio","to":"111111111111","quantity":"10000.0000 SYS","memo":"first ColorBayToken issue"}

issue action 来获得代币。
void issue( account_name to, /代币的发行方为账户/
asset quantity, /发行代币的数量为10000个,代币名称为CBT/
string memo ); /表示备注说明,不能超过256个字节/

7.转账

创建账户可参考这里

$ cleos push action eosio.token transfer '[ "111111111111", "111111111112", "8000.0000 SYS", "pay!" ]' -p 111111111111

transfer action 来获得代币。
void transfer(
account_name from, /转账方/
account_name to, /接收方/
asset quantity, /转账的数量/
string memo ); /表示备注说明,不能超过256个字节/

EOS开发环境搭建–账户创建

1.创建钱包

$ cleos wallet create --to-console

Creating wallet: default Save password to use in the future to unlock this wallet. Without password imported keys will not be retrievable. "PW5JvSUVTLst22cjZ1q1mwo6bqgFtEYhNgy1dg6zSDaaYvJp4W2Di"
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
“PW5JvSUVTLst22cjZ1q1mwo6bqgFtEYhNgy1dg6zSDaaYvJp4W2Di”

2.创建私钥

$ cleos create key

3.导入私钥

导入上一步生成的私钥

$ cleos wallet import

root@fuck:~/eos# cleos wallet import private key: imported private key for: EOS6dEyb2tydFUrDBg2BZ9s7a8igFkyDNuNh7PWadxK9hp9u9EF6B root@fuck:~/eos# cleos wallet import private key: imported private key for: EOS6iY6sbtVYMhhiJaW228K2iSDxCzR2j88ekJtQeBBwxo828tsTQ
root@fuck:~/eos# cleos wallet import
private key: imported private key for: EOS6dEyb2tydFUrDBg2BZ9s7a8igFkyDNuNh7PWadxK9hp9u9EF6B
root@fuck:~/eos# cleos wallet import
private key: imported private key for: EOS6iY6sbtVYMhhiJaW228K2iSDxCzR2j88ekJtQeBBwxo828tsTQ

4.注册账户名

$ cleos create account eosio 111111111111 EOS6dEyb2tydFUrDBg2BZ9s7a8igFkyDNuNh7PWadxK9hp9u9EF6B EOS6dEyb2tydFUrDBg2BZ9s7a8igFkyDNuNh7PWadxK9hp9u9EF6B

果不其然,报错…..

Error 3090003: Provided keys, permissions, and delays do not satisfy declared authorizations Ensure that you have the related private keys inside your wallet and your wallet is unlocked.
Error 3090003: Provided keys, permissions, and delays do not satisfy declared authorizations
Ensure that you have the related private keys inside your wallet and your wallet is unlocked.

原因是要先导入eosio这个账户,其他的账户再由这个账户生成

eosio public key: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
eosio private key: 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

导入eosio

$ cleos wallet import --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

executed transaction: 6c6997dda1f91c95f0291fc40338a499ac9b8f4e5b02f2e5bd53db4e6e15ee5c 200 bytes 4601 us # eosio <= eosio::newaccount {"creator":"eosio","name":"111111111111","owner":{"threshold":1,"keys":[{"key":"EOS6dEyb2tydFUrDBg2B... warning: transaction executed locally, but may not be confirmed by the network yet ]
executed transaction: 6c6997dda1f91c95f0291fc40338a499ac9b8f4e5b02f2e5bd53db4e6e15ee5c 200 bytes 4601 us
# eosio <= eosio::newaccount {“creator”:”eosio”,”name”:”111111111111″,”owner”:{“threshold”:1,”keys”:[{“key”:”EOS6dEyb2tydFUrDBg2B…
warning: transaction executed locally, but may not be confirmed by the network yet ]
至此钱包账户生成就完成了

EOS私有网络快速搭建

根据EOS官方推介的操作系统走,用Ubuntu 16.04以上的版本作为运行环境(用其他的很有可能出很多的问题)

1.从全球最大gay交友网站github上下载源码

$ git clone https://github.com/EOSIO/eos --recursive

2.运行eosio_build.sh安装所需的环境和编译环境

$ ./eosio_build.sh

编译成功

根据安装提示,配置mongodb

$ export PATH=${HOME}/opt/mongodb/bin:$PATH

$ /root/opt/mongodb/bin/mongod -f /root/opt/mongodb/mongod.conf &

$ cd /root/eos/build; make test

最后一步有可能会有点儿慢

3.安装

$ ./eosio_install.sh

4.快速启动私有网络

$ nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin

再重新开一个窗口运行

$ cleos get info

至此私有网络搭建成功