本次EOS项目编译操作是在mac上安装的的centos7进行的,可能是虚拟机的问题,本次编译时间较长。下面是本次操作的整个流程。

一、虚拟机安装:具体安装步骤省略,看资料需要我分配了8G内存和50G硬盘,参见下图配置


二、首先需要到github上下载相应的代码,下载地址为:https://github.com/EOSIO/eos 下载前先安装git,安装命令:yum install -y git,安装完成后进入需要保存的硬盘路径下载代码,git clonehttps://github.com/EOSIO/eos --recursive 

三、进入eos, ./eosio_build.sh编译,此时会报错:

eos/scripts/eosio_build_centos.sh:行98: /opt/rh/devtoolset-7/enable: 没有那个文件或目录


这时需要安装一些软件,命令如下:

sudo yum -y --enablerepo=extras install centos-release-scl

  sudo yum install -y devtoolset-7

  sudo yum install -y python33.x86_64

四、使用 ./eosio_build.sh编译,由于下载软件较多,依赖网络速度。

五、编译中出现下载mongodb无法下载问题,试过几个网络都无法下载,最终解决办法是修改编译脚本,由于我的是centos系统,所以修改的是eos/scripts/eosio_build_centos.sh,修改内容如下 


六、当出现这个表示编译通过

七、按上面流程启动mongodb, 设置path,然后测试编译结果

/home/lz/opt/mongodb/bin/mongod -f /home/lz/opt/mongodb/mongod.conf &
source /opt/rh/python33/enable
export PATH=${HOME}/opt/mongodb/bin:$PATH
cd /data/blockchain/eos/build; make test

八、编译后分三个程序

-Cleos,它是一个命令行程序。在前端使用EOS是通过Cleos输入命令,给EOS下达指令。

-Nodeos,其实它就是挖矿客户端。在启动Nodeos之后,它自然就会产生区块。

-Keosd,它是在后端启动。它的目的主要是管理钱包,可以创建私钥。

九、启动nodeos服务,./nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin


十、帐户与钱包是EOS中两个不同的概念,钱包管理所有密钥,帐户是实现用户权限管理,通过权重与阈值来管理不同的权限,系统默认有owner和active权限。

[lz@localhost cleos]$ ./cleos get account lz

{

  "account_name": "lz",

  "permissions": [{

      "perm_name": "active",

      "parent": "owner",

      "required_auth": {

        "threshold": 1,

        "keys": [{

            "key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",

            "weight": 1

          }

        ],

        "accounts": []

      }

    },{

      "perm_name": "owner",

      "parent": "",

      "required_auth": {

        "threshold": 1,

        "keys": [{

            "key": "EOS55pK2pN6vBoZrLdrfmKzU7r4xSuAARtekgKxTuiyfjL29VBE8r",

            "weight": 1

          }

        ],

        "accounts": []

      }

    }

  ]

}

十一、创建钱包

[lz@localhost cleos]$ ./cleos wallet create
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.

"PW5HwWAavqhVRRLKWPLeRxoXEZTfAWHzAaHR5EfgsMxEPqLzLdjLs"


十二、生成公私钥

[lz@localhost cleos]$ ./cleos create key
Private key: 5JYRVnqRBhZUt4SBqBcU3jx53iNFZaWGXrLHiPX3RH39i3DXkYZ

Public key: EOS55pK2pN6vBoZrLdrfmKzU7r4xSuAARtekgKxTuiyfjL29VBE8r

十三、导入私钥

[lz@localhost cleos]$ ./cleos wallet import 5JYRVnqRBhZUt4SBqBcU3jx53iNFZaWGXrLHiPX3RH39i3DXkYZ
imported private key for: EOS55pK2pN6vBoZrLdrfmKzU7r4xSuAARtekgKxTuiyfjL29VBE8r
[lz@localhost cleos]$ ./cleos wallet keys
[[
    "EOS55pK2pN6vBoZrLdrfmKzU7r4xSuAARtekgKxTuiyfjL29VBE8r",
    "5JYRVnqRBhZUt4SBqBcU3jx53iNFZaWGXrLHiPX3RH39i3DXkYZ"
  ],[
    "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
    "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
  ]

]

十四、创建帐户,

