README.md 19.0 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 10

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

# Resources
1. [EOS.IO Website](https://eos.io)
15 16
2. [Documentation](https://eosio.github.io/eos/)
3. [Blog](https://steemit.com/@eosio)
S
Sandwich 已提交
17
4. [Community Telegram Group](https://t.me/EOSProject)
18 19 20
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 已提交
21

22 23 24
# Table of contents

1. [Getting Started](#gettingstarted)
S
Serg Metelin 已提交
25
2. [Setting up a build/development environment](#setup)
26
	1. [Automated build script](#autobuild)
S
Serg Metelin 已提交
27
	    1. [Clean install Ubuntu 16.10](#autoubuntu)
28
	    2. [MacOS Sierra 10.12.6](#automac)
S
Serg Metelin 已提交
29
3. [Building EOS and running a node](#runanode)
30 31 32
	1. [Getting the code](#getcode)
	2. [Building from source code](#build)
	3. [Creating and launching a single-node testnet](#singlenode)
S
Sandwich 已提交
33 34
4. [Example Currency Contract Walkthrough](#smartcontracts)
	1. [Example Contracts](#smartcontractexample)
35 36 37
	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)
38
	5. [Pushing a message to a sample contract](#pushamessage)
39 40
	6. [Reading Currency Contract Balance](#readingcontract)
5. [Running local testnet](#localtestnet)
S
Serg Metelin 已提交
41 42
6. [Doxygen documentation](#doxygen)
7. [Running EOS in Docker](#docker)
S
Sandwich 已提交
43 44 45
8. [Manual installation of the dependencies](#manualdep)
   1. [Clean install Ubuntu 16.10](#ubuntu)
   2. [MacOS Sierra 10.12.6](#macos)
46

S
Serg Metelin 已提交
47 48
<a name="gettingstarted"></a>
## Getting Started
49
The following instructions overview 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 已提交
50

S
Serg Metelin 已提交
51 52
<a name="setup"></a>
## Setting up a build/development environment
53

54 55 56
<a name="autobuild"></a>
### Automated build script

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

59
It is called build.sh with following inputs.
60
- architecture [ubuntu|darwin]
61
- optional mode [full|build]
62 63 64 65

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 build script always installs dependencies and then builds eos.

```bash
66
./build.sh <architecture> <optional mode>
67
```
68 69 70
Clone EOS repository recursively as below and run build.sh located in root `eos` folder.

<a name="autoubuntu"></a>
71
#### Clean install Ubuntu 16.10
72 73 74 75 76

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

cd eos
77
./build.sh ubuntu
78 79
```

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

82
<a name="automac"></a>
83
#### MacOS Sierra
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

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)"
```

```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)

S
Serg Metelin 已提交
101
<a name="runanode"></a>
102
## Building EOS and running a node
S
Serg Metelin 已提交
103

S
Serg Metelin 已提交
104
<a name="getcode"></a>
105
### Getting the code
S
Serg Metelin 已提交
106

107
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 已提交
108

109 110 111
```bash
git clone https://github.com/eosio/eos --recursive
```
N
Nathan Hourt 已提交
112 113 114

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:

115 116 117
```bash
git submodule update --init --recursive
```
N
Nathan Hourt 已提交
118

S
Serg Metelin 已提交
119
<a name="build"></a>
120
### Building from source code
121

122 123
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.
124

125
```bash
S
Serg Metelin 已提交
126
cd ~
127
git clone https://github.com/eosio/eos --recursive
S
Serg Metelin 已提交
128
mkdir -p ~/eos/build && cd ~/eos/build
J
jaehong park 已提交
129
cmake -DBINARYEN_BIN=~/binaryen/bin -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib ..
130 131 132 133
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 已提交
134 135 136 137 138

`-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`.

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

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

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

S
Serg Metelin 已提交
148
<a name="singlenode"></a>
149
### Creating and launching a single-node testnet
S
Serg Metelin 已提交
150

B
Brian 已提交
151
After successfully building the project, the `eosd` binary should be present in the `build/programs/eosd` directory. Go ahead and run `eosd` -- it will probably exit with an error, but if not, close it immediately with <kbd>Ctrl-C</kbd>. Note that `eosd` 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 `eosd`.
N
Nathan Hourt 已提交
152

N
Nathan Hourt 已提交
153
Edit the `config.ini` file, adding the following settings to the defaults already in place:
N
Nathan Hourt 已提交
154 155

```
N
Nathan Hourt 已提交
156 157
# 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 已提交
158
 # Enable production on a stale chain, since a single-node test chain is pretty much always stale
N
Nathan Hourt 已提交
159 160
enable-stale-production = true
# Enable block production with the testnet producers
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
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 已提交
182
# Load the block producer plugin, so you can produce blocks
P
Pravin 已提交
183
plugin = eosio::producer_plugin
S
Serg Metelin 已提交
184
# Wallet plugin
P
Pravin 已提交
185
plugin = eosio::wallet_api_plugin
S
Serg Metelin 已提交
186
# As well as API and HTTP plugins
P
Pravin 已提交
187 188
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin
N
Nathan Hourt 已提交
189 190
```

191
Now it should be possible to run `eosd` and see it begin producing blocks.
peterwillcn's avatar
peterwillcn 已提交
192

S
Serg Metelin 已提交
193 194 195 196 197 198 199
When running `eosd` you should get log messages similar to below. It means the blocks are successfully produced.

```
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
200
...
S
Serg Metelin 已提交
201 202
```

S
Sandwich 已提交
203
<a name="smartcontracts"></a>
S
Sandwich 已提交
204
## Example "Currency" Contract Walkthrough
S
Serg Metelin 已提交
205

206
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 已提交
207

S
Serg Metelin 已提交
208
<a name="smartcontractexample"></a>
S
Sandwich 已提交
209
### Example smart contracts
210

S
Sandwich 已提交
211
First, run the node
S
Serg Metelin 已提交
212

213
```bash
S
Serg Metelin 已提交
214
cd ~/eos/build/programs/eosd/
S
Serg Metelin 已提交
215
./eosd
S
Serg Metelin 已提交
216
```
217

S
Serg Metelin 已提交
218
<a name="walletimport"></a>
219
### Setting up a wallet and importing account key
S
Serg Metelin 已提交
220

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

223
```bash
S
Serg Metelin 已提交
224
cd ~/eos/build/programs/eosc/
225
./eosc wallet create # Outputs a password that you need to save to be able to lock/unlock the wallet
S
Serg Metelin 已提交
226 227
```

228
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 已提交
229

S
Sandwich 已提交
230
```bash
S
Sandwich 已提交
231 232
./eosc wallet import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
```
S
Serg Metelin 已提交
233

S
Serg Metelin 已提交
234
<a name="createaccounts"></a>
S
Sandwich 已提交
235
### Creating accounts for sample "currency" contract
S
Serg Metelin 已提交
236

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

239
```bash
240
cd ~/eos/build/programs/eosc/
241 242
./eosc create key # owner_key
./eosc create key # active_key
243 244
```

S
Sandwich 已提交
245
This will output two pairs of public and private keys
246 247 248 249 250 251

```
Private key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Public key:  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

S
Sandwich 已提交
252
**Important:**
253 254
Save the values for future reference.

S
Sandwich 已提交
255
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
256

257
```bash
258
./eosc create account inita currency PUBLIC_KEY_1 PUBLIC_KEY_2
259 260
```

S
Sandwich 已提交
261
You should then get a json response back with a transaction ID confirming it was executed successfully.
262

S
Sandwich 已提交
263
Go ahead and check that the account was successfully created
264

265
```bash
S
Serg Metelin 已提交
266
./eosc get account currency
267 268
```

S
Sandwich 已提交
269
If all went well, you will receive output similar to the following
270 271 272

```json
{
S
Serg Metelin 已提交
273
  "name": "currency",
274 275 276 277 278 279 280
  "eos_balance": 0,
  "staked_balance": 1,
  "unstaking_balance": 0,
  "last_unstaking_time": "2106-02-07T06:28:15"
}
```

S
Sandwich 已提交
281
Now import the active private key generated previously in the wallet:
282 283 284 285 286

```bash
./eosc wallet import XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

S
Serg Metelin 已提交
287
<a name="uploadsmartcontract"></a>
288
### Upload sample "currency" contract to blockchain
289

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

292
```bash
293
./eosc get code currency
D
Daniel Larimer 已提交
294 295 296
code hash: 0000000000000000000000000000000000000000000000000000000000000000
```

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

299
```bash
300
./eosc set contract currency ../../contracts/currency/currency.wast ../../contracts/currency/currency.abi
S
Serg Metelin 已提交
301 302 303 304
```

As a response you should get a json with a `transaction_id` field. Your contract was successfully uploaded!

S
Sandwich 已提交
305
You can also verify that the code has been set with the following command
D
Daniel Larimer 已提交
306

307
```bash
D
Daniel Larimer 已提交
308
./eosc get code currency
S
Sandwich 已提交
309 310 311 312
```

It will return something like
```bash
D
Daniel Larimer 已提交
313 314 315
code hash: 9b9db1a7940503a88535517049e64467a6e8f4e9e03af15e9968ec89dd794975
```

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

318
```bash
D
Daniel Larimer 已提交
319 320 321 322 323 324 325 326 327 328 329
./eosc get table currency currency account
{
  "rows": [{
     "account": "account",
     "balance": 1000000000
     }
  ],
  "more": false
}
```

S
Serg Metelin 已提交
330
<a name="pushamessage"></a>
331
### Transfering funds with the sample "currency" contract
332 333 334

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 shows a "transfer" message being
335
sent to the "currency" contract.
336 337 338

The content of the message is `'{"from":"currency","to":"inita","amount":50}'`. 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 已提交
339 340


341
```bash
342
./eosc push message currency transfer '{"from":"currency","to":"inita","amount":50}' --scope currency,inita --permission currency@active
D
Daniel Larimer 已提交
343 344
```

345
Below is a generalization that shows the `currency` account is only referenced once, to specify which contract to deliver the `transfer` message to.
346 347 348 349 350 351 352 353

```bash
./eosc push message currency transfer '{"from":"${usera}","to":"${userb}","amount":50}' --scope ${usera},${userb} --permission ${usera}@active
```

We specify the `--scope ...` argument to give the currency contract read/write permission to those users so it can modify their balances.  In a future release scope
will be determined automatically.

S
Sandwich 已提交
354
As a confirmation of a successfully submitted transaction you will receive json output that includes a `transaction_id` field.
D
Daniel Larimer 已提交
355

S
Serg Metelin 已提交
356
<a name="readingcontract"></a>
S
Sandwich 已提交
357
### Reading sample "currency" contract balance
358

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

361
```bash
D
Daniel Larimer 已提交
362 363 364 365
./eosc get table inita currency account
{
  "rows": [{
      "account": "account",
366
      "balance": 50
D
Daniel Larimer 已提交
367 368 369 370 371 372 373 374 375 376 377 378 379
       }
    ],
  "more": false
}
./eosc get table currency currency account
{
  "rows": [{
      "account": "account",
      "balance": 999999950
    }
  ],
  "more": false
}
S
Serg Metelin 已提交
380 381
```

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

S
Serg Metelin 已提交
384
<a name="localtestnet"></a>
385
## Running multi-node local testnet
S
Serg Metelin 已提交
386

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

S
Serg Metelin 已提交
389
For testing purposes you will run 2 local production nodes talking to each other.
S
Serg Metelin 已提交
390

391
```bash
S
Serg Metelin 已提交
392 393
cd ~/eos/build
cp ../genesis.json ./
B
bitcoiners 已提交
394
./programs/launcher/launcher -p2 --skip-signature
S
Serg Metelin 已提交
395 396
```

397
This command will generate 2 data folders for each instance of the node: `tn_data_0` and `tn_data_1`.
S
Serg Metelin 已提交
398 399 400

You should see a following response:

401
```bash
S
Serg Metelin 已提交
402 403 404 405 406
spawning child, programs/eosd/eosd --skip-transaction-signatures --data-dir tn_data_0
spawning child, programs/eosd/eosd --skip-transaction-signatures --data-dir tn_data_1
```

To confirm the nodes are running, run following `eosc` commands:
407
```bash
S
Serg Metelin 已提交
408 409 410 411 412
~/eos/build/programs/eosc
./eosc -p 8888 get info
./eosc -p 8889 get info
```

S
Serg Metelin 已提交
413
For each you should get a json with a blockchain information.
S
Serg Metelin 已提交
414

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

S
Serg Metelin 已提交
417
<a name="doxygen"></a>
418
## Doxygen documentation
S
Serg Metelin 已提交
419 420 421

You can find more detailed API documentation in Doxygen reference: https://eosio.github.io/eos/

S
Serg Metelin 已提交
422
<a name="docker"></a>
423
## Running EOS in Docker
peterwillcn's avatar
peterwillcn 已提交
424

425 426 427 428 429
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>
430
## Manual installation of the dependencies
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446

If you prefer to manually build dependencies - follow the steps below.

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>
447
### Clean install Ubuntu 16.10
448 449 450 451 452 453

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 已提交
454
sudo apt-get install clang-4.0 lldb-4.0 libclang-4.0-dev cmake make \
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475
                     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):
476

477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
```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
```

520
Your environment is set up. Now you can <a href="#runanode">build EOS and run a node</a>.
521 522

<a name="macos"></a>
523
### MacOS Sierra 10.12.6
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549

macOS additional Dependencies:

* Brew
* Newest XCode

Upgrade your XCode to the newest version:

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

Install homebrew:

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

Install the dependencies:

```bash
brew update
brew install git automake libtool boost openssl llvm@4 gmp
```

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

551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 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
```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
```


Build LLVM and clang for WASM:

```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
```