开发笔记3

创建一个helloworld合约
(1)在program中写如下合约代码.
#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) )

(2)编译
eosiocpp -o hello.wast hello.cpp
eosiocpp -g hello.abi hello.cpp
(3)创建账户
cleos create account eosio hello.code  EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
(4)部署合约
cleos set contract hello.code ../hello -p hello.code
(5)调用合约
cleos push action hello.code hi '["user"]' -p user

猜你喜欢

转载自blog.csdn.net/wangping623/article/details/80932102