编写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. Git版本库创建(包含文件权限设置 Linux环境下)

    确保git服务已安装成功,如果没有安装git服务查看:Git源码安装 Linux指定安装目录 1.创建git用户,并设置密码.并禁止git用户通过shell登录服务器(注意如果需要安装gitolite ...

  2. quartz Cron表达式解读

    CronTrigger CronTriggers往往比SimpleTrigger更有用,如果您需要基于日历的概念,而非SimpleTrigger完全指定的时间间隔,复发的发射工作的时间表. CronT ...

  3. css自定义checkbox和radio样式

    很常见的问题,也有许多人写过类似的文章,自己写来记录下 css代码如下: #myCheck + label,.myRadio + label{ width:16px; height:16px; bor ...

  4. 《DSP using MATLAB》Problem 7.12

    阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  5. The problems when using a new ubuntu 18.04

    how to install dual systems (windows & ubuntu) Donwloading the ubuntu from web. Using refu to cr ...

  6. Java高级特性 第4节 输入输出流

    一.使用I/O操作文件 关键步骤: 使用File类操作文件或目录属性 使用FileInputStream类读文本文件 使用FileOutputStram类写文本文件 使用BufferedReader类 ...

  7. 解决ansible上传速度慢的问题

    问题: 假如有A.B.C.D....等机器,机器A为Ansible服务器,机器B.C.D...等为Ansible管理的节点服务器,A机器与其他机器都不在同一个网络,也就是A机器必须添加VPN之后才能与 ...

  8. MySQL 命令(导出数据):mysqldump

    官方网址:https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html

  9. ElasticSearch的lowlevelApi和低级别API

    之前开发使用的其实都是lowLevel的api,所谓lowlevelapi就是操作ES的json字符串要自己去写:所谓highlevel的api就是指将查询的json字符串给对象化,创建一个Searc ...

  10. django 获取用户提交的数据 文件 表单

    templates: <div> <form action="/detail" method="post" enctype="mul ...