摘要: 原文地址: https://ethereum.stackexchange.com/questions/19341/address-send-vs-address-transfer-best-practice-usage address.transfer() throws on failure for 阅读全文
posted @ 2018-03-26 11:53 huahuayu 阅读(3608) 评论(0) 推荐(0) 编辑
摘要: solidity mapping of mapping,两层映射,用的时候可以像二维数组一样去访问和修改值,非常方便。 以下代码示例中的这一句: mapping(string => mapping(uint => uint)) prices 相当于建立了一个price数据库表(只不过存在内存中),表 阅读全文
posted @ 2018-03-22 15:29 huahuayu 阅读(1189) 评论(0) 推荐(0) 编辑
摘要: 1. 股票数据: https://blog.quandl.com/api-for-stock-data iextrading.com www.nowapi.com 中文 2. 外汇数据: https://fixer.io/ 阅读全文
posted @ 2018-03-22 10:49 huahuayu 阅读(655) 评论(0) 推荐(0) 编辑
摘要: solidity 程序中如果用到oraclize query,api调用需要apikey,则最好加密apikey,否则公开solidity代码时会连同apikey一起公开。 加密方法: https://docs.oraclize.it/#ethereum-advanced-topics 阅读全文
posted @ 2018-03-21 20:20 huahuayu 阅读(385) 评论(0) 推荐(0) 编辑
摘要: 1 pragma solidity ^0.4.4; 2 3 contract Person { 4 5 string public name; 6 uint age; 7 uint private weight; 8 string internal birthday; 9 10 function Person() ... 阅读全文
posted @ 2018-03-20 18:38 huahuayu 阅读(1249) 评论(0) 推荐(0) 编辑
摘要: 在Solidity中constant、view、pure三个函数修饰词的作用是告诉编译器,函数不改变/不读取状态变量,这样函数执行就可以不消耗gas了(是完全不消耗!),因为不需要矿工来验证。所以用好这几个关键词很重要,不言而喻,省gas就是省钱! 这三个关键词有什么区别和联系,简单来说,在Soli 阅读全文
posted @ 2018-03-19 21:16 huahuayu 阅读(7185) 评论(0) 推荐(0) 编辑
摘要: 官方解释: 这个叫做fallback function,当有人 1. 只发送以太币给合约而不带任何输入数据;2. 调用smart contract时调起了一个不存在的方法。会触发执行这个方法。 What is the deal with “function () { ... }” inside So 阅读全文
posted @ 2018-03-19 15:44 huahuayu 阅读(374) 评论(0) 推荐(0) 编辑
摘要: Solidity没有print或console.log方法可以用来打印变量,这会给我们调试程序增加难度。 Solidity有event功能,可以在event中记录变量信息,通过调用event方法也可以实现打印功能,但不可能处处写event方法,麻烦。 以下代码实现了可重用的log方法,只要调用log 阅读全文
posted @ 2018-03-18 00:00 huahuayu 阅读(10230) 评论(9) 推荐(2) 编辑
摘要: 1. 查询transaction历史记录 https://forum.ethereum.org/discussion/2116/in-what-ways-can-storage-history-be-accessed 2. solidity开发测试建议流程 Before putting your c 阅读全文
posted @ 2018-03-16 23:26 huahuayu 阅读(289) 评论(0) 推荐(0) 编辑
摘要: Example地址:https://solidity.readthedocs.io/en/develop/solidity-by-example.html#voting Voting程序的功能: 这个智能合约实现了一种在区块链上公开投票的功能。 部署该智能合约的人称为chairperson(主席), 阅读全文
posted @ 2018-03-13 17:58 huahuayu 阅读(789) 评论(0) 推荐(0) 编辑