README.md 23.4 KB
Newer Older
1
## EOS.IO - The Most Powerful Infrastructure for Decentralized Applications
N
Nathan Hourt 已提交
2

peterwillcn's avatar
peterwillcn 已提交
3 4
[![Build Status](https://travis-ci.org/EOSIO/eos.svg?branch=master)](https://travis-ci.org/EOSIO/eos)

D
Daniel Larimer 已提交
5 6
Welcome to the EOS.IO source code repository!  EOS.IO software enables developers to create and deploy
high-performance, horizontally scalable, blockchain infrastructure upon which decentralized applications
7
can be built.
D
Daniel Larimer 已提交
8 9

This code is currently alpha-quality and under rapid development. That said,
10 11
there is plenty early experimenters can do including running a private multi-node test network and
developing applications (smart contracts).
D
Daniel Larimer 已提交
12

13 14
The public testnet described in the [wiki](https://github.com/EOSIO/eos/wiki/Testnet%3A%20Public) is running the `dawn-2.x` branch.  The `master` branch is no longer compatible with the public testnet.  Instructions are provided below for building either option.

D
Daniel Larimer 已提交
15 16
# Resources
1. [EOS.IO Website](https://eos.io)
17 18
2. [Documentation](https://eosio.github.io/eos/)
3. [Blog](https://steemit.com/@eosio)
S
Sandwich 已提交
19
4. [Community Telegram Group](https://t.me/EOSProject)
20 21 22
5. [Developer Telegram Group](https://t.me/joinchat/EaEnSUPktgfoI-XPfMYtcQ)
6. [White Paper](https://github.com/EOSIO/Documentation/blob/master/TechnicalWhitePaper.md)
7. [Roadmap](https://github.com/EOSIO/Documentation/blob/master/Roadmap.md)
N
Nathan Hourt 已提交
23

24 25 26
# Table of contents

1. [Getting Started](#gettingstarted)
S
Serg Metelin 已提交
27
2. [Setting up a build/development environment](#setup)
28
	1. [Automated build script](#autobuild)
29
      1. [Clean install Ubuntu 16.10 for a local testnet](#autoubuntulocal)
R
RadW2020 已提交
30
      2. [Clean install Ubuntu 16.10 for the public testnet](#autoubuntupublic)
31 32
      3. [MacOS Sierra 10.12.6 for a local testnet](#automaclocal)
      4. [MacOS Sierra 10.12.6 for the public testnet](#automacpublic)
S
Serg Metelin 已提交
33
3. [Building EOS and running a node](#runanode)
34 35 36
	1. [Getting the code](#getcode)
	2. [Building from source code](#build)
	3. [Creating and launching a single-node testnet](#singlenode)
S
Sandwich 已提交
37 38
4. [Example Currency Contract Walkthrough](#smartcontracts)
	1. [Example Contracts](#smartcontractexample)
39 40 41
	2. [Setting up a wallet and importing account key](#walletimport)
	3. [Creating accounts for your smart contracts](#createaccounts)
	4. [Upload sample contract to blockchain](#uploadsmartcontract)
42
	5. [Pushing a message to a sample contract](#pushamessage)
43 44
	6. [Reading Currency Contract Balance](#readingcontract)
5. [Running local testnet](#localtestnet)
45 46 47 48
6. [Running a node on the public testnet](#publictestnet)
7. [Doxygen documentation](#doxygen)
8. [Running EOS in Docker](#docker)
9. [Manual installation of the dependencies](#manualdep)
S
Sandwich 已提交
49 50
   1. [Clean install Ubuntu 16.10](#ubuntu)
   2. [MacOS Sierra 10.12.6](#macos)
51

S
Serg Metelin 已提交
52 53
<a name="gettingstarted"></a>
## Getting Started
54
The following instructions detail the process of getting the software, building it, running a simple test network that produces blocks, account creation and uploading a sample contract to the blockchain.
N
Nathan Hourt 已提交
55

S
Serg Metelin 已提交
56 57
<a name="setup"></a>
## Setting up a build/development environment
58

59 60 61
<a name="autobuild"></a>
### Automated build script

62
For Ubuntu 16.10 and MacOS Sierra, there is an automated build script that can install all dependencies and builds EOS.
63

64
It is called build.sh with the following inputs.
65
- architecture [ubuntu|darwin]
66
- optional mode [full|build]
67

68
The second optional input can be `full` or `build` where `full` implies that it installs dependencies and builds eos. If you omit this input then the build script installs dependencies and then builds eos.
69 70

```bash
71
./build.sh <architecture> <optional mode>
72
```
73
Choose whether you will be building for a local testnet or for the public testnet and jump to the appropriate section below.  Clone the EOS repository recursively as described and run build.sh located in the root `eos` folder.
74

75 76 77 78
:warning: **As of February 2018, `master` is under heavy development and is not suitable for experimentation.** :warning:

We strongly recommend following the instructions for building the public testnet version. `master` is in pieces on the garage floor while we rebuild this hotrod. This notice will be removed when `master` is usable again. Your patience is appreciated.

79
<a name="autoubuntulocal"></a>
80
#### :no_entry: Clean install Ubuntu 16.10 for a local testnet :no_entry:
81 82 83 84 85

```bash
git clone https://github.com/eosio/eos --recursive

cd eos
86
./build.sh ubuntu
87 88
```

89 90
Now you can proceed to the next step - [Creating and launching a single-node testnet](#singlenode)

91 92
<a name="autoubuntupublic"></a>
#### Clean install Ubuntu 16.10 for the public testnet
93

94 95 96 97 98 99 100 101 102 103 104
```bash
git clone https://github.com/eosio/eos --recursive

cd eos
git checkout dawn-2.x
./build.sh ubuntu
```

Now you can proceed to the next step - [Running a node on the public testnet](#publictestnet)

<a name="automaclocal"></a>
105
#### :no_entry: MacOS Sierra for a local testnet :no_entry:
106 107

Before running the script make sure you have updated XCode and brew:
108 109 110 111 112 113

```bash
xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```

114
Then clone the EOS.IO repository recursively and run build.sh in the root `eos` folder.
115

116 117 118 119 120 121 122 123 124
```bash
git clone https://github.com/eosio/eos --recursive

cd eos
./build.sh darwin
```

Now you can proceed to the next step - [Creating and launching a single-node testnet](#singlenode)

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
<a name="automacpublic"></a>
#### MacOS Sierra for the public testnet

Before running the script make sure you have updated XCode and brew:

```bash
xcode-select --install
ruby -e "$(curl -fsSl https://raw.githubusercontent.com/Homebrew/install/master/install)"
```

Then clone the EOS repository recursively, checkout the branch that is compatible with the public testnet, and run build.sh in the root `eos` folder.

```bash
git clone https://github.com/eosio/eos --recursive

cd eos
git checkout dawn-2.x
./build.sh darwin
```

Now you can proceed to the next step - [Running a node on the public testnet](#publictestnet)

S
Serg Metelin 已提交
147
<a name="runanode"></a>
148
## Building EOS and running a node
S
Serg Metelin 已提交
149

S
Serg Metelin 已提交
150
<a name="getcode"></a>
151
### Getting the code
S
Serg Metelin 已提交
152

153
To download all of the code, download EOS source code and a recursion or two of submodules. The easiest way to get all of this is to do a recursive clone:
N
Nathan Hourt 已提交
154

155 156 157
```bash
git clone https://github.com/eosio/eos --recursive
```
N
Nathan Hourt 已提交
158 159 160

If a repo is cloned without the `--recursive` flag, the submodules can be retrieved after the fact by running this command from within the repo:

161 162 163
```bash
git submodule update --init --recursive
```
N
Nathan Hourt 已提交
164

S
Serg Metelin 已提交
165
<a name="build"></a>
166
### Building from source code
167

168 169
The *WASM_LLVM_CONFIG* environment variable is used to find our recently built WASM compiler.
This is needed to compile the example contracts inside `eos/contracts` folder and their respective tests.
170

171
```bash
S
Serg Metelin 已提交
172
cd ~
173
git clone https://github.com/eosio/eos --recursive
S
Serg Metelin 已提交
174
mkdir -p ~/eos/build && cd ~/eos/build
J
jaehong park 已提交
175
cmake -DBINARYEN_BIN=~/binaryen/bin -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib ..
176 177 178 179
make -j4
```

Out-of-source builds are also supported. To override clang's default choice in compiler, add these flags to the CMake command:
N
Nathan Hourt 已提交
180 181 182 183 184

`-DCMAKE_CXX_COMPILER=/path/to/c++ -DCMAKE_C_COMPILER=/path/to/cc`

For a debug build, add `-DCMAKE_BUILD_TYPE=Debug`. Other common build types include `Release` and `RelWithDebInfo`.

185
To run the test suite after building, run the `chain_test` executable in the `tests` folder.
N
Nathan Hourt 已提交
186

S
Serg Metelin 已提交
187 188
EOS comes with a number of programs you can find in `~/eos/build/programs`. They are listed below:

189 190
* eosiod - server-side blockchain node component
* eosioc - command line interface to interact with the blockchain
191
* eosio-walletd - EOS wallet
S
Serg Metelin 已提交
192
* launcher - application for nodes network composing and deployment; [more on launcher](https://github.com/EOSIO/eos/blob/master/testnet.md)
S
Serg Metelin 已提交
193

S
Serg Metelin 已提交
194
<a name="singlenode"></a>
195
### Creating and launching a single-node testnet
S
Serg Metelin 已提交
196

197
After successfully building the project, the `eosiod` binary should be present in the `build/programs/eosiod` directory. Run `eosiod` -- it will probably exit with an error, but if not, close it immediately with <kbd>Ctrl-C</kbd>. If it exited with an error, note that `eosiod` created a directory named `data-dir` containing the default configuration (`config.ini`) and some other internals. This default data storage path can be overridden by passing `--data-dir /path/to/data` to `eosiod`.  These instructions will continue to use the default directory.
N
Nathan Hourt 已提交
198

199
Edit the `config.ini` file, adding/updating the following settings to the defaults already in place:
N
Nathan Hourt 已提交
200 201

```
N
Nathan Hourt 已提交
202 203
# Load the testnet genesis state, which creates some initial block producers with the default key
genesis-json = /path/to/eos/source/genesis.json
S
Sandwich 已提交
204
 # Enable production on a stale chain, since a single-node test chain is pretty much always stale
N
Nathan Hourt 已提交
205 206
enable-stale-production = true
# Enable block production with the testnet producers
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
producer-name = inita
producer-name = initb
producer-name = initc
producer-name = initd
producer-name = inite
producer-name = initf
producer-name = initg
producer-name = inith
producer-name = initi
producer-name = initj
producer-name = initk
producer-name = initl
producer-name = initm
producer-name = initn
producer-name = inito
producer-name = initp
producer-name = initq
producer-name = initr
producer-name = inits
producer-name = initt
producer-name = initu
S
Serg Metelin 已提交
228
# Load the block producer plugin, so you can produce blocks
P
Pravin 已提交
229
plugin = eosio::producer_plugin
S
Serg Metelin 已提交
230
# Wallet plugin
P
Pravin 已提交
231
plugin = eosio::wallet_api_plugin
S
Serg Metelin 已提交
232
# As well as API and HTTP plugins
P
Pravin 已提交
233 234
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin
N
Nathan Hourt 已提交
235 236
```

237
Now it should be possible to run `eosiod` and see it begin producing blocks.
peterwillcn's avatar
peterwillcn 已提交
238

239
When running `eosiod` you should get log messages similar to below. It means the blocks are successfully produced.
S
Serg Metelin 已提交
240 241 242 243 244 245

```
1575001ms thread-0   chain_controller.cpp:235      _push_block          ] initm #1 @2017-09-04T04:26:15  | 0 trx, 0 pending, exectime_ms=0
1575001ms thread-0   producer_plugin.cpp:207       block_production_loo ] initm generated block #1 @ 2017-09-04T04:26:15 with 0 trxs  0 pending
1578001ms thread-0   chain_controller.cpp:235      _push_block          ] initc #2 @2017-09-04T04:26:18  | 0 trx, 0 pending, exectime_ms=0
1578001ms thread-0   producer_plugin.cpp:207       block_production_loo ] initc generated block #2 @ 2017-09-04T04:26:18 with 0 trxs  0 pending
246
...
S
Serg Metelin 已提交
247 248
```

S
Sandwich 已提交
249
<a name="smartcontracts"></a>
S
Sandwich 已提交
250
## Example "Currency" Contract Walkthrough
S
Serg Metelin 已提交
251

252
EOS comes with example contracts that can be uploaded and run for testing purposes. Next we demonstrate how to upload and interact with the sample contract "currency".
S
Serg Metelin 已提交
253

S
Serg Metelin 已提交
254
<a name="smartcontractexample"></a>
S
Sandwich 已提交
255
### Example smart contracts
256

S
Sandwich 已提交
257
First, run the node
S
Serg Metelin 已提交
258

259
```bash
260 261
cd ~/eos/build/programs/eosiod/
./eosiod
S
Serg Metelin 已提交
262
```
263

S
Serg Metelin 已提交
264
<a name="walletimport"></a>
265
### Setting up a wallet and importing account key
S
Serg Metelin 已提交
266

267
As you've previously added `plugin = eosio::wallet_api_plugin` into `config.ini`, EOS wallet will be running as a part of `eosiod` process. Every contract requires an associated account, so first, create a wallet.
S
Serg Metelin 已提交
268

269
```bash
270 271
cd ~/eos/build/programs/eosioc/
./eosioc wallet create # Outputs a password that you need to save to be able to lock/unlock the wallet
S
Serg Metelin 已提交
272 273
```

274
For the purpose of this walkthrough, import the private key of the `inita` account, a test account included within genesis.json, so that you're able to issue API commands under authority of an existing account. The private key referenced below is found within your `config.ini` and is provided to you for testing purposes.
S
Sandwich 已提交
275

S
Sandwich 已提交
276
```bash
277
./eosioc wallet import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
S
Sandwich 已提交
278
```
S
Serg Metelin 已提交
279

S
Serg Metelin 已提交
280
<a name="createaccounts"></a>
S
Sandwich 已提交
281
### Creating accounts for sample "currency" contract
S
Serg Metelin 已提交
282

S
Sandwich 已提交
283
First, generate some public/private key pairs that will be later assigned as `owner_key` and `active_key`.
284

285
```bash
286 287 288
cd ~/eos/build/programs/eosioc/
./eosioc create key # owner_key
./eosioc create key # active_key
289 290
```

S
Sandwich 已提交
291
This will output two pairs of public and private keys
292 293 294

```
Private key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
295
Public key: EOSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
296 297
```

S
Sandwich 已提交
298
**Important:**
299 300
Save the values for future reference.

S
Sandwich 已提交
301
Run the `create` command where `inita` is the account authorizing the creation of the `currency` account and `PUBLIC_KEY_1` and `PUBLIC_KEY_2` are the values generated by the `create key` command
302

303
```bash
304
./eosioc create account inita currency PUBLIC_KEY_1 PUBLIC_KEY_2
305 306
```

307
You should then get a JSON response back with a transaction ID confirming it was executed successfully.
308

S
Sandwich 已提交
309
Go ahead and check that the account was successfully created
310

311
```bash
312
./eosioc get account currency
313 314
```

315
If all went well, you will receive output similar to the following:
316 317 318

```json
{
319 320
  "account_name": "currency",
  "eos_balance": "0.0000 EOS",
321
  "staked_balance": "0.0001 EOS",
322 323 324
  "unstaking_balance": "0.0000 EOS",
  "last_unstaking_time": "2035-10-29T06:32:22",
...
325 326
```

S
Sandwich 已提交
327
Now import the active private key generated previously in the wallet:
328 329

```bash
330
./eosioc wallet import XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
331 332
```

S
Serg Metelin 已提交
333
<a name="uploadsmartcontract"></a>
334
### Upload sample "currency" contract to blockchain
335

S
Sandwich 已提交
336
Before uploading a contract, verify that there is no current contract:
D
Daniel Larimer 已提交
337

338
```bash
339
./eosioc get code currency
D
Daniel Larimer 已提交
340 341 342
code hash: 0000000000000000000000000000000000000000000000000000000000000000
```

S
Sandwich 已提交
343
With an account for a contract created, upload a sample contract:
344

345
```bash
346
./eosioc set contract currency ../../contracts/currency/currency.wast ../../contracts/currency/currency.abi
S
Serg Metelin 已提交
347 348
```

349
As a response you should get a JSON with a `transaction_id` field. Your contract was successfully uploaded!
S
Serg Metelin 已提交
350

351
You can also verify that the code has been set with the following command:
D
Daniel Larimer 已提交
352

353
```bash
354
./eosioc get code currency
S
Sandwich 已提交
355 356
```

357
It will return something like:
S
Sandwich 已提交
358
```bash
D
Daniel Larimer 已提交
359 360 361
code hash: 9b9db1a7940503a88535517049e64467a6e8f4e9e03af15e9968ec89dd794975
```

362 363 364 365 366 367
Before using the currency contract, you must issue the currency.

```bash
./eosioc push action currency issue '{"to":"currency","quantity":"1000.0000 CUR"}' --permission currency@active
```

S
Sandwich 已提交
368
Next verify the currency contract has the proper initial balance:
D
Daniel Larimer 已提交
369

370
```bash
371
./eosioc get table currency currency account
D
Daniel Larimer 已提交
372 373
{
  "rows": [{
374 375
     "currency": 1381319428,
     "balance": 10000000
D
Daniel Larimer 已提交
376 377 378 379 380 381
     }
  ],
  "more": false
}
```

S
Serg Metelin 已提交
382
<a name="pushamessage"></a>
383
### Transfering funds with the sample "currency" contract
384

385
Anyone can send any message to any contract at any time, but the contracts may reject messages which are not given necessary permission. Messages are not sent "from" anyone, they are sent "with permission of" one or more accounts and permission levels. The following commands show a "transfer" message being sent to the "currency" contract.
S
Serg Metelin 已提交
386

387
The content of the message is `'{"from":"currency","to":"inita","quantity":"20.0000 CUR","memo":"any string"}'`. In this case we are asking the currency contract to transfer funds from itself to someone else. This requires the permission of the currency contract.
S
Serg Metelin 已提交
388

389
```bash
390
./eosioc push action currency transfer '{"from":"currency","to":"inita","quantity":"20.0000 CUR","memo":"my first transfer"}' --permission currency@active
D
Daniel Larimer 已提交
391 392
```

393
Below is a generalization that shows the `currency` account is only referenced once, to specify which contract to deliver the `transfer` message to.
394 395

```bash
396
./eosioc push action currency transfer '{"from":"${usera}","to":"${userb}","quantity":"20.0000 CUR","memo":""}' --permission ${usera}@active
397 398
```

399
As confirmation of a successfully submitted transaction, you will receive JSON output that includes a `transaction_id` field.
D
Daniel Larimer 已提交
400

S
Serg Metelin 已提交
401
<a name="readingcontract"></a>
S
Sandwich 已提交
402
### Reading sample "currency" contract balance
403

404
So now check the state of both of the accounts involved in the previous transaction.
D
Daniel Larimer 已提交
405

406
```bash
407
./eosioc get table inita currency account
D
Daniel Larimer 已提交
408 409
{
  "rows": [{
410 411
      "currency": 1381319428,
      "balance": 200000
D
Daniel Larimer 已提交
412 413 414 415
       }
    ],
  "more": false
}
416
./eosioc get table currency currency account
D
Daniel Larimer 已提交
417 418
{
  "rows": [{
419 420
      "currency": 1381319428,
      "balance": 9800000
D
Daniel Larimer 已提交
421 422 423 424
    }
  ],
  "more": false
}
S
Serg Metelin 已提交
425 426
```

427
As expected, the receiving account **inita** now has a balance of **20** tokens, and the sending account now has **20** less tokens than its initial supply.
S
Sandwich 已提交
428

S
Serg Metelin 已提交
429
<a name="localtestnet"></a>
430
## Running multi-node local testnet
S
Serg Metelin 已提交
431

432
To run a local testnet you can use a `launcher` application provided in the `~/eos/build/programs/launcher` folder.
S
Serg Metelin 已提交
433

434
For testing purposes you will run two local production nodes talking to each other.
S
Serg Metelin 已提交
435

436
```bash
S
Serg Metelin 已提交
437 438
cd ~/eos/build
cp ../genesis.json ./
B
bitcoiners 已提交
439
./programs/launcher/launcher -p2 --skip-signature
S
Serg Metelin 已提交
440 441
```

442
This command will generate two data folders for each instance of the node: `tn_data_00` and `tn_data_01`.
S
Serg Metelin 已提交
443

444
You should see the following response:
S
Serg Metelin 已提交
445

446
```bash
447 448
spawning child, programs/eosiod/eosiod --skip-transaction-signatures --data-dir tn_data_0
spawning child, programs/eosiod/eosiod --skip-transaction-signatures --data-dir tn_data_1
S
Serg Metelin 已提交
449 450
```

451
To confirm the nodes are running, run the following `eosioc` commands:
452
```bash
453 454 455
~/eos/build/programs/eosioc
./eosioc -p 8888 get info
./eosioc -p 8889 get info
S
Serg Metelin 已提交
456 457
```

458
For each command, you should get a JSON response with blockchain information.
S
Serg Metelin 已提交
459

S
Serg Metelin 已提交
460 461
You can read more on launcher and its settings [here](https://github.com/EOSIO/eos/blob/master/testnet.md)

462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
<a name="publictestnet"></a>
## Running a local node connected to the public testnet

To run a local node connected to the public testnet operated by block.one, a script is provided.

```bash
cd ~/eos/build/scripts
./start_npnode.sh
```

This command will use the data folder provided for the instance called `testnet_np`.

You should see the following response:

```bash
477 478
Launched eosd.
See testnet_np/stderr.txt for eosd output.
479 480 481
Synching requires at least 8 minutes, depending on network conditions.
```

482
To confirm eosd operation and synchronization:
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503

```bash
tail -F testnet_np/stderr.txt
```

To exit tail, use Ctrl-C.  During synchronization, you will see log messages similar to:

```bash
3439731ms            chain_plugin.cpp:272          accept_block         ] Syncing Blockchain --- Got block: #200000 time: 2017-12-09T07:56:32 producer: initu
3454532ms            chain_plugin.cpp:272          accept_block         ] Syncing Blockchain --- Got block: #210000 time: 2017-12-09T13:29:52 producer: initc
```

Synchronization is complete when you see log messages similar to:

```bash
42467ms            net_plugin.cpp:1245           start_sync           ] Catching up with chain, our last req is 351734, theirs is 351962 peer ip-10-160-11-116:9876
42792ms            chain_controller.cpp:208      _push_block          ] initt #351947 @2017-12-12T22:59:44  | 0 trx, 0 pending, exectime_ms=0
42793ms            chain_controller.cpp:208      _push_block          ] inito #351948 @2017-12-12T22:59:46  | 0 trx, 0 pending, exectime_ms=0
42793ms            chain_controller.cpp:208      _push_block          ] initd #351949 @2017-12-12T22:59:48  | 0 trx, 0 pending, exectime_ms=0
```

504 505
This eosd instance listens on 127.0.0.1:8888 for http requests, on all interfaces at port 9877
for p2p requests, and includes the wallet plugins.
506

S
Serg Metelin 已提交
507
<a name="doxygen"></a>
508
## Doxygen documentation
S
Serg Metelin 已提交
509

510 511 512
You can find more detailed API documentation in the Doxygen reference.
For the `master` branch: https://eosio.github.io/eos/
For the public testnet branch: http://htmlpreview.github.io/?https://github.com/EOSIO/eos/blob/dawn-2.x/docs/index.html
S
Serg Metelin 已提交
513

S
Serg Metelin 已提交
514
<a name="docker"></a>
515
## Running EOS in Docker
peterwillcn's avatar
peterwillcn 已提交
516

517 518 519
You can find up to date information about EOS Docker in the [Docker Readme](https://github.com/EOSIO/eos/blob/master/Docker/README.md)

<a name="manualdep"></a>
520
## Manual installation of the dependencies
521

522
If you prefer to manually build dependencies, follow the steps below.
523 524 525 526 527 528 529 530 531 532 533 534 535 536

This project is written primarily in C++14 and uses CMake as its build system. An up-to-date Clang and the latest version of CMake is recommended.

Dependencies:

* Clang 4.0.0
* CMake 3.5.1
* Boost 1.64
* OpenSSL
* LLVM 4.0
* [secp256k1-zkp (Cryptonomex branch)](https://github.com/cryptonomex/secp256k1-zkp.git)
* [binaryen](https://github.com/WebAssembly/binaryen.git)

<a name="ubuntu"></a>
537
### Clean install Ubuntu 16.10
538 539 540 541 542 543

Install the development toolkit:

```bash
sudo apt-get update
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
M
Matias Romeo 已提交
544
sudo apt-get install clang-4.0 lldb-4.0 libclang-4.0-dev cmake make \
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
                     libbz2-dev libssl-dev libgmp3-dev \
                     autotools-dev build-essential \
                     libbz2-dev libicu-dev python-dev \
                     autoconf libtool git
```

Install Boost 1.64:

```bash
cd ~
wget -c 'https://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.bz2/download' -O boost_1.64.0.tar.bz2
tar xjf boost_1.64.0.tar.bz2
cd boost_1_64_0/
echo "export BOOST_ROOT=$HOME/opt/boost_1_64_0" >> ~/.bash_profile
source ~/.bash_profile
./bootstrap.sh "--prefix=$BOOST_ROOT"
./b2 install
source ~/.bash_profile
```

Install [secp256k1-zkp (Cryptonomex branch)](https://github.com/cryptonomex/secp256k1-zkp.git):
566

567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609
```bash
cd ~
git clone https://github.com/cryptonomex/secp256k1-zkp.git
cd secp256k1-zkp
./autogen.sh
./configure
make
sudo make install
```

To use the WASM compiler, EOS has an external dependency on [binaryen](https://github.com/WebAssembly/binaryen.git):

```bash
cd ~
git clone https://github.com/WebAssembly/binaryen.git
cd ~/binaryen
git checkout tags/1.37.14
cmake . && make

```

Add `BINARYEN_ROOT` to your .bash_profile:

```bash
echo "export BINARYEN_ROOT=~/binaryen" >> ~/.bash_profile
source ~/.bash_profile
```

By default LLVM and clang do not include the WASM build target, so you will have to build it yourself:

```bash
mkdir  ~/wasm-compiler
cd ~/wasm-compiler
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git
cd llvm/tools
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git
cd ..
mkdir build
cd build
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=.. -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../
make -j4 install
```

610
Your environment is set up. Now you can <a href="#runanode">build EOS and run a node</a>.
611 612

<a name="macos"></a>
613
### MacOS Sierra 10.12.6
614 615 616

macOS additional Dependencies:

617
* Brew
618 619 620 621 622 623 624 625
* Newest XCode

Upgrade your XCode to the newest version:

```bash
xcode-select --install
```

626
Install homebrew:
627 628 629 630 631 632 633 634 635

```bash
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```

Install the dependencies:

```bash
brew update
636 637
brew install git automake libtool boost openssl llvm@4 gmp ninja gettext
brew link gettext --force
638 639 640
```

Install [secp256k1-zkp (Cryptonomex branch)](https://github.com/cryptonomex/secp256k1-zkp.git):
641

642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
```bash
cd ~
git clone https://github.com/cryptonomex/secp256k1-zkp.git
cd secp256k1-zkp
./autogen.sh
./configure
make
sudo make install
```

Install [binaryen v1.37.14](https://github.com/WebAssembly/binaryen.git):

```bash
cd ~
git clone https://github.com/WebAssembly/binaryen.git
cd ~/binaryen
git checkout tags/1.37.14
cmake . && make
```

Add `BINARYEN_ROOT` to your .bash_profile:

```bash
echo "export BINARYEN_ROOT=~/binaryen" >> ~/.bash_profile
source ~/.bash_profile
```

669 670

Build LLVM and clang for WASM:
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691

```bash
mkdir  ~/wasm-compiler
cd ~/wasm-compiler
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git
cd llvm/tools
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git
cd ..
mkdir build
cd build
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=.. -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../
make -j4 install
```

Add `WASM_LLVM_CONFIG` and `LLVM_DIR` to your `.bash_profile`:

```bash
echo "export WASM_LLVM_CONFIG=~/wasm-compiler/llvm/bin/llvm-config" >> ~/.bash_profile
echo "export LLVM_DIR=/usr/local/Cellar/llvm/4.0.1/lib/cmake/llvm" >> ~/.bash_profile
source ~/.bash_profile
```