- 浏览: 770787 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (1045)
- 数据结构 (36)
- UML与设计模式 (42)
- c++ (87)
- rust (36)
- Qt (41)
- boost模板元编程 (43)
- Linux (77)
- 汇编 (4)
- 其它 (2)
- 烹饪 (3)
- unix c / socket (73)
- 软件工程 (4)
- shell (53)
- Python (37)
- c++ primer 5th(c++11) (22)
- 数据库/MySQL (27)
- 数据存储 (4)
- lisp (7)
- git (4)
- Utility (3)
- CDN与DNS (54)
- Http (53)
- php (7)
- nginx/lua/openresty (41)
- redis (11)
- TCP/IP (16)
- 互联网 (6)
- kernel (2)
- go (34)
- 区块链 (43)
- 比特股 (13)
- 以太坊 (23)
- 比特币 (23)
- 密码学 (10)
- EOS (53)
- DAG (1)
- docker (1)
- filecoin (7)
- solidity (65)
- ipfs (8)
- 零知识证明 (1)
- openzeppelin (3)
- java (1)
- defi (7)
- Ton (0)
最新评论
#include <eosiolib/eosio.hpp> class [[eosio::contract]] testcontract : public eosio::contract { public: testcontract( eosio::name receiver, eosio::name code, eosio::datastream<const char*> ds ) : eosio::contract(receiver, code, ds), _students(receiver, code.value) {} //添加学生 [[eosio::action]] void add(eosio::name user, std::string studentName,std::string studentGender,uint32_t studentAge,uint32_t studentHeight) { require_auth(user); eosio::print("Add student ", studentName); _students.emplace(get_self(), [&](auto& p) { p.id = _students.available_primary_key(); p.studentName = studentName; p.studentGender = studentGender; p.studentAge = studentAge; p.studentHeight = studentHeight; }); } //根据主键删除学生 [[eosio::action]] void del(eosio::name user, uint64_t id) { require_auth(user); eosio::print("Del student", id); auto itr = _students.find(id); if (itr != _students.end()) { _students.erase(itr); } } //根据主键修改学生 [[eosio::action]] void update(eosio::name user, uint64_t id,std::string studentName,std::string studentGender,uint32_t studentAge,uint32_t studentHeight) { require_auth(user); eosio::print("update student", studentName); auto itr = _students.find(id); if (itr != _students.end()) { _students.modify(itr, user, [&]( auto& p ) { p.studentName = studentName; p.studentGender = studentGender; p.studentAge = studentAge; p.studentHeight = studentHeight; }); } } //清空表,待定 [[eosio::action]] void clear(eosio::name user) { require_auth(user); std::vector<uint64_t> keysForDeletion; for(auto& item : _students) { keysForDeletion.push_back(item.id); } for (uint64_t key : keysForDeletion) { eosio::print("remove from _students ", key); auto itr = _students.find(key); if (itr != _students.end()) { _students.erase(itr); } } } //private: -- not private so the cleos get table call can see the table data. // create the multi index tables to store the data struct [[eosio::table]] students { uint64_t id; // primary key std::string studentName; std::string studentGender; uint32_t studentAge; uint32_t studentHeight; uint64_t primary_key() const { return id; } uint64_t by_age() const {return studentAge; } }; //数据表根据age排序 typedef eosio::multi_index<"students"_n, students, eosio::indexed_by<"studentage"_n, eosio::const_mem_fun<students, uint64_t, &students::by_age>>> studentstable; //students数据库表 studentstable _students; }; EOSIO_DISPATCH( testcontract, (add)(del)(update)(clear))
1.编译与部署合约
xjdeMacBook-Pro:testcontract xj$ eosio-cpp -o testcontract.wasm testcontract.cpp --abigen
Warning, empty ricardian clause file
Warning, empty ricardian clause file
Warning, action <add> does not have a ricardian contract
Warning, action <del> does not have a ricardian contract
Warning, action <update> does not have a ricardian contract
Warning, action <clear> does not have a ricardian contract
(reverse-i-search)`':
xjdeMacBook-Pro:testcontract xj$ cleos set contract testcontract /Users/xj/code/eos/build/programs/cleos/testcontract -p testcontract@active
Reading WASM from /Users/xj/code/eos/build/programs/cleos/testcontract/testcontract.wasm...
Skipping set code because the new code is the same as the existing code
Skipping set abi because the new abi is the same as the existing abi
no transaction is sent
2.添加数据
xjdeMacBook-Pro:testcontract xj$ cleos push action testcontract add '["testcontract","wangwu","male",11,120]' -p eosio@active
executed transaction: 4ea9886d0347e75028ef5f4d2180ceee2f5a8843783f30ee7fb3a473b3dc2039 120 bytes 1308 us
# testcontract <= testcontract::add {"s":"testcontract","studentName":"wangwu","studentGender":"male","studentAge":11,"studentHeight":12...
warning: transaction executed locally, but may not be confirmed by the network yet ]
3.查询
xjdeMacBook-Pro:testcontract xj$ cleos get table testcontract testcontract students
{
"rows": [{
"id": 0,
"studentName": "wangwu",
"studentGender": "male",
"studentAge": 11,
"studentHeight": 120
}
],
"more": false
}
4.修改
xjdeMacBook-Pro:testcontract xj$ cleos push action testcontract update '["testcontract",0,"wangwu","male",12,123]' -p eosio@active
executed transaction: b895a437c9c205d769cdb3746b861b5164591f4cec70bfb047d5e0472e21a18b 128 bytes 1198 us
# testcontract <= testcontract::update {"s":"testcontract","id":0,"studentName":"wangwu","studentGender":"male","studentAge":12,"studentHei...
warning: transaction executed locally, but may not be confirmed by the network yet ]
xjdeMacBook-Pro:testcontract xj$ cleos get table testcontract testcontract students
{
"rows": [{
"id": 0,
"studentName": "wangwu",
"studentGender": "male",
"studentAge": 12,
"studentHeight": 123
}
],
"more": false
}
5.删除
xjdeMacBook-Pro:testcontract xj$ cleos push action testcontract del '["testcontract",0]' -p eosio@active
executed transaction: f885c9e315a2d610fbeeefc887884c1e9b99ed21c1782bc1034eb67c6e3fda96 112 bytes 1172 us
# testcontract <= testcontract::del {"s":"testcontract","id":0}
warning: transaction executed locally, but may not be confirmed by the network yet ]
xjdeMacBook-Pro:testcontract xj$ cleos get table testcontract testcontract students
{
"rows": [],
"more": false
}
发表评论
-
eos快照
2019-10-06 08:31 383快照:为区块链提供临时 ... -
eos待确认/分叉库
2019-10-05 08:32 255fork_database:管理了轻量级状态数据,是由未确认的 ... -
eos controller概述
2019-10-03 17:28 294EOS中的模型层是blocks.log和基于chainbase ... -
eos multi_index
2019-10-03 09:01 283EOS的数据库就是chainbase,而调用数据库服务的C++ ... -
eos chainbase状态库
2019-10-01 08:03 435chainbase:是一个快速包含 ... -
eos action
2019-09-28 17:18 183action:在EOS中,action被分配到对应程序(一般是 ... -
eos事务结构
2019-09-28 16:34 396transaction_header:事务头的数据大小是固定的 ... -
eos区块头结构
2019-09-28 08:54 283block_header:区块头 struct block ... -
eos rpc set
2019-09-26 19:27 282set contract:设置合约 xjdeMacBook- ... -
eos rpc create
2019-09-26 19:18 2551.创建公私钥对 xjdeMacBook-Pro:safeco ... -
EOS blocks.log
2019-09-26 07:40 370区块数据通过blocks.log与blocks.index持久 ... -
引用区块
2019-09-25 07:26 311trx.set_reference_block(ref_blo ... -
EOS事务
2019-09-24 07:36 349调用函数add_standard_transaction_op ... -
全节点搭建
2019-09-22 09:34 2631.通过system regproducer命令可将普通账户注 ... -
eos名词解释
2019-09-14 09:34 6561.Authority:权力,要与Permission做好区分 ... -
智能合约依赖库
2019-08-29 07:32 366Action:这部分定义了查询或发送action的API.在E ... -
eos_rpc_system资源获取
2019-08-21 07:39 370资源主要有CPU,net bandwidt ... -
eos_rpc_sign
2019-08-21 07:22 244sign [OPTIONS] transaction:完成EO ... -
eos_rpc_wallet
2019-08-20 07:31 3191.wallet create [OPTIONS]:创建一个新 ... -
eos_rpc_get
2019-08-18 08:38 2921.get info:通过指定全节点API接口获取其连接的EO ...
相关推荐
1、一般来讲,对数据库的操作无外乎增删改查 2、表结构示例详解 3、Multi_index定义,建立数据表 4、实例化multi_index 5、操作数据,增删改查 #玩转table表 1、Table表producers 2、Table表global 3、...
EOS智能合约开发是一项涉及到区块链技术、合约编写和执行的技术,它允许开发者在EOS平台上创建和部署智能合约,为去中心化应用(DAPP)提供运行的基础。本文将详细探讨EOS智能合约开发的相关知识点。 首先,EOS智能...
EOS智能合约教程,从零开始学习EOS智能合约, DApp安全漏洞(security)及攻击实践(EOS Contract)
EOS智能合约详细开发教程。这是本人整理自币乎-松果的文章,这可能是当前最详细的EOS开发教程了吧,花了我一整天的时间进行整理,很全面,分享给有需要的朋友。
`eos-crypto-java_ecc_`这个项目显然关注的是在Java平台上实现ECC加密算法,特别是针对EOS区块链平台的加密需求。 在Java中,ECC的实现主要依赖于Java Cryptography Extension (JCE)框架,它是Java标准库的一部分,...
EOS-1D Mark III EOS 40D EOS-1Ds Mark III EOS DIGITAL REBEL Xsi/450D/ Kiss X2 EOS DIGITAL REBEL XS/ 1000D/ KISS F EOS 50D EOS 5D Mark II EOS Kiss X3/EOS REBEL T1i /EOS 500D EOS 7D EOS-1D Mark ...
【标题】"cpp-eos3dio和eosdayioEOS智能合约"涉及的是使用C++语言在EOS区块链平台上开发智能合约的技术。EOS是一个基于区块链技术的分布式应用操作系统,它旨在提供一个去中心化、高性能的环境来支持大规模的商业级...
本教程将通过深入解析"eos-tutorials-源码"来帮助你理解EOS的工作原理及其开发流程。 1. **EOS项目结构** EOS源码通常按照模块进行组织,包括共识机制、网络通信、智能合约、账户系统等。在"eos-tutorials-源码"中...
这是eos api开源项目eos4j-1.0.2.jar,下载完请解压,源码地址:https://github.com/espritblock/eos4j
通过“eos-py”,Python开发者能够轻松地与EOS网络进行交互,实现智能合约的部署、调用等操作。 首先,让我们解压“eos-py-1.0.1.tar.gz”这个文件。在Unix/Linux系统中,可以使用`tar -zxvf eos-py-1.0.1.tar.gz`...
基于EOS智能合约开发的区块链存证智能合约全部资料+详细文档.zip 【备注】 1、该项目是个人高分项目源码,已获导师指导认可通过,答辩评审分达到95分 2、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传...
因此,`eos-py`很可能是为开发者提供与EOS区块链交互的Python接口,包括账户管理、交易发送、智能合约部署等功能。 在实际使用中,开发者首先需要将`.tar.gz`文件解压缩,然后通过Python的`setup.py`脚本来安装这个...
python库,解压后可用。 资源全名:eos_py-0.14.0-cp36-cp36m-win_amd64.whl
### 普元EOS-Platform-7.0基础开发教程知识点详析 #### 一、产品概述 **1.1 产品简介** 普元EOS Platform 7.0是一款基于J2EE、Eclipse等开放技术和平台的产品,它通过配置化、组件化、图形化和一体化的方式,为...
01.01 快速开发:单表增删改查 01.01.01 页面效果 01.01.02 数据准备 01.01.03 创建数据模型 01.01.04 设置显示属性 01.01.05 增删改查一步完成 01.01.05.01 设置查询条件 01.01.05.02 选择目录并通过向导...
EOS智能合约与DApp开发入门实战教程:课程帮助你快速入门EOS区块链去中心化应用的开发,内容涵盖EOS工具链、账户与钱包、智能合约开发与部署、代币发行、使用代码与合约交互等核心知识点,并结合React完成一个便签...
生成EOS C ++智能合约以在区块链上创建表。 安装 通过以下方式全局安装: npm i -g eos-new-table 用法 选项 $ eos-new-table Generate EOS C++ smart contract to create a table on the blockchain. Options: -...
EOS Studio是一款EOS开发工具,它为开发者提供了图形化的界面来编写、部署和管理智能合约。其故障处理可能涉及界面显示、代码编译、合约部署等环节,需要检查工具配置、更新版本、修复网络连接或优化合约代码。 ...
(This document is common for All Cameras, EOS 5D Mark III, EOS 5D Mark II, EOS 6D, EOS 7D, EOS 60D, EOS 50D, EOS 40D, EOS-1Ds Mark III, EOS-1D Mark III, EOS-1D Mark IV, EOS M, EOS 1100D, EOS 1000D, ...