安裝EOS合約工具eosio.cdt

安裝:

安裝完以後 會產生 eosio-cpp_, eosio-cceosio-ldeosio-pp, and _eosio_abigen (These are the C++ compiler, C compiler, linker, postpass tool and ABI generator.) 這些交互工具。html

// step 1
$ git clone --recursive https://github.com/eosio/eosio.cdt

PS:整個克隆過程很慢,若是中斷進入項目根目錄,執行git submodule update --init --recursive繼續下載。git

// step 2
// ./build.sh <CORE_SYMBOL> coresymbol能夠理解爲鏈名稱 這裏用eos
$ ./build.sh EOS

build完成以後會出現如下界面:github

  ___           ___           ___                       ___
     /  /\         /  /\         /  /\        ___          /  /\
    /  /:/_       /  /::\       /  /:/_      /  /\        /  /::\
   /  /:/ /\     /  /:/\:\     /  /:/ /\    /  /:/       /  /:/\:\
  /  /:/ /:/_   /  /:/  \:\   /  /:/ /::\  /__/::\      /  /:/  \:\
 /__/:/ /:/ /\ /__/:/ \__\:\ /__/:/ /:/\:\ \__\/\:\__  /__/:/ \__\:\
 \  \:\/:/ /:/ \  \:\ /  /:/ \  \:\/:/~/:/    \  \:\/\ \  \:\ /  /:/
  \  \::/ /:/   \  \:\  /:/   \  \::/ /:/      \__\::/  \  \:\  /:/
   \  \:\/:/     \  \:\/:/     \__\/ /:/       /__/:/    \  \:\/:/
    \  \::/       \  \::/        /__/:/        \__\/      \  \::/
     \__\/         \__\/         \__\/                     \__\/
For more information:
EOSIO website: https://eos.io

 安裝:web

// step 3
sudo ./install.sh

安裝完後 一樣會出現安裝成功畫面, 這一步install會將下列可執行工具鏈接到 bin目錄下工具

llvm-ranlib
llvm-ar
llvm-objdump
llvm-readelf
eosio-cc
eosio-cpp
eosio-ld
eosio-pp
eosio-abigen
wasm2wat
wat2wasmpost

編譯:

在路徑eosio.cdt/examples 有hello合約的示例ui

#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>

using namespace eosio;

class hello : public eosio::contract {
  public:
      using contract::contract;

      [[eosio::action]]
      void hi( name user ) {
         print("Hello World",name{user});
      }
};
EOSIO_DISPATCH( hello, (hi))

1 編譯wasm文件spa

$ eosio-cpp hello.cpp -o hello.wasm

2 編譯abi文件orm

// 1 在編譯wasm文件的同時加上--abigen flag能夠同時編譯abi文件
$ eosio-cpp hello.cpp -o hello.wasm --abigen
// 2 直接使用eosio-abigen 編譯
$ eosio-abigen hello.cpp --output=hello.abi
相關文章
相關標籤/搜索