diff --git a/README.md b/README.md index 5f050d967d57a6533901ae7188a8f3fe7050378a..351d83541bba3ee626c48772de6419b3404ee15b 100644 --- a/README.md +++ b/README.md @@ -1,919 +1,32 @@ -## EOS.IO - The Most Powerful Infrastructure for Decentralized Applications +# EOSIO - The Most Powerful Infrastructure for Decentralized Applications [![Build Status](https://jenkins.eos.io/buildStatus/icon?job=eosio/master)](https://jenkins.eos.io/job/eosio/job/master/) -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 can be built. +Welcome to the EOSIO source code repository! EOSIO software enables developers to create and deploy high-performance, horizontally scalable, blockchain infrastructure upon which decentralized applications can be built. -This code is currently alpha-quality and under rapid development. That said, there is plenty early experimenters can do. This includes running a private multi-node test network and developing applications (smart contracts). +This code is currently beta-quality and under rapid development. That said, there is plenty early experimenters can do. This includes running a private multi-node test network and developing applications (smart contracts). -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 a local testnet using the `master` branch. This document will be updated later with instructions for running on the `dawn-3.x` public testnet. +There is no public testnet running currently. -### Supported Operating Systems -EOS.IO currently supports the following operating systems: -1. Amazon 2017.09 and higher. -2. Centos 7. -3. Fedora 25 and higher (Fedora 27 recommended). -4. Mint 18. -5. Ubuntu 16.04 (Ubuntu 16.10 recommended). -6. MacOS Darwin 10.12 and higher (MacOS 10.13.x recommended). +## Supported Operating Systems +EOSIO currently supports the following operating systems: +1. Amazon 2017.09 and higher +2. Centos 7 +3. Fedora 25 and higher (Fedora 27 recommended) +4. Mint 18 +5. Ubuntu 16.04 (Ubuntu 16.10 recommended) +6. MacOS Darwin 10.12 and higher (MacOS 10.13.x recommended) # Resources -1. [EOS.IO Website](https://eos.io) -2. [Documentation](https://eosio.github.io/eos/) -3. [Blog](https://steemit.com/@eosio) +1. [eos.io Website](https://eos.io) +3. [EOSIO Blog](https://medium.com/eosio) +8. [EOSIO Documentation Wiki](https://github.com/EOSIO/eos/wiki) +2. [EOSIO API Documentation](https://eosio.github.io/eos/) 4. [Community Telegram Group](https://t.me/EOSProject) 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) -8. [Wiki](https://github.com/EOSIO/eos/wiki) - -# Table of contents - -1. [Getting Started](#gettingstarted) -2. [Setting up a build/development environment](#setup) - 1. [Getting the code](#getcode) - 2. [Building the executables](#build) - 1. [Automated build script](#autobuild) - 2. [Manual build](#manualbuild) - 3. [Build validation](#basicvalidation) - 4. [Install the executables](#installexecutables) -3. [Running a node](#runanode) - 1. [Creating and launching a single-node testnet](#singlenode) - 2. [Running a multi-node local testnet](#localtestnet) - 3. [Running on the public testnet](#publictestnet) - 4. [Next steps](#nextsteps) -4. [Example Currency Contract Walkthrough](#smartcontracts) - 1. [Example Contracts](#smartcontractexample) - 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) - 5. [Pushing a message to a sample contract](#pushamessage) - 6. [Reading Currency Contract Balance](#readingcontract) -5. [Doxygen documentation](#doxygen) -6. [Running EOS in Docker](#docker) -7. [Manual installation of the dependencies](#manualdep) - 1. [Clean install Amazon 2017.09 and higher](#manualdepamazon) - 2. [Clean install Centos 7 and higher](#manualdepcentos) - 3. [Clean install Fedora 25 and higher](#manualdepfedora) - 4. [Clean install Mint 18](#manualdepubuntu) - 5. [Clean install Ubuntu 16](#manualdepubuntu) - 6. [Clean install MacOS Sierra 10.12 and higher](#manualdepmacos) ## Getting Started -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. - - -## Setting up a build/development environment - - -### Getting the code - -To download all of the code, clone the eos repository and its submodules. - -```bash -git clone https://github.com/eosio/eos --recursive -``` - -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: - -```bash -git submodule update --init --recursive -``` - - -### Building the executables - -EOS comes with a number of programs: - -* nodeos - server-side blockchain node component -* cleos - command line interface to interact with the blockchain -* keosd - EOS wallet -* eosio-launcher - application for nodes network composing and deployment; [more on eosio-launcher](https://github.com/EOSIO/eos/blob/master/testnet.md) - -The build places content in the `eos/build` folder. The executables can be found in subfolders within the `eos/build/programs` folder. - - -#### Automated build script - -There is an automated build script that can install all dependencies and build EOS. We are working on supporting other Linux/Unix distributions in future releases. - -Run the build script. - -```bash -cd eos -./eosio_build.sh -``` - - -#### Manual build - -To manually build, use the following steps to create a `build` folder within your `eos` folder and then perform the build. The steps below assume the `eos` repository was cloned into your home (i.e., `~`) folder. - -```bash -cd ~ -mkdir -p ~/eos/build && cd ~/eos/build -cmake -DBINARYEN_BIN=~/binaryen/bin -DWASM_ROOT=~/wasm-compiler/llvm -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib .. -make -j$( nproc ) -``` - -Out-of-source builds are also supported. To override clang's default choice in compiler, add these flags to the CMake command: - -`-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`. - -To run the test suite after building, run the `chain_test` executable in the `tests` folder. - - -### Build validation - -Optionally, a set of tests can be run against your build to perform some basic validation. - -```bash -cd build -make test -``` - - -### Install the executables - -For ease of contract development, content can be installed in the `/usr/local` folder using the `make install` target. This step is run from the `build` folder. Adequate permission is required to install. - -```bash -cd build -sudo make install -``` - - -## Running a node - - -### Running a single-node testnet - -After successfully building the project, the `nodeos` binary should be present in the `build/programs/nodeos` folder. `nodeos` can be run directly from the `build` folder using `programs/nodeos/nodeos`. - -`nodeos` uses a custom configuration folder. The location of this folder is determined by your system. - -- Mac OS: `~/Library/Application Support/eosio/nodeos/config` -- Linux: `~/.local/share/eosio/nodeos/config` - -The build seeds this folder with a default `genesis.json` file. Alternatively, a configuration folder can be specified using the `--config-dir` command line argument to `nodeos`. If you use this option, you will need to manually copy a genesis.json file to your config folder. - -`nodeos` will need a properly configured `config.ini` file in order to do meaningful work. On startup, `nodeos` looks in the config folder for `config.ini`. If one is not found, a default `config.ini` file is created. If you do not -already have a `config.ini` file ready to use, run `nodeos` and then close it immediately with Ctrl-C. A default configuration (`config.ini`) will have been created in the config folder. Edit the `config.ini` file, adding/updating the following settings to the defaults already in place: - -``` -# Load the testnet genesis state, which creates some initial block producers with the default key -genesis-json = /path/to/eos/source/genesis.json -# Enable production on a stale chain, since a single-node test chain is pretty much always stale -enable-stale-production = true -# Enable block production with the testnet producers -producer-name = eosio -# Load the block producer plugin, so you can produce blocks -plugin = eosio::producer_plugin -# Wallet plugin -plugin = eosio::wallet_api_plugin -# As well as API and HTTP plugins -plugin = eosio::chain_api_plugin -plugin = eosio::http_plugin -``` - -Now it should be possible to run `nodeos` and see it begin producing blocks. - -When running `nodeos` 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 -... -``` - -`nodeos` stores runtime data (e.g., shared memory and log content) in a custom data folder. The location of this folder is determined by your system. - -- Mac OS: `~/Library/Application Support/eosio/nodeos/data` -- Linux: `~/.local/share/eosio/nodeos/data` - -A data folder can be specified using the `--data-dir` command line argument to `nodeos`. - - -### Running a multi-node local testnet - -To run a local testnet you can use the `eosio-launcher` application provided in the `~/eos/build/programs/eosio-launcher` folder. - -For testing purposes you will run two local production nodes talking to each other. - -```bash -cd ~/eos/build -cp ../genesis.json ./ -./programs/eosio-launcher/eosio-launcher -p2 --skip-signature -``` - -This command will generate two data folders for each instance of the node: `tn_data_00` and `tn_data_01`. - -You should see the following response: - -```bash -spawning child, programs/nodeos/nodeos --skip-transaction-signatures --data-dir tn_data_0 -spawning child, programs/nodeos/nodeos --skip-transaction-signatures --data-dir tn_data_1 -``` - -To confirm the nodes are running, run the following `cleos` commands: -```bash -~/eos/build/programs/cleos -./cleos -p 8888 get info -./cleos -p 8889 get info -``` - -For each command, you should get a JSON response with blockchain information. - -You can read more on eosio-launcher and its settings [here](https://github.com/EOSIO/eos/blob/master/testnet.md) - - -### Running a local node connected to the public testnet - -The `master` branch is no longer compatible with the `dawn-2.x` public testnet. To run on the public testnet, please see [dawn-2.x/eos/README.md](https://github.com/EOSIO/eos/blob/dawn-2.x/README.md) - -## Next Steps - - -Further documentation is available in the [wiki](https://github.com/EOSIO/eos/wiki). Wiki pages include detailed reference documentation for all programs and tools and the database schema and API. The wiki also includes a section describing smart contract development. A simple walkthrough of the "currency" contract follows. - - -## Example "Currency" Contract Walkthrough - -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". - - -### Example smart contracts - -First, run the node - -```bash -cd ~/eos/build/programs/nodeos/ -./nodeos -``` - - -### Setting up a wallet - -Every contract requires an associated account, so first you need to create a wallet. -To create a wallet, you need to have the wallet_plugin loaded into the nodeos process which can be accomplished in one of two ways: -* Via a plugin entry in the config.ini file (i.e. `plugin = eosio::wallet_plugin`) -* Via a plugin command-line option when invoking nodeos (i.e. `--plugin eosio::wallet_plugin`) - -Use the wallet create command of the cleos tool, to create a wallet. - -```bash -cd ~/eos/build/programs/cleos/ -./cleos wallet create # Outputs a password that you need to save to be able to lock/unlock the wallet -``` - - -### Creating accounts for sample "currency" contract - -First, generate some public/private key pairs that will be later assigned as the `owner_key` and the `active_key`. - -```bash -cd ~/eos/build/programs/cleos/ -./cleos create key # owner-key -./cleos create key # active-key -``` - -This will output two pairs of public and private keys - -``` -Private key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -Public key: EOSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -``` - -**Important:** -Save the values for future reference. - -Run the `cleos create account` command where `eosio` is the account authorizing the creation of the `currency` account and `public-owner-key` and `public-active-key` are the values generated above by the two invocations of the `cleos create key` command - -```bash -./cleos create account eosio currency public-owner-key public-active-key -``` - -You should then get a JSON response back with a transaction ID confirming it was executed successfully. - -You can verify that the account was successfully created - -```bash -./cleos get account currency -``` - -If all has gone well, you will receive an output similar to the following: - -```json -{ - "account_name": "currency", - "eos_balance": "0.0000 EOS", - "staked_balance": "0.0001 EOS", - "unstaking_balance": "0.0000 EOS", - "last_unstaking_time": "2035-10-29T06:32:22", - ... -} -``` - -Now import the active private key generated previously in the wallet: - -```bash -./cleos wallet import XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -``` - - -### Upload sample "currency" contract to blockchain - -Before uploading a contract, verify that there is no current contract: - -```bash -./cleos get code currency -code hash: 0000000000000000000000000000000000000000000000000000000000000000 -``` - -With an account for a contract created, upload a sample contract: - -```bash -./cleos set contract currency ../../contracts/currency/currency.wast ../../contracts/currency/currency.abi -``` - -As a response you should get a JSON with a `transaction_id` field. Your contract was successfully uploaded! - -You can also verify that the code has been set with the following command: - -```bash -./cleos get code currency -``` - -It will return something like: -```bash -code hash: 9b9db1a7940503a88535517049e64467a6e8f4e9e03af15e9968ec89dd794975 -``` - -Before using the currency contract, you must issue the currency. - -```bash -./cleos push action currency issue '{"to":"currency","quantity":"1000.0000 CUR","memo":""}' --permission currency@active -``` - -Next verify the currency contract has the proper initial balance: - -```bash -./cleos get table currency currency account -{ - "rows": [{ - "currency": 1381319428, - "balance": 10000000 - } - ], - "more": false -} -``` - - -### Transfering funds with the sample "currency" contract - -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. - -The content of the message is `'{"from":"currency","to":"eosio","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. - -```bash -./cleos push action currency transfer '{"from":"currency","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}' --permission currency@active -``` - -Below is a generalization that shows the `currency` account is only referenced once, to specify which contract to deliver the `transfer` message to. - -```bash -./cleos push action currency transfer '{"from":"${usera}","to":"${userb}","quantity":"20.0000 CUR","memo":""}' --permission ${usera}@active -``` - -As confirmation of a successfully submitted transaction, you will receive JSON output that includes a `transaction_id` field. - - -### Reading sample "currency" contract balance - -So now check the state of both of the accounts involved in the previous transaction. - -```bash -./cleos get table eosio currency account -{ - "rows": [{ - "currency": 1381319428, - "balance": 200000 - } - ], - "more": false -} -./cleos get table currency currency account -{ - "rows": [{ - "currency": 1381319428, - "balance": 9800000 - } - ], - "more": false -} -``` - -As expected, the receiving account **eosio** now has a balance of **20** tokens, and the sending account now has **20** less tokens than its initial supply. - - -## Doxygen documentation - -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 - - -## Running EOS in Docker - -You can find up to date information about EOS Docker in the [Docker Readme](https://github.com/EOSIO/eos/blob/master/Docker/README.md) - - -## Manual installation of the dependencies - -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.66 -* OpenSSL -* LLVM 4.0 -* [secp256k1-zkp (Cryptonomex branch)](https://github.com/cryptonomex/secp256k1-zkp.git) - - -### Clean install Amazon 2017.09 and higher - -Install the development toolkit: - -```bash -sudo yum update -sudo yum install git gcc72.x86_64 gcc72-c++.x86_64 autoconf automake libtool make bzip2 \ - bzip2-devel.x86_64 openssl-devel.x86_64 gmp.x86_64 gmp-devel.x86_64 \ - libstdc++72.x86_64 python36-devel.x86_64 libedit-devel.x86_64 \ - ncurses-devel.x86_64 swig.x86_64 gettext-devel.x86_64 - -``` - -Install CMake 3.10.2: - -```bash -cd ~ -curl -L -O https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz -tar xf cmake-3.10.2.tar.gz -rm -f cmake-3.10.2.tar.gz -ln -s cmake-3.10.2/ cmake -cd cmake -./bootstrap -make -sudo make install -``` - -Install Boost 1.66: - -```bash -cd ~ -curl -L https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.bz2 > boost_1.66.0.tar.bz2 -tar xf boost_1.66.0.tar.bz2 -echo "export BOOST_ROOT=$HOME/boost_1_66_0" >> ~/.bash_profile -source ~/.bash_profile -cd boost_1_66_0/ -./bootstrap.sh "--prefix=$BOOST_ROOT" -./b2 install -``` -Install [MongoDB (mongodb.org)](https://www.mongodb.com): - -```bash -mkdir ${HOME}/opt -cd ${HOME}/opt -curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-3.6.3.tgz -tar xf mongodb-linux-x86_64-amazon-3.6.3.tgz -rm -f mongodb-linux-x86_64-amazon-3.6.3.tgz -ln -s ${HOME}/opt/mongodb-linux-x86_64-amazon-3.6.3/ ${HOME}/opt/mongodb -mkdir ${HOME}/opt/mongodb/data -mkdir ${HOME}/opt/mongodb/log -touch ${HOME}/opt/mongodb/log/mongod.log - -tee > /dev/null ${HOME}/opt/mongodb/mongod.conf <build EOS and run a node. - - -### Clean install Centos 7 and higher - -Install the development toolkit: -* Installation on Centos requires installing/enabling the Centos Software Collections - Repository. - [Centos SCL](https://wiki.centos.org/AdditionalResources/Repositories/SCL): - -```bash -sudo yum --enablerepo=extras install centos-release-scl -sudo yum update -sudo yum install -y devtoolset-7 -scl enable devtoolset-7 bash -sudo yum install -y python33.x86_64 -scl enable python33 bash -sudo yum install git autoconf automake libtool make bzip2 \ - bzip2-devel.x86_64 openssl-devel.x86_64 gmp-devel.x86_64 \ - ocaml.x86_64 doxygen libicu-devel.x86_64 python-devel.x86_64 \ - gettext-devel.x86_64 - -``` - -Install CMake 3.10.2: - -```bash -cd ~ -curl -L -O https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz -tar xf cmake-3.10.2.tar.gz -cd cmake-3.10.2 -./bootstrap -make -j$( nproc ) -sudo make install -``` - -Install Boost 1.66: - -```bash -cd ~ -curl -L https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.bz2 > boost_1.66.0.tar.bz2 -tar xf boost_1.66.0.tar.bz2 -echo "export BOOST_ROOT=$HOME/boost_1_66_0" >> ~/.bash_profile -source ~/.bash_profile -cd boost_1_66_0/ -./bootstrap.sh "--prefix=$BOOST_ROOT" -./b2 install -``` - -Install [MongoDB (mongodb.org)](https://www.mongodb.com): - -```bash -mkdir ${HOME}/opt -cd ${HOME}/opt -curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-3.6.3.tgz -tar xf mongodb-linux-x86_64-amazon-3.6.3.tgz -rm -f mongodb-linux-x86_64-amazon-3.6.3.tgz -ln -s ${HOME}/opt/mongodb-linux-x86_64-amazon-3.6.3/ ${HOME}/opt/mongodb -mkdir ${HOME}/opt/mongodb/data -mkdir ${HOME}/opt/mongodb/log -touch ${HOME}/opt/mongodb/log/mongod.log - -tee > /dev/null ${HOME}/opt/mongodb/mongod.conf <build EOS and run a node. - - -### Clean install Fedora 25 and higher - -Install the development toolkit: - -```bash -sudo yum update -sudo yum install git gcc.x86_64 gcc-c++.x86_64 autoconf automake libtool make cmake.x86_64 \ - bzip2-devel.x86_64 openssl-devel.x86_64 gmp-devel.x86_64 \ - libstdc++-devel.x86_64 python3-devel.x86_64 libedit.x86_64 \ - mongodb.x86_64 mongodb-server.x86_64 ncurses-devel.x86_64 \ - swig.x86_64 gettext-devel.x86_64 - -``` - -Install Boost 1.66: - -```bash -cd ~ -curl -L https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.bz2 > boost_1.66.0.tar.bz2 -tar xf boost_1.66.0.tar.bz2 -echo "export BOOST_ROOT=$HOME/boost_1_66_0" >> ~/.bash_profile -source ~/.bash_profile -cd boost_1_66_0/ -./bootstrap.sh "--prefix=$BOOST_ROOT" -./b2 install -``` -Install [mongo-cxx-driver (release/stable)](https://github.com/mongodb/mongo-cxx-driver): - -```bash -cd ~ -curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/1.9.3/mongo-c-driver-1.9.3.tar.gz -tar xf mongo-c-driver-1.9.3.tar.gz -cd mongo-c-driver-1.9.3 -./configure --enable-static --enable-ssl=openssl --disable-automatic-init-and-cleanup --prefix=/usr/local -make -j$( nproc ) -sudo make install -git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/stable --depth 1 -cd mongo-cxx-driver/build -cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. -sudo make -j$( nproc ) -``` - -Install [secp256k1-zkp (Cryptonomex branch)](https://github.com/cryptonomex/secp256k1-zkp.git): - -```bash -cd ~ -git clone https://github.com/cryptonomex/secp256k1-zkp.git -cd secp256k1-zkp -./autogen.sh -./configure -make -j$( nproc ) -sudo make install -``` - -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 -j$( nproc ) install -``` - -Your environment is set up. Now you can build EOS and run a node. - - -### Clean install Ubuntu 16.04 & Linux Mint 18 - -Install the development toolkit: - -```bash -sudo apt-get update -wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - -sudo apt-get install clang-4.0 lldb-4.0 libclang-4.0-dev cmake make \ - libbz2-dev libssl-dev libgmp3-dev \ - autotools-dev build-essential \ - libbz2-dev libicu-dev python-dev \ - autoconf libtool git mongodb -``` - -Install Boost 1.66: - -```bash -cd ~ -wget -c 'https://sourceforge.net/projects/boost/files/boost/1.66.0/boost_1_66_0.tar.bz2/download' -O boost_1.66.0.tar.bz2 -tar xjf boost_1.66.0.tar.bz2 -cd boost_1_66_0/ -echo "export BOOST_ROOT=$HOME/boost_1_66_0" >> ~/.bash_profile -source ~/.bash_profile -./bootstrap.sh "--prefix=$BOOST_ROOT" -./b2 install -source ~/.bash_profile -``` - -Install [mongo-cxx-driver (release/stable)](https://github.com/mongodb/mongo-cxx-driver): - -```bash -cd ~ -curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/1.9.3/mongo-c-driver-1.9.3.tar.gz -tar xf mongo-c-driver-1.9.3.tar.gz -cd mongo-c-driver-1.9.3 -./configure --enable-static --enable-ssl=openssl --disable-automatic-init-and-cleanup --prefix=/usr/local -make -j$( nproc ) -sudo make install -git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/stable --depth 1 -cd mongo-cxx-driver/build -cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. -sudo make -j$( nproc ) -``` - -Install [secp256k1-zkp (Cryptonomex branch)](https://github.com/cryptonomex/secp256k1-zkp.git): - -```bash -cd ~ -git clone https://github.com/cryptonomex/secp256k1-zkp.git -cd secp256k1-zkp -./autogen.sh -./configure -make -sudo make install -``` - -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 -``` - -Your environment is set up. Now you can build EOS and run a node. - - -### MacOS Sierra 10.12.6 & higher - -macOS additional Dependencies: - -* Brew -* Newest XCode -* MongoDB C++ driver - -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 cmake boost openssl@1.0 llvm@4 gmp ninja gettext mongodb -brew link gettext --force -``` -Install [mongo-cxx-driver (release/stable)](https://github.com/mongodb/mongo-cxx-driver): - -```bash -cd ~ -brew install --force pkgconfig -brew unlink pkgconfig && brew link --force pkgconfig -curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/1.9.3/mongo-c-driver-1.9.3.tar.gz -tar xf mongo-c-driver-1.9.3.tar.gz -rm -f mongo-c-driver-1.9.3.tar.gz -cd mongo-c-driver-1.9.3 -./configure --enable-static --enable-ssl=darwin --disable-automatic-init-and-cleanup --prefix=/usr/local -make -j$( sysctl -in machdep.cpu.core_count ) -sudo make install -cd .. -rm -rf mongo-c-driver-1.9.3 - -git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/stable --depth 1 -cd mongo-cxx-driver/build -cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. -make -j$( sysctl -in machdep.cpu.core_count ) -sudo make install -cd .. -rm -rf mongo-cxx-driver -``` - -Install [secp256k1-zkp (Cryptonomex branch)](https://github.com/cryptonomex/secp256k1-zkp.git): - -```bash -cd ~ -git clone https://github.com/cryptonomex/secp256k1-zkp.git -cd secp256k1-zkp -./autogen.sh -./configure -make -j$( sysctl -in machdep.cpu.core_count ) -sudo make install -``` - -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 -j$( sysctl -in machdep.cpu.core_count ) -make install -``` - -Your environment is set up. Now you can build EOS and run a node. +Instructions detailing 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 can be found on the [Wiki](https://github.com/EOSIO/eos/wiki) for this GitHub repository. diff --git a/TUTORIAL.md b/TUTORIAL.md deleted file mode 100644 index 52957e20d0b85004bd998b7d0b5d016bc9128991..0000000000000000000000000000000000000000 --- a/TUTORIAL.md +++ /dev/null @@ -1,417 +0,0 @@ -## EOSIO Developer Tutorial - -The purpose of this tutorial is to demonstrate how to setup a local blockchain -that can be used to experiment with smart contracts. The first part of this -tutorial will focus on: - -1. Starting a Node -2. Creating a Wallet -3. Creating Accounts -4. Deploying Contracts -5. Interacting with Contracts - -The second part of this tutorial will walk you through creating and deploying -your own contracts. - -This tutorial assumes that you have installed EOSIO and that `nodeos` and -`cleos` are in your path. - - -## Starting a Private Blockchain - -You can start your own single-node blockchain with this single command: - -``` -$ nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin -... -eosio generated block 046b9984... #101527 @ 2018-04-01T14:24:58.000 with 0 trxs -eosio generated block 5e527ee2... #101528 @ 2018-04-01T14:24:58.500 with 0 trxs - -``` - -This command sets many flags and loads some optional plugins which we will need for the rest of this tutorial. Assuming everything worked properly, you should see a block generation message every 0.5 seconds. - -``` -eosio generated block 046b9984... #101527 @ 2018-04-01T14:24:58.000 with 0 trxs -``` - -This means your local blockchain is live, producing blocks, and ready to be used. - -For more information about the arguments to `nodeos` you can use: - -``` -nodeos --help -``` - -## Creating a Wallet - -A wallet is a repository of private keys necessary to authorize actions on the blockchain. These keys are stored on disk encrypted using a password generated for you. This password should be stored in a secure password manager. - -``` -$ cleos wallet create -Creating wallet: default -Save password to use in the future to unlock this wallet. -Without password imported keys will not be retrievable. -"PW5JuBXoXJ8JHiCTXfXcYuJabjF9f9UNNqHJjqDVY7igVffe3pXub" -``` - -For the purpose of this simple development environment, your wallet is being managed by your local `nodeos` via the `eosio::wallet_api_plugin` we enabled when we started `nodeos`. Any time you restart `nodeos` you will have to unlock your wallet before you can use the keys within. - -``` -$ cleos wallet unlock --password PW5JuBXoXJ8JHiCTXfXcYuJabjF9f9UNNqHJjqDVY7igVffe3pXub -Unlocked: default -``` - -It is generally not secure to use your password directly on the commandline where it gets logged to your bash history, so you can also unlock in interactive mode: - -``` -$ cleos wallet unlock -password: -``` - -For security purposes it is generally best to leave your wallet locked when you are not using it. To lock your wallet without shutting down `nodeos` you can do: - -``` -$ cleos wallet lock -Locked: default -``` - -You will need your wallet unlocked for the rest of this tutorial. - -All new blockchains start out with a master key for the sole initial account, `eosio`. To interact with the blockchain you will need to import this initial account's private key into your wallet. - -Import the master key for the `eosio` account into your wallet. The master key can be found in the `config.ini` file in the config folder for `nodeos`. In this example, the default config folder is used. On Linux systems, this will be in `~/.local/share/eosio/nodeos/config` and on MacOS, this will be in `~/Library/Application Support/eosio/nodeos/config`. - -``` -$ cleos wallet import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 -imported private key for: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV -``` - -## Load the Bios Contract - -Now that we have a wallet with the key for the `eosio` account loaded, we can set a default system contract. For the purposes of development, the default `eosio.bios` contract can be used. This contract enables you to have direct control over the resource allocation of other accounts and to access other privileged API calls. In a public blockchain, this contract will manage the staking and unstaking of tokens to reserve bandwidth for CPU and network activity, and memory for contracts. - -The `eosio.bios` contract can be found in the `contracts/eosio.bios` folder of your EOSIO source code. The command sequence below assumes it is being executed from the root of the EOSIO source, but you can execute it from anywhere by specifying the full path to `${EOSIO_SOURCE}/build/contracts/eosio.bios`. - -``` -$ cleos set contract eosio build/contracts/eosio.bios -p eosio -Reading WAST... -Assembling WASM... -Publishing contract... -executed transaction: 414cf0dc7740d22474992779b2416b0eabdbc91522c16521307dd682051af083 4068 bytes 10000 cycles -# eosio <= eosio::setcode {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001ab011960037f7e7f0060057f7e7e7e... -# eosio <= eosio::setabi {"account":"eosio","abi":{"types":[],"structs":[{"name":"set_account_limits","base":"","fields":[{"n... -``` - -The result of this command sequence is that `cleos` generated a transaction with two actions, `eosio::setcode` and `eosio::setabi`. - -The code defines how the contract runs and the abi describes how to convert between binary and json representations of the arguments. While an abi is technically optional, all of the EOSIO tooling depends upon it for ease of use. - -Any time you execute a transaction you will see output like: -``` -executed transaction: 414cf0dc7740d22474992779b2416b0eabdbc91522c16521307dd682051af083 4068 bytes 10000 cycles -# eosio <= eosio::setcode {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001ab011960037f7e7f0060057f7e7e7e... -# eosio <= eosio::setabi {"account":"eosio","abi":{"types":[],"structs":[{"name":"set_account_limits","base":"","fields":[{"n... -``` - -This can be read as: The action `setcode` as defined by `eosio` was executed by `eosio` contract with `{args...}`. - -``` -# ${executor} <= ${contract}:${action} ${args...} -> console output from this execution, if any -``` - -As we will see in a bit, actions can be processed by more than one contract. - -The last argument to this call was `-p eosio`. This tells `cleos` to sign this action with the active authority of the `eosio` account, i.e., to sign the action using the private key for the `eosio` account that we imported earlier. - - -## Create an Account - -Now that we have setup the basic system contract, we can start to create our own accounts. We will create two accounts, `user` and `tester`, and we will need to associate a key with each account. In this example, the same key will be used for both accounts. - -To do this we first generate a key for the accounts. - -``` -$ cleos create key -Private key: 5Jmsawgsp1tQ3GD6JyGCwy1dcvqKZgX6ugMVMdjirx85iv5VyPR -Public key: EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 -``` - -Then we import this key into our wallet: -``` -$ cleos wallet import 5Jmsawgsp1tQ3GD6JyGCwy1dcvqKZgX6ugMVMdjirx85iv5VyPR -imported private key for: EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 -``` -**NOTE:** Be sure to use the actual key value generated by the `cleos` command and not the one shown in the example above! - -Keys are not automatically added to a wallet, so skipping this step could result in losing control of your account. - -## Create Two User Accounts - -Next we will create two accounts, `user` and `tester`, using the key we created and imported above. - -``` -$ cleos create account eosio user EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 -executed transaction: 8aedb926cc1ca31642ada8daf4350833c95cbe98b869230f44da76d70f6d6242 364 bytes 1000 cycles -# eosio <= eosio::newaccount {"creator":"eosio","name":"user","owner":{"threshold":1,"keys":[{"key":"EOS7ijWCBmoXBi3CgtK7DJxentZZ... - -$ cleos create account eosio tester EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 -executed transaction: 414cf0dc7740d22474992779b2416b0eabdbc91522c16521307dd682051af083 366 bytes 1000 cycles -# eosio <= eosio::newaccount {"creator":"eosio","name":"tester","owner":{"threshold":1,"keys":[{"key":"EOS7ijWCBmoXBi3CgtK7DJxentZZ... -``` -**NOTE:** The `create account` subcommand requires two keys, one for the OwnerKey (which in a production environment should be kept highly secure) and one for the ActiveKey. In this tutorial example, the same key is used for both. - -Because we are using the `eosio::account_history_api_plugin` we can query all accounts that are controlled by our key: - -``` -$ cleos get accounts EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 -{ - "account_names": [ - "tester", - "user" - ] -} -``` - -## Create Token Contract - -At this stage the blockchain doesn't do much, so let's deploy the `eosio.token` contract. This contract enables the creation of many different tokens all running on the same contract but potentially managed by different users. - -Before we can deploy the token contract we must create an account to deploy it to. - -``` -$ cleos create account eosio eosio.token EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 -... -``` - -Then we can deploy the contract which can be found in `${EOSIO_SOURCE}/build/contracts/eosio.token` - -``` -$ cleos set contract eosio.token build/contracts/eosio.token -p eosio.token -Reading WAST... -Assembling WASM... -Publishing contract... -executed transaction: 528bdbce1181dc5fd72a24e4181e6587dace8ab43b2d7ac9b22b2017992a07ad 8708 bytes 10000 cycles -# eosio <= eosio::setcode {"account":"eosio.token","vmtype":0,"vmversion":0,"code":"0061736d0100000001ce011d60067f7e7f7f7f7f00... -# eosio <= eosio::setabi {"account":"eosio.token","abi":{"types":[],"structs":[{"name":"transfer","base":"","fields":[{"name"... -``` - -### Create the EOS Token - -You can view the interface to `eosio.token` as defined by `contracts/eosio.token/eosio.token.hpp`: -``` - void create( account_name issuer, - asset maximum_supply, - uint8_t can_freeze, - uint8_t can_recall, - uint8_t can_whitelist ); - - - void issue( account_name to, asset quantity, string memo ); - - void transfer( account_name from, - account_name to, - asset quantity, - string memo ); -``` - -To create a new token we must call the `create(...)` action with the proper arguments. This command will use the symbol of the maximum supply to uniquely identify this token from other tokens. The issuer will be the one with authority to call issue and or perform other actions such as freezing, recalling, and whitelisting of owners. - -The concise way to call this method, using positional arguments: -``` -$ cleos push action eosio.token create '[ "eosio", "1000000000.0000 EOS", 0, 0, 0]' -p eosio.token -executed transaction: 0e49a421f6e75f4c5e09dd738a02d3f51bd18a0cf31894f68d335cd70d9c0e12 260 bytes 1000 cycles -# eosio.token <= eosio.token::create {"issuer":"eosio","maximum_supply":"1000000000.0000 EOS","can_freeze":0,"can_recall":0,"can_whitelis... -``` - -Alternatively, a more verbose way to call this method, using named arguments: - -``` -$ cleos push action eosio.token create '{"issuer":"eosio", "maximum_supply":"1000000000.0000 EOS", "can_freeze":0, "can_recall":0, "can_whitelist":0}' -p eosio.token -executed transaction: 0e49a421f6e75f4c5e09dd738a02d3f51bd18a0cf31894f68d335cd70d9c0e12 260 bytes 1000 cycles -# eosio.token <= eosio.token::create {"issuer":"eosio","maximum_supply":"1000000000.0000 EOS","can_freeze":0,"can_recall":0,"can_whitelis... -``` - - -This command created a new token `EOS` with a pecision of 4 decimials and a maximum supply of 1000000000.0000 EOS. - -In order to create this token we required the permission of the `eosio.token` contract because it "owns" the symbol namespace (e.g. "EOS"). Future versions of this contract may allow other parties to buy symbol names automatically. For this reason we must pass `-p eosio.token` to authorize this call. - -### Issue Tokens to Account "User" - -Now that we have created the token, the issuer can issue new tokens to the account `user` we created earlier. - -We will use the positional calling convention (vs named args). - -``` -$ cleos push action eosio.token issue '[ "user", "100.0000 EOS", "memo" ]' -p eosio -executed transaction: 822a607a9196112831ecc2dc14ffb1722634f1749f3ac18b73ffacd41160b019 268 bytes 1000 cycles -# eosio.token <= eosio.token::issue {"to":"user","quantity":"100.0000 EOS","memo":"memo"} ->> issue -# eosio.token <= eosio.token::transfer {"from":"eosio","to":"user","quantity":"100.0000 EOS","memo":"memo"} ->> transfer -# eosio <= eosio.token::transfer {"from":"eosio","to":"user","quantity":"100.0000 EOS","memo":"memo"} -# user <= eosio.token::transfer {"from":"eosio","to":"user","quantity":"100.0000 EOS","memo":"memo"} -``` - -This time the output contains several different actions: one issue and three transfers. While the only action we signed was `issue`, the `issue` action performed an "inline transfer" and the "inline transfer" notified the sender and receiver accounts. The output indicates all of the action handlers that were called, the order they were called in, and whether or not any output was generated by the action. - -Technically, the `eosio.token` contract could have skipped the `inline transfer` and opted to just modify the balances directly. However, in this case, the `eosio.token` contract is following our token convention that requires that all account balances be derivable by the sum of the transfer actions that reference them. It also requires that the sender and receiver of funds be notified so they can automate handling deposits and withdrawals. - -If you want to see the actual transaction that was broadcast, you can use the `-d -j` options to indicate "don't broadcast" and "return transaction as json". - -``` -$ cleos push action eosio.token issue '["user", "100.0000 EOS", "memo"]' -p eosio -d -j -{ - "expiration": "2018-04-01T15:20:44", - "region": 0, - "ref_block_num": 42580, - "ref_block_prefix": 3987474256, - "net_usage_words": 21, - "kcpu_usage": 1000, - "delay_sec": 0, - "context_free_actions": [], - "actions": [{ - "account": "eosio.token", - "name": "issue", - "authorization": [{ - "actor": "eosio", - "permission": "active" - } - ], - "data": "00000000007015d640420f000000000004454f5300000000046d656d6f" - } - ], - "signatures": [ - "EOSJzPywCKsgBitRh9kxFNeMJc8BeD6QZLagtXzmdS2ib5gKTeELiVxXvcnrdRUiY3ExP9saVkdkzvUNyRZSXj2CLJnj7U42H" - ], - "context_free_data": [] -} -``` - -### Transfer Tokens to Account "Tester" - -Now that account `user` has tokens, we will transfer some to account `tester`. We indicate that `user` authorized this action using the permission argument `-p user`. - -``` -$ cleos push action eosio.token transfer '[ "user", "tester", "25.0000 EOS", "m" ]' -p user -executed transaction: 06d0a99652c11637230d08a207520bf38066b8817ef7cafaab2f0344aafd7018 268 bytes 1000 cycles -# eosio.token <= eosio.token::transfer {"from":"user","to":"tester","quantity":"25.0000 EOS","memo":"m"} ->> transfer -# user <= eosio.token::transfer {"from":"user","to":"tester","quantity":"25.0000 EOS","memo":"m"} -# tester <= eosio.token::transfer {"from":"user","to":"tester","quantity":"25.0000 EOS","memo":"m"} -``` - - -## Hello World Contract - -We will now create our first "hello world" contract. Create a new folder called "hello", cd into the folder, then create a file "hello.cpp" with the following contents: - -#### hello/hello.cpp -``` -#include -#include -using namespace eosio; - -class hello : public eosio::contract { - public: - using contract::contract; - - /// @abi action - void hi( account_name user ) { - print( "Hello, ", name{user} ); - } -}; - -EOSIO_ABI( hello, (hi) ) -``` - -You can compile your code to web assmebly (.wast) as follows: -``` -$ eosiocpp -o hello.wast hello.cpp -``` -**NOTE:** The compiler might generate warnings. These can be safely ignored. - -Now generate the abi: - -``` -$ eosiocpp -g hello.abi hello.cpp -Generated hello.abi -``` - -Create an account and upload the contract: - -``` -$ cleos create account eosio hello.code EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 -... -$ cleos set contract hello.code ../hello -p hello.code -... -``` - -Now we can run the contract: - -``` -$ cleos push action hello.code hi '["user"]' -p user -executed transaction: 4c10c1426c16b1656e802f3302677594731b380b18a44851d38e8b5275072857 244 bytes 1000 cycles -# hello.code <= hello.code::hi {"user":"user"} ->> Hello, user -``` - -At this time the contract allows anyone to authorize it, we could also say: - -``` -$ cleos push action hello.code hi '["user"]' -p tester -executed transaction: 28d92256c8ffd8b0255be324e4596b7c745f50f85722d0c4400471bc184b9a16 244 bytes 1000 cycles -# hello.code <= hello.code::hi {"user":"user"} ->> Hello, user -``` - -In this case tester is the one who authorized it and user is just an argument. If we want our contact to authenticate the user we are saying "hi" to, then we need to modify the contract to require authentication. - -Modify the hi() function in hello.cpp as follows: -``` -void hi( account_name user ) { - require_auth( user ); - print( "Hello, ", name{user} ); -} -``` -Repeat the steps to compile the wast file and generate the abi, then set the contract again to deploy the update. - -Now if we attempt to mismatch the user and the authority, the contract will throw an error: -``` -$ cleos push action hello.code hi '["tester"]' -p user -Error 3030001: missing required authority -Ensure that you have the related authority inside your transaction!; -If you are currently using 'cleos push action' command, try to add the relevant authority using -p option. -Error Details: -missing authority of tester -``` - -We can fix this by giving the permission of tester: - -``` -$ cleos push action hello.code hi '["tester"]' -p tester -executed transaction: 235bd766c2097f4a698cfb948eb2e709532df8d18458b92c9c6aae74ed8e4518 244 bytes 1000 cycles -# hello.code <= hello.code::hi {"user":"tester"} ->> Hello, tester -``` - - -## Deploy Exchange Contract -Similar to the examples shown above, we can deploy the exchange contract. It is assumed this is being run from the root of the EOSIO source. - -``` -$ cleos create account eosio exchange EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 -executed transaction: 4d38de16631a2dc698f1d433f7eb30982d855219e7c7314a888efbbba04e571c 364 bytes 1000 cycles -# eosio <= eosio::newaccount {"creator":"eosio","name":"exchange","owner":{"threshold":1,"keys":[{"key":"EOS7ijWCBmoXBi3CgtK7DJxe... - -$ cleos set contract exchange build/contracts/exchange -p exchange -Reading WAST... -Assembling WASM... -Publishing contract... -executed transaction: 5a63b4de8a1da415590778f163c5ed26dc164c960185b20fd834c297cf7fa8f4 35172 bytes 10000 cycles -# eosio <= eosio::setcode {"account":"exchange","vmtype":0,"vmversion":0,"code":"0061736d0100000001f0023460067f7e7f7f7f7f00600... -# eosio <= eosio::setabi {"account":"exchange","abi":{"types":[{"new_type_name":"account_name","type":"name"}],"structs":[{"n... -``` -