编写Smart Contract

1、包含头文件.

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

2、使用命名空间

  1. using namespace eosio;

3、实现一个空的合约

  1. class hello : public contract {
  2. public:
  3. using contract::contract;
  4. };

4、合约中添加一个action

  1. class hello : public contract {
  2. public:
  3. using contract::contract;
  4.  
  5. [[eosio::action]]
  6. void hi( name user ) {
  7. print( "Hello, ", name{user});
  8. }
  9. };

5、添加转发表

  1. EOSIO_DISPATCH( hello, (hi))

6、使用 eosio-cpp -o --abigen 生成 .wasm、.abi

  1. eosio-cpp -o hello.wasm hello.cpp --abigen

7、用set contract 命令发布合约

  

  -p 指明需要 hello的 active权限

  1. cleos set contract hello /home/ubuntu/contracts/hello -p hello@active

8、使用 push action 命令来使用

  

-p 指明本身的权限

  1. leos push action hello hi '["bob"]' -p bob@active

参考:

1、https://developers.eos.io/eosio-home/docs/your-first-contract

Smart Contract - Hello World的更多相关文章

  1. ethereum/EIPs-1271 smart contract

    https://github.com/PhABC/EIPs/blob/is-valid-signature/EIPS/eip-1271.md Standard Signature Validation ...

  2. Using APIs in Your Ethereum Smart Contract with Oraclize

    Homepage Coinmonks HOMEFILTER ▼BLOCKCHAIN TUTORIALSCRYPTO ECONOMYTOP READSCONTRIBUTEFORUM & JOBS ...

  3. Truffle Smart Contract Error: Invalid number of parameter

      I followed the tutorial of quorum with truffle: https://truffleframework.com/tutorials/building-da ...

  4. 区块链学习5:智能合约Smart contract原理及发展历程科普知识

    ☞ ░ 前往老猿Python博文目录 ░ 一.智能合约的定义 通俗来说,智能合约就是一种在计算机系统上,当一定条件满足的情况下可被自动执行的合约,智能合约体现为一段代码及其运行环境.例如银行信用卡的自 ...

  5. 【翻译】A Next-Generation Smart Contract and Decentralized Application Platform

    原文链接:https://github.com/ethereum/wiki/wiki/White-Paper 当中本聪在2009年1月启动比特币区块链时,他同时向世界引入了两种未经测试的革命性的新概念 ...

  6. smart contract 知识点

    知识点 memory vs storage vs stack storage , where all the contract state variables reside. Every contra ...

  7. 【阿菜Writeup】Security Innovation Smart Contract CTF

    赛题地址:https://blockchain-ctf.securityinnovation.com/#/dashboard Donation 源码解析 我们只需要用外部账户调用 withdrawDo ...

  8. the security of smart contract- 1

    https://blog.zeppelin.solutions/the-hitchhikers-guide-to-smart-contracts-in-ethereum-848f08001f05 这个 ...

  9. Smart Contracts

    A smart contract is a computer code running on top of a blockchain containing a set of rules under w ...

随机推荐

  1. Python重新安装pip

    1). 下载pip安装工具: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py 2).执行升级命令: python2.7 get-pip. ...

  2. 【转】matlab学习(5) 读取excel文件

    转自:https://blog.csdn.net/thy19988/article/details/78489623 1.使用函数xlsread读取单个文件(1)num=xlsread(filenam ...

  3. linux自启动tomcat

    第一种方式 1.修改脚本文件rc.local:vim /etc/rc.d/rc.local 这个脚本是使用者自定的开机启动程序,可以在里面添加想在系统启动之后执行的脚本或者脚本执行命令 2.添加如下内 ...

  4. bzoj 2460 线性基

    #include<bits/stdc++.h> #define ll long long #define LL long long #define int long long using ...

  5. ios-项目启动页面

    项目运行启动页面: 点工程项目targets-(或Images.xcasets)-LaunchImage(iphone四种规格图片:320*480/350*568/640*960/640*1136)将 ...

  6. python调用mediainfo工具批量提取视频信息

    写了2个脚本,分别是v1版本和v2版本 都是python调用mediainfo工具提取视频元数据信息 v1版本是使用pycharm中测试运行的,指定了视频路径 v2版本是最终交付给运营运行的,会把v2 ...

  7. Centos6.8通过yum安装mysql5.7 centos7.5适用

    1.安装mysql的yum源 a.下载配置mysql的yum源的rpm包 根据上面3张图片中的操作下载下来的rpm文件可以通过如下命令获取: wget https://dev.mysql.com/ge ...

  8. EF 指定字段修改

    public virtual void Modify(T model, params string[] ProNames) { DbEntityEntry entry = db.Entry<T& ...

  9. ClassNotFoundException与NoClassDefFoundError异常

    方法 loadClass()抛出的是 java.lang.ClassNotFoundException异常(一般是jar冲突或者没有引入jar):方法 defineClass()抛出的是 java.l ...

  10. awk 进阶,百万行文件取交集

    今天我们说的不是简单的交集,而是如下示例: file1: as,er,gf,1212kl,iop,121378,jkl,uio,jki,1214vbnm,yuoi,678i,1215sadfasdf, ...