[blockchain-036] 用c++编写一个智能合约

本文档详细介绍了如何使用C++编写EOSIO智能合约,从参考文献到启动单节点测试网络,再到创建合约目录、编写合约源代码、编译合约文件,以及通过cleos创建账户和部署智能合约的步骤。
摘要由CSDN通过智能技术生成

1.参考文献

https://github.com/EOSIO/eos/wiki/Tutorial-Hello-World-Contract

注意:编译eos之后,要"cd build; sudo make install",这样后文的编译才不会出现问题,否则会缺失很多头文件

2.启动单节点eos测试网络

./nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin

3.编写部署智能合约

  3.1 创建目录hello, cd hello
  3.2 创建hellp.cpp文件,内容如下

#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
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) )

    3.3 编译hello.wast文件

eosiocpp -o hello.wast hello.cpp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值