纯净机器上部署 EOS 测试网
演示的系统为 Ubuntu 18.04 LTS,内存8g以上,硬盘300g+
clone EOS代码
们以EOS-Mainnet仓库部署,(EOS-Mainnet是部署在目前EOS主网的版本,等于再次在EOSIO仓库测试过的版本,更稳定。)
开始clone 代码
//如果没有安装git,先安装
$sudo apt install git
$git clone https://github.com/EOS-Mainnet/eos.git
切换到最新分支(当前的EOS最新版本为 v1.4.3)
更新子模块代码
git submodule update --init --recursive
编译代码
./eosio_build.sh -s EOS
安装程序
sudo ./eosio_install.sh
创建配置文件夹
sudo mkdir /data
sudo chmod 777 /data
cd /data
创建缺省钱包
cleos wallet create --to-console
输出密码如:PW5Kequvj31v37mAeBEPtx2mNcs5SHCjoZXf4sWw67GvxuNPZwfEf
这里会产生一个密码,可以把密码保存下来
echo PW5Kequvj31v37mAeBEPtx2mNcs5SHCjoZXf4sWw67GvxuNPZwfEf > pwd.txt
生成genesis.json文件
mkdir config
mkdir data
cd config
nodeos --extract-genesis-json genesis.json
新建一个config.ini文件, 并添加如下内容
http-server-address = 0.0.0.0:8000
p2p-listen-endpoint = 0.0.0.0:8001
agent-name = "EOS AI"
producer-name = eosio
signature-provider = EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
#创世节点才需要,其他bp不需要开启
enable-stale-production = true
#以下为通用设置
max-transaction-time=1000
wasm-runtime = wabt
pause-on-startup = false
abi-serializer-max-time-ms = 3000
chain-state-db-size-mb = 65535
reversible-blocks-db-size-mb = 2048
contracts-console = false
p2p-max-nodes-per-host = 1
allowed-connection = any
max-clients = 100
network-version-match = 1
sync-fetch-span = 500
#filter-on = *
connection-cleanup-period = 30
max-implicit-request = 1500
http-validate-host = false
access-control-allow-origin = *
access-control-allow-headers = *
access-control-allow-credentials = false
verbose-http-errors = true
#添加插件
plugin = eosio::chain_api_plugin
plugin = eosio::history_plugin
plugin = eosio::history_api_plugin
plugin = eosio::producer_plugin
首次启动节点
cd /data
nodeos --genesis-json ./config/genesis.json --max-irreversible-block-age 108000000 --data-dir ./data --config-dir ./config --delete-all-blocks
激活eosio账号
cleos wallet import --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
特别注意,本文中的其它密码,KEY都是自定义的, 这里这个KEY必须是这个串,不得变更。
创建基础合约
cd {EOS源码路径}/build/contracts
cleos -u http://127.0.0.1:8000 set contract eosio eosio.bios/ -p eosio
创建系统基础账号
cleos wallet import --private-key 5JBCqbY4EuwtVxCz4qBMXTGiT1hRr1bEjbZPKM16Q7fgcb8ikEP
cleos -u http://127.0.0.1:8000 create account eosio eosio.sudo EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831
cleos -u http://127.0.0.1:8000 create account eosio eosio.vpay EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831
cleos -u http://127.0.0.1:8000 create account eosio eosio.token EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831
cleos -u http://127.0.0.1:8000 create account eosio eosio.bpay EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831
cleos -u http://127.0.0.1:8000 create account eosio eosio.msig EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831
cleos -u http://127.0.0.1:8000 create account eosio eosio.names EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831
cleos -u http://127.0.0.1:8000 create account eosio eosio.ram EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831
cleos -u http://127.0.0.1:8000 create account eosio eosio.ramfee EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831
cleos -u http://127.0.0.1:8000 create account eosio eosio.saving EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831
cleos -u http://127.0.0.1:8000 create account eosio eosio.stake EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831
创建系统基础合约
cleos -u http://127.0.0.1:8000 set contract eosio.token eosio.token
cleos -u http://127.0.0.1:8000 push action eosio.token create '["eosio","10000000000.0000 EOS",0,0,0]' -p eosio.token
cleos -u http://127.0.0.1:8000 push action eosio.token issue '["eosio","1000000000.0000 EOS","issue"]' -p eosio
cleos -u http://127.0.0.1:8000 get currency balance eosio.token eosio
cleos -u http://127.0.0.1:8000 set contract eosio eosio.msig -p eosio
cleos -u http://127.0.0.1:8000 set contract eosio eosio.system -p eosio
其中最后一句, 可以多执行几遍,确保输出类似如下内容,表示合约已经确认,不然后面调用合约创建账号可能会报错。
Reading WASM from eosio.system/eosio.system.wasm...
Skipping set code because the new code is the same as the existing code
Skipping set abi because the new abi is the same as the existing abi
no transaction is sent
cleos -u http://127.0.0.1:8000 set contract eosio eosio.sudo -p eosio
创建其它账号
cleos -u http://127.0.0.1:8000 system newaccount eosio eosio.bp1 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 --stake-net "20000 EOS" --stake-cpu "20000 EOS" --buy-ram "20000 EOS"
cleos -u http://127.0.0.1:8000 system newaccount eosio eosio.bp2 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 --stake-net "20000 EOS" --stake-cpu "20000 EOS" --buy-ram "20000 EOS"
cleos -u http://127.0.0.1:8000 system newaccount eosio eosio.bp3 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 EOS8V8fLfYQhjdMLkFzz12YdK3UBCAw8mT7imCiJGfgxTdNs9H831 --stake-net "20000 EOS" --stake-cpu "20000 EOS" --buy-ram "20000 EOS"
cleos -u http://127.0.0.1:8000 get account eosio.bp1
cleos -u http://127.0.0.1:8000 get account eosio.bp2
cleos -u http://127.0.0.1:8000 get account eosio.bp3