1, currency基本組成文件:cpp,hpp,abi,wast
參考游戲tic_tac_toe的currency
(1)hpp文件中主要包含:namesapece tic_tac_toe{
一些基本數(shù)據(jù)和基本動(dòng)作函數(shù)的結(jié)構(gòu)體 struct}
(2)cpp文件中則主要是實(shí)現(xiàn)hpp中所定義的data和action等的核心代碼活喊。
(3)abi則是所有struct的集成淌铐,形式簡(jiǎn)單瓷患,根據(jù)hpp文件生成。
? (4) wast 通過(guò)eosiocpp工具建瘫,依據(jù)cpp文件編譯生成。
2, 一個(gè)abi文件的結(jié)構(gòu):
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
參考基本流程:來(lái)源eos wiki 文檔(eos2.0模式)
寫(xiě)智能合約
使用eoscpp工具創(chuàng)建骨架?$ eoscpp -n ${contract}
在.cpp&.hpp文件中編寫(xiě)您的智能合約
生成.abi文件?$ eoscpp -g ${contract}.abi ${contract}.hpp
生成.wast文件?$ eoscpp -o ${contract}.wast ${contract}.cpp
部署智能合約
連接到一個(gè)節(jié)點(diǎn)?$ eosc -H ${node_ip} -p ${port_num}
創(chuàng)建一個(gè)錢(qián)包?$ eosc wallet create
如果您尚未擁有EOS密鑰,請(qǐng)創(chuàng)建一個(gè)帳戶
導(dǎo)入您的帳戶密鑰?$ eosc wallet import ${private_key}
解鎖你的錢(qián)包?$ eosc wallet unlock ${wallet}
部署合同?$ eosc set contract ${account} ${contract}.wast ${contract}.abi