官方文档获取代码git clone https://github.com/EOSIO/eos –recursive# –recursive表示自动获取更新子项目,相当于:# git submodule update –init –recursive4中编译方式自动编译脚本笔者目前采取第一种方式编译,4核8G的电脑编译了2个小时。Docker Compose手动编译安装执行文件配置EOS配置文件配置文件地址:Linux: /.local/share/eosio/nodeos/config区块文件:Linux:/.local/share/eosio/nodeos/data单节点网络# 1.命令行启动$ cd build/programs/nodeos$ ./nodeos -e -p eosio –plugin eosio::chain_api_plugin –plugin eosio::history_api_plugin# 2.通过配置config.ini方式# Enable production on a stale chain, since a single-node test chain is pretty much always staleenable-stale-production = true# Enable block production with the testnet producersproducer-name = eosio# Load the block producer plugin, so you can produce blocksplugin = eosio::producer_plugin# As well as API and HTTP pluginsplugin = eosio::chain_api_pluginplugin = eosio::http_plugin# This will be used by the validation step below, to view historyplugin = eosio::history_api_plugin多节点网络开启钱包管理// 第一个窗口$ keosd –http-server-address 127.0.0.1:8899创建默认钱包// 第二个窗口$ cleos –wallet-url http://127.0.0.1:8899 wallet create –to-console// 备份密码将来使用Creating wallet: defaultSave password to use in the future to unlock this wallet.Without password imported keys will not be retrievable.“PW5JsmfYz2wrdUEotTzBamUCAunAA8TeRZGT57Ce6PkvM12tre8Sm"导入eos key上面步骤中启动的私有区块链是用默认的初始键创建的,该初始键必须加载到钱包中。$ cleos –wallet-url http://127.0.0.1:8899 wallet import –private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3imported private key for: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV启动第一个生产节点// 第三个窗口$ nodeos –enable-stale-production –producer-name eosio –plugin eosio::chain_api_plugin –plugin eosio::net_api_plugin启动第二个节点这个命令在${EOSIO_SOURCE}目录运行。在启动额外的节点之前,你必须先加载eosio.bios合约。该合约使您能够直接控制其他帐户的资源分配,并访问其他特权API调用。返回到第二个终端窗口,运行以下命令加载合同:// 第二个窗口$ cleos –wallet-url http://127.0.0.1:8899 set contract eosio build/contracts/eosio.bios$ cleos create keyPrivate key: 5JgbL2ZnoEAhTudReWH1RnMuQS6DBeLZt4ucV6t8aymVEuYg7srPublic key: EOS6hMjoWRF2L8x9YpeqtUEcsDKAyxSuM1APicxgRU1E3oyV5sDEg$ cleos –wallet-url http://127.0.0.1:8899 wallet import 5JgbL2ZnoEAhTudReWH1RnMuQS6DBeLZt4ucV6t8aymVEuYg7srimported private key for: EOS6hMjoWRF2L8x9YpeqtUEcsDKAyxSuM1APicxgRU1E3oyV5sDEg// 创建一个账户需要2个public key;一个是owner key和active key. 这里2个key一样。$ cleos –wallet-url http://127.0.0.1:8899 create account eosio inita EOS6hMjoWRF2L8x9YpeqtUEcsDKAyxSuM1APicxgRU1E3oyV5sDEg EOS6hMjoWRF2L8x9YpeqtUEcsDKAyxSuM1APicxgRU1E3oyV5sDEgexecuted transaction: d1ea511977803d2d88f46deb554f5b6cce355b9cc3174bec0da45fc16fe9d5f3 352 bytes 102400 cycles# eosio <= eosio::newaccount {“creator”:“eosio”,“name”:“inita”,“owner”:{“threshold”:1,“keys”:[{“key”:“EOS6hMjoWRF2L8x9YpeqtUEcsDK…// 第四个窗口$ nodeos –producer-name inita –plugin eosio::chain_api_plugin –plugin eosio::net_api_plugin –http-server-address 127.0.0.1:8889 –p2p-listen-endpoint 127.0.0.1:9877 –p2p-peer-address 127.0.0.1:9876 –config-dir node2 –data-dir node2 –private-key ["EOS6hMjoWRF2L8x9YpeqtUEcsDKAyxSuM1APicxgRU1E3oyV5sDEg","5JgbL2ZnoEAhTudReWH1RnMuQS6DBeLZt4ucV6t8aymVEuYg7sr"]// 到这里,第二个节点是一个空闲的producer。切换producer,让inita变成active producer,需要bios node操作$ cleos –wallet-url http://127.0.0.1:8899 push action eosio setprods “{ "schedule": [{"producer_name": "inita","block_signing_key": "EOS6hMjoWRF2L8x9YpeqtUEcsDKAyxSuM1APicxgRU1E3oyV5sDEg"}]}” -p eosio@activeexecuted transaction: 2cff4d96814752aefaf9908a7650e867dab74af02253ae7d34672abb9c58235a 272 bytes 105472 cycles# eosio <= eosio::setprods {“version”:1,“producers”:[{“producer_name”:“inita”,“block_signing_key”:“EOS6hMjoWRF2L8x9YpeqtUEcsDKA…// 验证结果cleos get infocleos –url http://127.0.0.1:8889 get info