编写Smart Contract

1、包含头文件.

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

2、使用命名空间

using namespace eosio;

3、实现一个空的合约

class hello : public contract {
public:
using contract::contract;
};

4、合约中添加一个action

class hello : public contract {
public:
using contract::contract; [[eosio::action]]
void hi( name user ) {
print( "Hello, ", name{user});
}
};

5、添加转发表

EOSIO_DISPATCH( hello, (hi))

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

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

7、用set contract 命令发布合约

  

  -p 指明需要 hello的 active权限

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

8、使用 push action 命令来使用

  

-p 指明本身的权限

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. 框架tensorflow2

    TensorFlow 2 TensorFlow 激励函数 TensorFlow 添加层: 思考:matmul和multiply两种乘法的区别:http://www.soaringroad.com/?p ...

  2. matplotlib画sin(x)和cos(x)/2

    import matplotlib.pyplot as mp 1. 基本的绘图 mp.plot(水平坐标, 垂直坐标, linestyle=线型, linewidth=线宽, color=颜色, .. ...

  3. 2018年3月6日16:54:58 考试错误的java题目总结

  4. 在vue中使用Echarts画曲线图(异步加载数据)

    现实的工作中, 数据不可能写死的,所有的数据都应该通过发送请求进行获取. 所以本项目的需求是请求服务器获得二维数组,并生成曲线图.曲线图的横纵坐标均从获得的数据中取得. Echarts官方文档: ht ...

  5. python学习之路03

    一.常量和变量 1.python中的数据类型 分类: ​ Number:数字型[整型,浮点型,复数] ​ String:字符串型 ​ Boolean:布尔型[True,False] ​ None:空值 ...

  6. build to win读后感

    在软件开发的过程中,不能盲目去show自己的成果,而是要大量考虑别人的意见,在广范围的撒网之后,收集意见,最后在一锤定音. 还有就是,要懂得团队合作,例如,本文介绍了一个事例,作者的团队与科研团队合作 ...

  7. C# winform 打开主界面并关闭登录界面

    在winform 界面编程中,我们有时候要在主界面打开之前先显示登录界面,当登录界面用户信息校验正确后才打开主界面,而这时登陆界面也完成使命该功成身退了. 目前有两种方法可实现: 方法1. 隐藏登录界 ...

  8. LDAP学习总结

    一.简介: LDAP(Light Directory Access Portocol),它是基于X.500标准的轻量级目录访问协议.目录是一个为查询.浏览和搜索而优化的数据库,它成树状结构组织数据,类 ...

  9. 简析Colorspace

    最近Colorspace成为了一个很高频的问题,很多Compositor为这个概念感到纠结,其实这是很正常的,因为Colorspace发展了很多年,也有很多种标准,最后还要落地到合成软件中,中间自然就 ...

  10. 一次Windows 安装问题

    在 thinpad x250上安装 windows 10时,提示"安装程序无法创建新的系统分区,也无法定位现有系统分区". x250 的主板上自带一个16G的闪存且标识为 主分区, ...