---
# System prepended metadata

title: EOS green book

---

# EOS green book

## 3.1 EOS 框架總覽

1. 腳本層
2. 插件層
3. 合約層
4. 支持層

### 3.1.1 腳本層

use`script file` to build EOS 
include `eosio_build.sh`

see [this](https://github.com/EOSIO/eos/tree/master/scripts)

### 3.1.2 插件層

EOS rely on `plugin` layer to serveces.
Such as block search, transation, block package, P2P communication.

`REG`>`INIT`>`START`>`STOP`

see [this](https://github.com/EOSIO/eos/tree/master/plugins)

包刮 模板層、基類層、python層、封裝層
![](https://i.imgur.com/BaKu0si.png)

* [模板層](https://github.com/EOSIO/eos/tree/master/plugins/template_plugin)
![](https://i.imgur.com/VDltn2a.png)


* 基類層
![](https://i.imgur.com/eAbqCV3.png)

* 合約層

用戶可以調用已經不上鏈的智能合約

以下為5個系統及的智能合約
![](https://i.imgur.com/YBxaOHO.png)

1. `eosio.bios`
    用於啟動EOS 的 P2P 網路
2. `eosio.msig`
    用於定義multi-sign
3. `eosio.sudo`
    用於root帳號，可修改更新合約
4. `eosio.system`
    管理EOS的基本功能，如：創建帳戶、部署智能合約、交易RAM/CPU、投票等
5. `eosio.token`
    發行貨幣、初始分發、轉帳、餘額查詢


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

1. `eos/conteact/asserter`
    asserter節構
2. `eos/conteact/bancor`
    貨幣之間的轉換
    
    
    
### 3.1.4 支持層

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


## 3.2 共識演算法

### 3.2.1 DPoS code 

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

see [eos/programs/cleos/main.cpp](https://github.com/EOSIO/eos/blob/master/programs/cleos/main.cpp)

see [eosio.contracts/contracts/eosio.system/src/voting.cpp](https://github.com/EOSIO/eosio.contracts/blob/master/contracts/eosio.system/src/voting.cpp)


## 3.4 網路層

**reference**
1. p70 [Boost 的事件管理架構：Signal / Slot](https://kheresy.wordpress.com/2011/04/07/boost_signals_part1/)

## 3.5 系統合約

eosio.system
eosio.token
eosio.msig
eosio.bios
eosio.sudo

### 3.5.1 eosio.system

用於抵押資源、投票

### 3.5.2 eosio.token

用於生產代幣、轉帳
1. create fun
2. issue fun
3. transfer fun
4. sub_balance fun

### 3.5.3 eosio.msig (multi-signature)
 abi, cpp, hpp
 
 1. proPoSe
 2. approve 同意修改
 3. unapprove
 4. canel
 5. exec

## 3.5.4 eosiolib

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

1. types.hpp
2. action.h
3. print.h
4. multi_index.hpp
5. dispatcher.hpp
6. contract.cpp
7. eosiolib.cpp
8. stdlib.hpp
9. chain.h
10. compiler_builtins.h
11. crypto.h
12. db.h
13. system.h
14. permission.hpp
15. privileged.hpp
16. asset.hpp
17. currency.hpp
18. datastream.hpp
19. fixed_key.hpp
20. fixedpoint.hpp
21. optional.hpp
22. producer_schedule.hpp
23. public_key.hpp
24. reflect.hpp
25. serialize.hpp
26. singleton.hpp
27. symbol.hpp
28. time.hpp
29. transaction.hpp
30. varint.hpp
31. vector.hpp

## 3.6 EOS key tools

### 3.6.1 nodeos

in `~/.local/share/eosio/nodeos/config` have `config.ini`, `genesis,json`

### 3.6.2 cleos (client eos)

### 3.6.3 keosd



