---
# System prepended metadata

title: EOS self-build testnet

---

# EOS self-build testnet

## reference
1. [4.5. 啟動 EOS 節點](http://netkiller.sourceforge.net/blockchain/eos/eos.launch.html)
2. [CryptoLions/EOS-MainNet](https://github.com/CryptoLions/EOS-MainNet)
3. [EOSIO dawn4.0 节点部署方案](https://github.com/eosstore/eosio-dawn4.0/wiki/EOSIO-dawn4.0-%E8%8A%82%E7%82%B9%E9%83%A8%E7%BD%B2%E6%96%B9%E6%A1%88)


---


```shell=
docker run -d -it -p 8881:8080/tcp -p 8891:8888/tcp --name eos1 tony92151/eos_lab:v3
```

```shell=
docker run -d -it -p 8882:8080/tcp -p 8892:8888/tcp --name eos2 tony92151/eos_lab:v3
```

Go to web env (http://localhost:8881) and continue.

```shell=
mkdir -p ~/.local/share/eosio/nodeos/config
cd ~/.local/share/eosio/nodeos/config

wget https://gist.githubusercontent.com/tony92151/bf303abffd06f11d296e02b99da4bf91/raw/c1cc2158648f630c1212e186cf8d998febc10770/config.inii
wget https://genesis.testnet.eos.io/genesis.json

nodeos -e -p eosio --genesis-json /root/.local/share/eosio/nodeos/config/genesis.json

nodeos -e -p eosio \
--plugin eosio::producer_plugin \
--plugin eosio::producer_api_plugin \
--plugin eosio::chain_api_plugin \
--plugin eosio::net_api_plugin \
--plugin eosio::http_plugin \
--plugin eosio::history_plugin \
--plugin eosio::history_api_plugin \
--filter-on="*" \
--access-control-allow-origin='*' \
--contracts-console \
--http-validate-host=false \
--verbose-http-errors \
--http-server-address=0.0.0.0:8888 \
--genesis-json /root/.local/share/eosio/nodeos/config/genesis.json \
--config-dir=/root/.local/share/eosio/nodeos

nodeos --producer-name inita \
--plugin eosio::chain_api_plugin \
--plugin eosio::net_api_plugin \
--http-server-address 0.0.0.0:8888 \
--p2p-listen-endpoint 172.17.0.2:8888 \
--p2p-peer-address 00.0.0.0:9876 
```
```shell=
nodeos -e -p eosio \
--plugin eosio::producer_plugin \
--plugin eosio::chain_api_plugin \
--plugin eosio::http_plugin \
--plugin eosio::history_plugin \
--plugin eosio::history_api_plugin \
--filter-on="*" \
--access-control-allow-origin='*' \
--contracts-console \
--http-validate-host=false \
--verbose-http-errors \
--http-server-address=0.0.0.0:8888
```
Done!
![](https://i.imgur.com/eeRA6Qo.png)

## Set accounts for Vote

Reference
[How to Vote for an EOS Block Producer | Step-by-Step Instructions](https://coincentral.com/how-to-vote-for-an-eos-block-producer/)

```shell=
cleos -u http://172.17.0.2:8888 wallet create -n tony --to-console

cleos -u http://172.17.0.2:8888 wallet import -n tony
# 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

cleos -u http://172.17.0.2:8888 wallet create_key -n tony
# this command create one key pair (public & private key. Remember this)

cleos -u http://172.17.0.2:8888 create account eosio john {public key} -p eosio@active

cleos -u http://172.17.0.2:8888 wallet private_keys -n tony
# wallet key
```

## Use Anchor (EOS wallet GUI manager)

Github : [Anchor](https://github.com/greymass/anchor)

Remember these two informations and `Endpoint`
![](https://i.imgur.com/fvizGdZ.png)


Open Anchor app and click `Setup New Wallet` > `Custom Blockchain`

![](https://i.imgur.com/07rafow.png)

![](https://i.imgur.com/q9tfR9X.png)

Enter the information mentioned above and `save`
![](https://i.imgur.com/pvq3f7I.png)


`Select` and `Enable`

![](https://i.imgur.com/MHJhGlp.png)

Go to `eosio testnet` > `Import account`
![](https://i.imgur.com/wg3abdi.png)

click `Import Private key`
![](https://i.imgur.com/wSbKSb4.png)

:::warning
You need to set wallet password when init wallet 
:::

Use `john` private key to import account
![](https://i.imgur.com/3vj0kAz.png)

Done!
![](https://i.imgur.com/mDARj26.png)



## other monitor

https://eosauthority.com/?network=eos#recentBlocks

https://medium.com/@auroraeos/eos-voting-guide-3bf4e0be251b


## `nodeos` note

:::info

```shell=
nodeos \
  -e -p eosio \
  --data-dir /users/mydir/eosio/data     \
  --config-dir /users/mydir/eosio/config \
  --plugin eosio::producer_plugin      \
  --plugin eosio::chain_plugin         \
  --plugin eosio::http_plugin          \
  --plugin eosio::state_history_plugin \
  --contracts-console   \
  --disable-replay-opts \
  --access-control-allow-origin='*' \
  --http-validate-host=false        \
  --verbose-http-errors             \
  --state-history-dir /shpdata \
  --trace-history              \
  --chain-state-history
```

enabling block production (-e)
identifying itself as block producer "eosio" (-p)
setting the blockchain data directory (--data-dir)
setting the config.ini directory (--config-dir)
loading plugins **producer_plugin**, chain_plugin, http_plugin, state_history_plugin (--plugin)
passing chain_plugin options (--contracts-console, --disable-replay-opts)
passing http-plugin options (--access-control-allow-origin, --http-validate-host, --verbose-http-errors)
passing state_history options (--state-history-dir, --trace-history, --chain-state-history)
redirecting both stdout and stderr to the nodeos.log file
returning to the shell by running in the background (&)
:::

### node have two type
* Producing Node
* Non-Producing Node

`Producing Nodes`配置用於塊生產。他們連接到對等網絡並積極產生新的區塊。鬆散的交易也將得到驗證和轉發。在主網上，`Producing Nodes`僅當分配的塊生產者是活動計劃的一部分時才產生塊。 :+1: 

`Non-Producing Nodes`連接到對等網絡，但不主動產生新的區塊；它們可用作代理節點，**中繼API調用**，驗證交易，向其他節點廣播信息等，`Non-Producing Nodes`也可用於監視區塊鏈狀態。


### Producing node :+1: 
**Steps**
Please follow the steps below to set up a producing node:

1. Register your account as a producer
2. Set Producer Name
3. Set the Producer's signature-provider
4. Define a peers list
5. Load the Required Plugins

:::info
```shell=
cleos system regproducer accountname1 EOS1234534... http://producer.site Antarctica
```
`account` TEXT - The account to register as a producer
`producer_key` TEXT - The producer's public key
`url` TEXT - URL where info about producer can be found
`location` UINT - Relative location for purpose of nearest neighbor scheduling

usage [System Regproducer](https://developers.eos.io/manuals/eos/latest/cleos/command-reference/system/system-regproducer)
:::

```shell=
cleos -u http://172.17.0.2:8888 system regproducer sally2 EOS8mJTwm9keuYiuzzwpvFch8y2skuPnJGhjwbwTXHCtP9UPo9rJ6 -p sally2@active
```

## Node2

```shell=
nodeos -e -p eosio \
--plugin eosio::producer_plugin \
--plugin eosio::chain_api_plugin \
--plugin eosio::http_plugin \
--plugin eosio::history_plugin \
--plugin eosio::history_api_plugin \
--filter-on="*" \
--access-control-allow-origin='*' \
--contracts-console \
--http-validate-host=false \
--verbose-http-errors \
--http-server-address=0.0.0.0:8888
```

## Init node contract

[EOS V2.0.x 部署eosio.bios合约，需先激活 WTMSIG_BLOCK_SIGNATURES 共识](https://www.bcskill.com/index.php/archives/884.html)

```shell=
git clone --branch add-boot-contract https://github.com/EOSIO/eosio.contracts.git 
cd eosio.contracts
./build.sh && cd

curl -X POST http://172.17.0.2:8888/v1/chain/get_activated_protocol_features -d '{}' | jq

curl -X POST http://172.17.0.2:8888/v1/producer/schedule_protocol_feature_activations -d '{"protocol_features_to_activate": ["0ec7e080177b2c02b278d5088611686b49d739925a92d9bfcacd7fc6b74053bd"]}' | jq

curl -X POST http://172.17.0.2:8888/v1/chain/get_activated_protocol_features -d '{}' | jq

cleos -u http://172.17.0.2:8888 set contract eosio eosio.contracts/build/contracts/eosio.boot -p eosio@active

cleos -u http://172.17.0.2:8888 set contract eosio eosio.contracts/build/contracts/eosio.bios -p eosio@active

cleos -u http://172.17.0.2:8888 set contract eosio eosio.contracts/build/contracts/eosio.system -p eosio@active
```

see [here](https://developers.eos.io/manuals/eos/latest/nodeos/usage/development-environment/local-multi-node-testnet)

```shell=
export node_name=john
export noden_key=EOS56sE3Xx7vtaQazDPj3ExEVjGm7G5iXT3CH6ezkKsovp6XyFjW4
export noden_pkey=5Kgp1QswMvDuXbgZNiRiCzhTA7hecaRbKgytgZyFFfYAPR1n8jH
```
```shell=
nodeos --producer-name $node_name \
--plugin eosio::chain_api_plugin \
--plugin eosio::net_api_plugin \
--http-server-address 0.0.0.0.0:8889 \
--p2p-listen-endpoint 0.0.0.0:9877 \
--p2p-peer-address 172.17.0.2:9876 \
--private-key [\"$noden_key\",\"$noden_pkey\"]
```

註冊為生產者 :X:
```shell=
cleos -u http://172.17.0.2:8888 push action eosio setprods "{ \"schedule\": [{\"producer_name\": \"inita\",\"block_signing_key\": \"EOS56sE3Xx7vtaQazDPj3ExEVjGm7G5iXT3CH6ezkKsovp6XyFjW4\", \"authority\": [\"EOS56sE3Xx7vtaQazDPj3ExEVjGm7G5iXT3CH6ezkKsovp6XyFjW4\"]}]}" -p eosio@active

cleos -u http://172.17.0.2:8888 push action eosio setprods "{ \"schedule\": [{\"authority\": [{\"producer_name\": \"inita\",\"block_signing_key\": \"EOS56sE3Xx7vtaQazDPj3ExEVjGm7G5iXT3CH6ezkKsovp6XyFjW4\"}]}]}" -p eosio@active

cleos -u http://172.17.0.2:8888 push action eosio setprods '{"schedule": [{"producer_name": "inita","block_signing_key": "EOS56sE3Xx7vtaQazDPj3ExEVjGm7G5iXT3CH6ezkKsovp6XyFjW4"}]}' -p eosio@active
```

### FIX
[see](https://eosio.stackexchange.com/questions/5234/action-setprods-on-eosio-v2-0-private-chain)
```shell=
cleos -u http://localnetwork.com:8888 push action eosio setprods "testnetprods.json" -p eosio@active
```
```json=
{
    "schedule": [
        {
            "producer_name": "eosio",
            "authority": [
                "block_signing_authority_v0",
                {
                    "threshold": 1,
                    "keys": [
                        {
                            "key": "EOS8xxxx",
                            "weight": 1
                        }
                    ]
                }
            ]
        }
    ]
}
```


![](https://i.imgur.com/tM5IyKP.png)

## web GUI tool

https://eosauthority.com/wallet/stake?network=localtest&endpoint=http:%2F%2Flocalhost:8891&token_symbol=QAQ

![](https://i.imgur.com/cYa1BnF.png)


## READ EOS解读--配置文件
[EOS解读--配置文件](https://www.jianshu.com/p/02e2db11d152)

```ini=
http-server-address = 0.0.0.0:8888 #这里设置四个0代表本地可以通过localhost或者127.0.0.1调用http接口，同时外部可以通过本机固定ip访问。
p2p-listen-endpoint = 0.0.0.0:9876 #p2p网络本机监听端口，监听外部接入的p2p节点，这里的四个0的ip配置意义同上。
bnet-endpoint = 0.0.0.0:4321 #bnet是使用一个非常简单的算法来同步两条区块链。主要工作是两条链上的确权，共识，广播，同步区块，保持默认配置即可。
p2p-peer-address = ip:port #对端p2p节点地址，可以设置多个。
enable-stale-production = true #意思是可以不经过确权直接出块，单节点时要配置为true，多节点出块由于需要各方确权共识，要配置为false。
producer-name = eosio #出块者，创世块，默认eosio账户
signature-provider = EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 ，密钥对，公钥加私钥，对应eosio账户，这对秘钥是写死的，不可改变。
```




