随笔分类 -  solidity

摘要: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 阅读(1250) 评论(0) 推荐(0) 编辑
摘要:在Solidity中constant、view、pure三个函数修饰词的作用是告诉编译器,函数不改变/不读取状态变量,这样函数执行就可以不消耗gas了(是完全不消耗!),因为不需要矿工来验证。所以用好这几个关键词很重要,不言而喻,省gas就是省钱! 这三个关键词有什么区别和联系,简单来说,在Soli 阅读全文
posted @ 2018-03-19 21:16 huahuayu 阅读(7210) 评论(0) 推荐(0) 编辑
摘要:官方解释: 这个叫做fallback function,当有人 1. 只发送以太币给合约而不带任何输入数据;2. 调用smart contract时调起了一个不存在的方法。会触发执行这个方法。 What is the deal with “function () { ... }” inside So 阅读全文
posted @ 2018-03-19 15:44 huahuayu 阅读(377) 评论(0) 推荐(0) 编辑
摘要:Solidity没有print或console.log方法可以用来打印变量,这会给我们调试程序增加难度。 Solidity有event功能,可以在event中记录变量信息,通过调用event方法也可以实现打印功能,但不可能处处写event方法,麻烦。 以下代码实现了可重用的log方法,只要调用log 阅读全文
posted @ 2018-03-18 00:00 huahuayu 阅读(10277) 评论(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 阅读(290) 评论(0) 推荐(0) 编辑
摘要:Example地址:https://solidity.readthedocs.io/en/develop/solidity-by-example.html#voting Voting程序的功能: 这个智能合约实现了一种在区块链上公开投票的功能。 部署该智能合约的人称为chairperson(主席), 阅读全文
posted @ 2018-03-13 17:58 huahuayu 阅读(794) 评论(0) 推荐(0) 编辑
摘要:官方文档: https://solidity.readthedocs.io/en/develop/control-structures.html#error-handling-assert-require-revert-and-exceptions require和assert方法的区别: http 阅读全文
posted @ 2018-03-13 12:43 huahuayu 阅读(851) 评论(0) 推荐(0) 编辑
摘要:这篇文章很详细的列举了几种方式来开始solidity开发: https://medium.com/@davekaj/solidity-tips-and-tricks-for-beginners-building-their-first-dapp-on-ethereum-fed32d6a19ac 最快 阅读全文
posted @ 2018-03-11 12:11 huahuayu 阅读(830) 评论(0) 推荐(0) 编辑