编写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. PHP常见错误级别及错误码

    数字 常量 说明 1 E_ERROR 致命错误,脚本执行中断,就是脚本中有不可识别的东西出现 举例: Error:Invalid parameters. Invalid parameter name ...

  2. django 多对多 增 删 改 查

      一.通过url方式实现多对多的:增加,删除,编辑 代码目录: urls.py 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ...

  3. poj2279——Mr. Young's Picture Permutations

    Description Mr. Young wishes to take a picture of his class. The students will stand in rows with ea ...

  4. PythonStudy——Python字典底层实现原理 The underlying implementation principle of Python dictionary

    在Python中,字典是通过散列表或说哈希表实现的.字典也被称为关联数组,还称为哈希数组等.也就是说,字典也是一个数组,但数组的索引是键经过哈希函数处理后得到的散列值.哈希函数的目的是使键均匀地分布在 ...

  5. c#读sql server数据添加到MySQL数据库

    using System;using System.Collections.Generic;using System.Text;using Console = System.Console;using ...

  6. javaScript 中的私有,共有,特权属性和方法

    function constructor () { var private_v; // 私有属性 var private_f = function () { // 私有方法 // code }; th ...

  7. set_false_path的用法

    set_false_path的用法 非功能性路径,因为两个多路选择器被相同的选择信号驱动? 上电复位信号 set_false两个异步时钟域的路径 在两个时钟域之间,设置set_false_path,应 ...

  8. python configparser使用

    .ini文件由若干section(部分)组成, 而每一个section又由若干键值对组成. 以 example.ini为例: [DEFAULT] ServerAliveInterval = 45 Co ...

  9. sql server 索引碎片相关问题

    1.查看表的索引碎片情况 --改成当前库 use DB_Name --创建变量 指定要查看的表 declare @table_id int set @table_id=object_id('Table ...

  10. sql server 数据库变成单用户模式的恢复

    USE master;GODECLARE @SQL VARCHAR(MAX);SET @SQL=''SELECT @SQL=@SQL+'; KILL '+RTRIM(SPID)FROM master. ...