1, currency基本组成文件:cpp,hpp,abi,wast
参考游戏tic_tac_toe的currency
(1)hpp文件中主要包含:namesapece tic_tac_toe{
一些基本数据和基本动作函数的结构体 struct}
(2)cpp文件中则主要是实现hpp中所定义的data和action等的核心代码。
(3)abi则是所有struct的集成,形式简单,根据hpp文件生成。
(4) wast 通过eosiocpp工具,依据cpp文件编译生成。
2, 一个abi文件的结构:
types
structs
actions
tables
3, eosiocpp工具
root@duffy-HP-Z420-Workstation:~/eos/build/programs# eosiocpp -h
Usage: /usr/local/bin/eosiocpp -o output.wast contract.cpp [other.cpp ...]
OR
/usr/local/bin/eosiocpp -n mycontract
OR
/usr/local/bin/eosiocpp -g contract.abi types.hpp
Options:
-n | --newcontract [name]
Create a new contract in the [name] folder, based on the example contract
OR
-o | --outname [output.wast] [input.cpp ...]
Generate the wast output file based on input cpp files
OR
-g | --genabi contract.abi types.hpp
Generate the ABI specification file [EXPERIMENTAL]
root@duffy-HP-Z420-Workstation:~/eos/build/contracts#eosiocpp -n helloworld
/**
* @file
* @copyright defined in eos/LICENSE.txt
created helloworld from skeleton
root@duffy-HP-Z420-Workstation:~/eos/build/contracts# cd helloworld/
root@duffy-HP-Z420-Workstation:~/eos/build/contracts/helloworld# ls
helloworld.abi helloworld.cpp helloworld.hpp
参考基本流程:来源eos wiki 文档(eos2.0模式)
写智能合约
使用eoscpp工具创建骨架 $ eoscpp -n ${contract}
在.cpp&.hpp文件中编写您的智能合约
生成.abi文件 $ eoscpp -g ${contract}.abi ${contract}.hpp
生成.wast文件 $ eoscpp -o ${contract}.wast ${contract}.cpp
部署智能合约
连接到一个节点 $ eosc -H ${node_ip} -p ${port_num}
创建一个钱包 $ eosc wallet create
如果您尚未拥有EOS密钥,请创建一个帐户
导入您的帐户密钥 $ eosc wallet import ${private_key}
解锁你的钱包 $ eosc wallet unlock ${wallet}
部署合同 $ eosc set contract ${account} ${contract}.wast ${contract}.abi