lz@localhost cleos]$ ./cleos create account eosio lz EOS55pK2pN6vBoZrLdrfmKzU7r4xSuAARtekgKxTuiyfjL29VBE8r EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
executed transaction: 2e0413099796e17a36d2695b268607e1810b4b3c836ad901ad3ddfb9cd1dbb55  352 bytes  102400 cycles
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"lz","owner":{"threshold":1,"keys":[{"key":"EOS55pK2pN6vBoZrLdrfmKzU7r4xSu...


十五、部署合约

[lz@localhost cleos]$ ./cleos set contract eosio /data/blockchain/eos/build/contracts/eosio.bios -p eosio
Reading WAST/WASM from /data/blockchain/eos/build/contracts/eosio.bios/eosio.bios.wast...
Assembling WASM...
Publishing contract...
executed transaction: a573f334fa7a6e9b46aa9662f060776a4f2082a5697be3576cf2befefa650879  3280 bytes  2200576 cycles
#         eosio <= eosio::setcode               {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001581060037f7e7f0060057f7e7e7e7e...
#         eosio <= eosio::setabi                {"account":"eosio","abi":{"types":[],"structs":[{"name":"set_account_limits","base":"","fields":[{"n...


[lz@localhost cleos]$ ./cleos set contract eosio.token ../../contracts/eosio.token/ -p eosio.token
Reading WAST/WASM from ../../contracts/eosio.token/eosio.token.wast...
Assembling WASM...
Publishing contract...
executed transaction: 986ef3482c1e23e9f7257d7bed3d42ab6af00b01dc77aa3e340d62e0ed83ccb8  8320 bytes  2200576 cycles
#         eosio <= eosio::setcode               {"account":"eosio.token","vmtype":0,"vmversion":0,"code":"0061736d010000000181011560067f7e7f7f7f7f00...
#         eosio <= eosio::setabi                {"account":"eosio.token","abi":{"types":[],"structs":[{"name":"transfer","base":"","fields":[{"name"...

十六、合约调用

[lz@localhost cleos]$ ./cleos push action eosio.token create '["eosio","1000000000.00000 EOS",0,0,0]' -p eosio.token
executed transaction: 20a9e37a1c2197b4795d4d6dc8a8455f4df638ebf2ad3d0acc99ddec7500f26e  248 bytes  104448 cycles
#   eosio.token <= eosio.token::create          {"issuer":"eosio","maximum_supply":"1000000000.00000 EOS","can_freeze":0,"can_recall":0,"can_whiteli...

十七、发币给用户,发币时需要小数点后的位数与创建币时一样,否则会报Error 3030000的错误

[lz@localhost cleos]$ ./cleos push action eosio.token issue '["lz","100.0000 EOS","memo"]' -p eosio
Error 3030000: transaction validation exception
Ensure that your transaction satisfy the contract's constraint!
Error Details:
condition: assertion failed: comparison of assets with different symbols is not allowed


[lz@localhost cleos]$ ./cleos push action eosio.token issue '["lz","100.00000 EOS","memo"]' -p eosio
executed transaction: e46bdee90767242283bc79e9a8913ba538de8694b03eee3560255cfa9cd85c23  256 bytes  126976 cycles
#   eosio.token <= eosio.token::issue           {"to":"lz","quantity":"100.00000 EOS","memo":"memo"}
>> issue
#   eosio.token <= eosio.token::transfer        {"from":"eosio","to":"lz","quantity":"100.00000 EOS","memo":"memo"}
>> transfer
#         eosio <= eosio.token::transfer        {"from":"eosio","to":"lz","quantity":"100.00000 EOS","memo":"memo"}
#            lz <= eosio.token::transfer        {"from":"eosio","to":"lz","quantity":"100.00000 EOS","memo":"memo"}

十八、货币转帐

[lz@localhost cleos]$ ./cleos push action eosio.token transfer '["lz","eosio.token","25.00000 EOS","m"]' -p lz
executed transaction: bf36c33f27b3bd82a0495f3721c780c94ffd690c9031477f493202140f5d37ae  256 bytes  110592 cycles
#   eosio.token <= eosio.token::transfer        {"from":"lz","to":"eosio.token","quantity":"25.00000 EOS","memo":"m"}
>> transfer
#            lz <= eosio.token::transfer        {"from":"lz","to":"eosio.token","quantity":"25.00000 EOS","memo":"m"}


[lz@localhost cleos]$ ./cleos get currency balance eosio.token lz
75.00000 EOS
[lz@localhost cleos]$ ./cleos get currency balance eosio.token eosio.token

25.00000 EOS


参考文章:

https://www.jinse.com/bitcoin/190743.html

https://www.jianshu.com/p/a50851fbb72f





            




Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