EOS智能合约流程

本文档详细介绍了在EOS环境下,从创建钱包、账号到部署智能合约、发行货币和转账的完整流程。遇到的问题主要是环境配置,解决后通过cmake构建合约,并在成功编译后执行 eosiod。在master分支上发行货币需额外步骤,需关注官方文档更新。

流程:创建钱包 ,创建账号,根据合约发行货币,转账 

因为master更新比较频繁,本人选择的是SuperDawn-2018-03-18 分支

这里不在描述环境的配置了,之前已经配置好了。大部分遇到的问题可能就是环境没配置好,或者分支是master问题导致的,多试几次。

直接粘贴一下

Install the development toolkit:

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
Install Boost 1.64:

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

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:

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:

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:

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


克隆代码到本地

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

切换版本,更新最新代码

git checkout -b 318 SuperDawn-2018-03-18

git submodule update --init --recursive

创建build目录,进入文件夹

mkdir build
cd build

执行cmake命令

cmake -DBINARYEN_BIN=~/binaryen/bin -DBOOST_ROOT=/home/feng/boost_1_66_0 -DWASM_ROOT=~/wasm-compiler/llvm -DCMAKE_BUILD_TYPE=Debug ..

构建成功:

feng@feng-B250-HD3P:~/workSpace/eos/build$ cmake -DBINARYEN_BIN=~/binaryen/bin -DBOOST_ROOT=/home/feng/boost_1_66_0 -DWASM_ROOT=~/wasm-compiler/llvm -DCMAKE_BUILD_TYPE=Debug ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using custom FindBoost.cmake
-- Boost version: 1.66.0
-- Found the following Boost libraries:
--   thread
--   date_time
--   system
--   filesystem
--   program_options
--   signals
--   serialization
--   chrono
--   unit_test_framework
--   context
--   locale
-- Configuring Eos on Linux
-- --------------------------------------------------------------------
-- No WASM compiler could be found ... (skipping building of contracts)
-- --------------------------------------------------------------------
-- Found Secp256k1: /usr/local/lib/libsecp256k1.a
-- Found GMP: /usr/lib/x86_64-linux-gnu/libgmp.a  
-- Configuring fc to build on Unix/Apple
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libssl.a;/usr/lib/x86_64-linux-gnu/libcrypto.a (found version "1.0.2g") 
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") 
-- zlib found
-- Found BZip2: /usr/lib/x86_64-linux-gnu/libbz2.so (found version "1.0.6") 
-- Looking for BZ2_bzCompressInit
-- Looking for BZ2_bzCompressInit - found
-- bzip2 found
-- Using custom FindBoost.cmake
-- Boost version: 1.66.0
-- Found the following Boost libraries:
--   thread
--   date_time
--   system
--   filesystem
--   chrono
--   unit_test_framework
--   locale
-- Configuring ChainBase on Linux
-- egenesis: /home/feng/workSpace/eos/genesis.json
-- embed_genesis_args: -t/home/feng/workSpace/eos/libraries/egenesis/egenesis_brief.cpp.tmpl---/home/feng/workSpace/eos/build/libraries/egenesis/egenesis_brief.cpp-t/home/feng/workSpace/eos/libraries/egenesis/egenesis_full.cpp.tmpl---/home/feng/workSpace/eos/build/libraries/egenesis/egenesis_full.cpp--genesis-json/home/feng/workSpace/eos/genesis.json
-- Using custom FindBoost.cmake
-- Boost version: 1.66.0
-- Found the following Boost libraries:
--   thread
--   date_time
--   system
--   filesystem
--   chrono
--   program_options
--   unit_test_framework
--   locale
-- Configuring AppBase on Linux
-- Using custom FindBoost.cmake
-- Boost version: 1.66.0
-- Found the following Boost libraries:
--   unit_test_framework
mongo_db_plugin not selected and will be omitted.
-- Found Git: /usr/bin/git (found version "2.7.4") 
-- Git commit revision: a731471c
-- Git commit revision: a731471c
-- Found Intl: /usr/include  
-- Git commit revision: a731471c
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.11") 
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    WASM_ROOT


-- Build files have been written to: /home/feng/workSpace/eos/build

但是你会发现

-- No WASM compiler could be found ... (skipping building of contracts)

这个是因为环境没有配置对,会掉过合约代码的构建,添加DWASM_LLVM_CONFIG

cmake -DBINARYEN_BIN=~/binaryen/bin -DBOOST_ROOT=/home/feng/boost_1_66_0 -DCMAKE_BUILD_TYPE=Debug -DWASM_LLVM_CONFIG=/home/feng/opt/wasm/bin/llvm-config ..

重新构建后,没有之前问题的

feng@feng-B250-HD3P:~/workSpace/eos/build$ cmake -DBINARYEN_BIN=~/binaryen/bin -DBOOST_ROOT=/home/feng/boost_1_66_0 -DCMAKE_BUILD_TYPE=Debug -DWASM_LLVM_CONF
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值