diff --git "a/2018-7-10 \344\273\245\345\244\252\345\235\212\345\270\270\347\224\250\346\234\257\350\257\255-\347\216\213\346\226\207\345\210\232.pdf" "b/2018-7-10 \344\273\245\345\244\252\345\235\212\345\270\270\347\224\250\346\234\257\350\257\255-\347\216\213\346\226\207\345\210\232.pdf" new file mode 100644 index 0000000..6eae873 Binary files /dev/null and "b/2018-7-10 \344\273\245\345\244\252\345\235\212\345\270\270\347\224\250\346\234\257\350\257\255-\347\216\213\346\226\207\345\210\232.pdf" differ diff --git "a/20180803 \345\214\272\345\235\227\351\223\276\347\231\275\347\232\256\344\271\246\345\210\206\344\272\253.ppt" "b/20180803 \345\214\272\345\235\227\351\223\276\347\231\275\347\232\256\344\271\246\345\210\206\344\272\253.ppt" new file mode 100644 index 0000000..0749f37 Binary files /dev/null and "b/20180803 \345\214\272\345\235\227\351\223\276\347\231\275\347\232\256\344\271\246\345\210\206\344\272\253.ppt" differ diff --git "a/CryptoZombies\346\270\270\346\210\217\345\255\246\344\271\240Solidity\347\254\224\350\256\260.md" "b/CryptoZombies\346\270\270\346\210\217\345\255\246\344\271\240Solidity\347\254\224\350\256\260.md" new file mode 100644 index 0000000..8f7f0bf --- /dev/null +++ "b/CryptoZombies\346\270\270\346\210\217\345\255\246\344\271\240Solidity\347\254\224\350\256\260.md" @@ -0,0 +1,160 @@ +作者:倔强的小红军 +注释:这是学习https://cryptozombies.io时的笔记 +1. 函数的写法 + ``` + function createZombies(string _str, uint _id) public pure returns(result){ + + } + ``` + returns后带括号写返回的参数名 + +2. 修饰符 +- public/private限定函数可以被所有人调用/只能在合约内部使用 +- internal/external限定函数函数可以被继承合约调用/只能从外部被调用 +- pure/view/留空可以限定函数不使用该DAPP的任何数据(不看也不写)/只查看该DAPP的数据保证不修改/可以修改合约数据 +- modifier修饰符,用于自定义其对函数的约束逻辑。在函数之前运行,常用来添加require检查是否满足限制条件,如下展示了自定义参数的modifier,其定义形式跟函数一样: + ``` + // 存储用户年龄的映射 + mapping (uint => uint) public age; + + // 限定用户年龄的修饰符 + modifier olderThan(uint _age, uint _userId) { + require(age[_userId] >= _age); + _; + } + + // 必须年满16周岁才允许开车 (至少在美国是这样的). + // 我们可以用如下参数调用`olderThan` 修饰符: + function driveCar(uint _userId) public olderThan(16, _userId) { //modifier后也要记得传递参数 + // 其余的程序逻辑 + } + ``` + modifier修饰符的最后一行为`_;`,表示修饰符调用结束后返回,并执行调用函数余下的部分。 一个常用的modifier叫onlyOwner,它能达到禁止第三方修改我们的合约的同时,留个后门给咱们自己去修改的目的。使用方法为先集成ownable合约。注意onlyOwner表明只能合约的作者调用,而合约的调用者不能调用该函数。 +- payable 一种可以接收以太的特殊函数。可以用于向一个合约要求支付一定的钱来运行一个函数。 + +# 第三章 高级Solidity编程 +这节介绍在以太坊上的DApp与其它程序真正的区别之处 +1. 在你把智能协议传上以太坊之后,它就变得不可更改, 这种永固性意味着你的代码永远不能被调整或更新。 +因此需要给可能需要修改的参数预留修改接口。 + +2. 两种存储方式 storage/memory,前者会写入区块链,后者只是临时变量 +默认的函数参数,包括返回的参数,是memory。 +默认的局部变量是一个指向storage的指针。 +状态变量,合约内声明的公有变量。是被分配了空间的storage型数据。 +memory与storage之间的赋值,具体请看[这里](http://me.tryblockchain.org/solidity-data-location.html) + + +3. 另一个使得Solidity编程语言与众不同的特征: + ``` + 用户想要每次执行你的 DApp 都需要支付一定的 gas(用以太币购买,因此,用户每次跑 DApp 都得花费以太币)。 + + ``` + 为什么要这样? + ``` + 用户想要每次执行你的 DApp 都需要支付一定的 gas(用以太币购买,因此,用户每次跑 DApp 都得花费以太币)。 + ``` + 节省`gas`的方法: + - 结构封装 (Struct packing) + uint即为uint256,另外还有uint32,uint64等, + 因为存储数据比做个运算贵得多,所以当 uint 定义在一个 struct 中的时候,尽量使用最小的整数子类型以节约空间。 并且把同样类型的变量放一起(即在 struct 中将把变量按照类型依次放置),这样 Solidity 可以将存储空间最小化。 + - 利用view函数节省gas + view 函数不会真正改变区块链上的任何数据——它们只是读取。 + 用 view 标记一个函数,意味着运行这个函数只需要查询你的本地以太坊节点,而不需要在区块链上创建一个事务(事务需要运行在每个节点上,因此花费 gas)。 + 因此在所能只读的函数上标记上表示“只读”的“external view 声明,就能为你的玩家减少在 DApp 中 gas 用量。 + - `storage`(存储)非常昂贵 + - 大多数编程语言中,遍历大数据集合都是昂贵的。但在 Solidity 中,使用一个标记了external view的函数,遍历比 storage 要便宜太多,因为 view 函数不会产生任何花销。 + - 在数组后面加上 memory关键字,表明这个数组是仅仅在内存中创建,不需要写入外部存储,并且在函数调用结束时它就解散了。如: + + ``` + uint[] memory values = new uint[](3); + + ``` + + - 其实就是将程序用到的数据范围严格限定,避免不必要的存储,以节约gas + + 在大多数编程语言中,遍历大数据集合都是昂贵的。但是在 Solidity 中,使用一个标记了external view的函数,遍历比 storage 要便宜太多,因为 view 函数不会产生任何花销。 (gas可是真金白银啊!)。 + + +4. Solidity中的时间 +unix时间戳,Solidity中还包含seconds,minutes,hours,days,weeks,years 等时间单位,分别会转换为相应的秒数存入uint中。 +now变量(uint256类型),固定返回当前时间 + +5. Solidity的继承,可以像传统一样定义is a关系,但好像还可以用于分割文件,避免一个文件中的逻辑过于复杂。 + ``` + contract cat is animal, creature{ + + } + ``` + +# 第五章 代币和交易 +1. #### 什么是代币? + 一个 代币 在以太坊基本上就是一个遵循一些共同规则的智能合约——即它实现了所有其他代币合约共享的一组标准函数,例如 transfer(address _to, uint256 _value) 和 balanceOf(address _owner). + 在智能合约内部,通常有一个映射, mapping(address => uint256) balances,用于追踪每个地址还有多少余额。 + 所以基本上一个代币只是一个追踪谁拥有多少该代币的合约,和一些可以让那些用户将他们的代币转移到其他地址的函数。 + #### 什么是ERC20? + ERC20事实上是一个标准,满足这个标准的代币就叫ERC20代币,他们共享具有相同名称的同一组函数,相互之间可以以相同的方式进行交互。 + 类似的标准还有ERC721等,它规定每个代币都被认为是唯一且不可分割的。只能以整个单位交易它们,并且每个单位都有唯一的 ID。 + 使用标准的优势在于:在我们的合约中不必再实现交易逻辑。并且其他人可以为加密可交易的ERC721资产搭建一个交易所平台 + +2. 库的使用 + ``` + import "./safemath.sol"; + + using SafeMath for uint256; // 这句写在contract中 + ``` + SafeMath库是OpenZeppelin建立的用来防止数据溢出的数学运算库,using可以自动把库的所有方法添加给某个数据类型,这样就不用每次都c = add(a,b)而可以简写成c = a.add(b)了。 + +3. 注释风格 + Solidity 社区所使用的一个标准是使用一种被称作 natspec 的格式,看起来像这样: + ``` + /// @title 一个简单的基础运算合约 + /// @author H4XF13LD MORRIS 💯💯😎💯💯 + /// @notice 现在,这个合约只添加一个乘法 + contract Math { + /// @notice 两个数相乘 + /// @param x 第一个 uint + /// @param y 第二个 uint + /// @return z (x * y) 的结果 + /// @dev 现在这个方法不检查溢出 + function multiply(uint x, uint y) returns (uint z) { + // 这只是个普通的注释,不会被 natspec 解释 + z = x * y; + } + } + ``` + @title(标题) 和 @author (作者)很直接了. + + @notice (须知)向 用户 解释这个方法或者合约是做什么的。 @dev (开发者) 是向开发者解释更多的细节。 + + @param (参数)和 @return (返回) 用来描述这个方法需要传入什么参数以及返回什么值。 + + 注意你并不需要每次都用上所有的标签,它们都是可选的。不过最少,写下一个 @dev 注释来解释每个方法是做什么的。 + +# 第六章 应用前端和 Web3.js +用以太坊基金发布的 JavaScript 库 —— Web3.js,来为 DApp 创建一个基本的前端界面,和智能合约交互。 + +1. 什么是web3.js + 以太坊网络是由节点组成的,每一个节点都包含了区块链的一份拷贝。当你想要调用一份智能合约的一个方法,你需要从其中一个节点中查找并告诉它: + - 智能合约的地址 + - 你想调用的方法,以及 + - 你想传入那个方法的参数 + + 以太坊节点只能识别一种叫做JSON-RPC的语言。这种语言直接读起来并不好懂。当你你想调用一个合约的方法的时候,需要发送的查询语句将会是这样的: + `{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from":"0xb60e8dd61c5d32be8058bb8eb970870f07233155","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","gas":"0x76c0","gasPrice":"0x9184e72a000","value":"0x9184e72a","data":"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"}],"id":1}` + web3.js是以太坊基金发布的 JavaScript 库,封装了查询语句,提供更易用的交互界面。 + Web3 Provider用来告诉我们的代码应该和哪个节点进行交互(就好比是传统的 Web 应用程序中为你的 API 调用设置远程 Web 服务器的网址) + 可以运行你自己的以太坊节点来作为 Provider,也可以用第三方的服务:[Infura](https://infura.io/)。它维护了很多以太坊节点并提供了一个缓存层来实现高速读取。用 Infura作为节点提供者,你可以不用自己运营节点就能很可靠地向以太坊发送、接收信息。 + MetaMask:浏览器中的身份(私钥)管理插件,让你在浏览器中访问DAPP,而不需要运行完整的以太坊代码。 + +2. 使用方法: + - Web3.js 需要两个东西来和你的合约对话: 它的 地址 和它的 ABI。 + > ABI(Application Binary Interface): 意为应用二进制接口,它是以 JSON 格式表示合约的方法,告诉 Web3.js 如何以合同理解的方式格式化函数调用。 + - Web3.js 有两个方法来调用我们合约的函数: call and send. + > call 用来调用 view 和 pure 函数。它只运行在本地节点,不会在区块链上创建事务。 + > send 将创建一个事务并改变区块链上的数据。你需要用 send 来调用任何非 view 或者 pure 的函数。 + + + + + + diff --git "a/IPFS\346\212\200\346\234\257\350\257\246\350\247\2431.pdf" "b/IPFS\346\212\200\346\234\257\350\257\246\350\247\2431.pdf" new file mode 100644 index 0000000..9f0e49f Binary files /dev/null and "b/IPFS\346\212\200\346\234\257\350\257\246\350\247\2431.pdf" differ diff --git "a/IPFS\346\212\200\346\234\257\350\257\246\350\247\2432.pdf" "b/IPFS\346\212\200\346\234\257\350\257\246\350\247\2432.pdf" new file mode 100644 index 0000000..e24fb52 Binary files /dev/null and "b/IPFS\346\212\200\346\234\257\350\257\246\350\247\2432.pdf" differ diff --git a/README.md b/README.md index d5b482b..9c35092 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,200 @@ ## 目标 目标:以输出的方式来加速学习 +## 加入我们 +- 抱团学习,一起学习共同输出,相互鼓励与扶持。 +- 技术布道者:要求,1. 对区块链技术有热情; 2. 对技术布道有热情; 3. 请参考1和2 +- 联系方式:bob@hiblock.net 、 微信:hiblocknet + ## 输出形式 输出形式多样: - 文章,如学习经验分享、心得、翻译等(不小于1000字) - 教程、课件(PPT)、视频、其他技术布道的输出 +## 20181125 +- 笔名辉哥 [【区块链技术工坊23期实录】郝振亚:工业互联网领域边缘计算与区块链实践](https://www.jianshu.com/p/1cb25f890f9b) +- AmyWu [Hyperledger Fabric构架简述之一 *再发布](https://www.jianshu.com/p/d0334265e33e) + + +## 20181118 +- 笔名辉哥 [【区块链技术工坊22期实录】王登辉:BANCOR算法详解及代码实现](https://www.jianshu.com/p/01877d787253) +- AmyWu [BCH简史](https://www.jianshu.com/p/0d5078c2b6f5) + +## 20181111 +- 笔名辉哥 [第二十九课 如何实现MetaMask签名授权后DAPP一键登录功能?](https://www.jianshu.com/p/8a0bd9bd487c) +- AmyWu [EOS和Ethereum的区别(中)](https://www.jianshu.com/p/d84a37b70497) + +## 20181104 +- 笔名辉哥 [第二十八课 区块链应用DAPP如何探测MetaMask的账号和登录状态?](https://www.jianshu.com/p/7d02202fa998) +- AmyWu [EOS和Ethereum的区别(上)](https://www.jianshu.com/p/39b0bec71c2f) + +## 20181028 +- 笔名辉哥 [IBO的金融原理和应用方向分析](https://www.jianshu.com/p/17c2151ff056) +- AmyWu [3分钟漫谈以太坊The DAO事件,浅入浅出区块链(4)](https://www.jianshu.com/p/d2e43f01c66d) + +## 20181021 +- 笔名辉哥 [【分析】最流行的3款DAPP浏览器和原理](https://www.jianshu.com/p/39e666ee2f2b) +- AmyWu [3分钟漫谈以太坊The DAO事件,浅入浅出区块链(3)](https://www.jianshu.com/p/5fe1da76340f) + +## 20181014 +- 笔名辉哥 [第二十七课 如何从BANCOR交易所兑换ENJIN通证](https://www.jianshu.com/p/617103393dc6) +- 笔名辉哥 [第二十六课 如何从零开始搭建一个Truffle框架的DAPP应用](https://www.jianshu.com/p/ecaa4dc22bef) +- AmyWu [3分钟漫谈以太坊The DAO事件,浅入浅出区块链(2)](https://www.jianshu.com/p/a6706b5bf7ff) + +## 20181007 +- OliviaZhang [Cryptozombie part 1](https://www.jianshu.com/p/4a66db75f3b0) +- 笔名辉哥 [第二十五课 如何开发自己的BANCOR去中心化交易平台?](https://www.jianshu.com/p/9fc78f8f5773) +- 笔名辉哥 [【ERC1400标准】支持证券增发,交易,相关法律文件存储的证券类同质化通证](https://www.jianshu.com/p/1e300a73eeef) +- 笔名辉哥 [肖风:未来三到五年内,一个去中心化的分布式AI平台或将出现](https://www.jianshu.com/p/a6ce20b61400) +- AmyWu [3分钟漫谈以太坊The DAO事件,浅入浅出区块链(1)](https://www.jianshu.com/p/8a396d2a92c1) + +## 20180930 +- OliviaZhang [Back to Basic On Smart Contract](https://www.jianshu.com/p/0ac8132d3312) +- 笔名辉哥 [【区块链实践】区块链+数字版权:“权利”的游戏](https://www.jianshu.com/p/411fcc5623fa) +- 笔名辉哥 [叶开:内容创作、知识版权、艺术品的Token内容模式](https://www.jianshu.com/p/90f35357e9e0) +- 笔名辉哥 [Fomo玩法加持的PixelMaster为什么火了?](https://www.jianshu.com/p/4aaeea70b4ce) +- 笔名辉哥 [【分析】比特大陆招股说明书解读[附pdf下载]](https://www.jianshu.com/p/c35847068075) +- 笔名辉哥 [【深度知识】以太坊第2层扩容方案:状态通道(State Channels)、Plasma 和 Truebit](https://www.jianshu.com/p/9b63bd712be8) +- 笔名辉哥 [【区块链实践】杭州互联网法院司法区块链解决方案](https://www.jianshu.com/p/ee1e3290338f) +- 笔名辉哥 [这30个以太坊开发示例,让你成为80万都挖不走的区块链人才!](https://www.jianshu.com/p/f5d557c62a66) +- AmyWu [通过小游戏学习Ethereum DApps编程(8)](https://www.jianshu.com/p/0fae5ff82ae4) +- AmyWu [精通以太坊 摘录+笔记(1)](https://www.jianshu.com/p/8777dc7ac064) +- AmyWu [精通比特币 摘录+笔记(1)](https://www.jianshu.com/p/c47013e62fff) + + +## 20180923 +- OliviaZhang [How to build your ERC20 token and launch an ICO](https://www.jianshu.com/p/5433ef1aeb34) +- 笔名辉哥 [第二十四课 基于以太坊的交易所BANCOR算法实现-转换算法框架](https://www.jianshu.com/p/875ba83002dc) +- 笔名辉哥 [【ERC1155实践】区块链游戏的平行宇宙和为此而生的Enjin钱包](https://www.jianshu.com/p/d558acbc8f65) +- 笔名辉哥 [【易错概念】Solidity语法的重载,继承的定义](https://www.jianshu.com/p/231ba1048ef5) +- 笔名辉哥 [【易错概念】Solidity语法的合约/抽象合约/接口/库的定义](https://www.jianshu.com/p/aa18346369cd) +- 笔名辉哥 [【易错概念】Solidity语法constant/view/pure关键字定义](https://www.jianshu.com/p/5f1bc0d39d79) +- AmyWu [通过小游戏学习Ethereum DApps编程(7)](https://www.jianshu.com/p/e0912339e842) + +## 20180916 +- OliviaZhang [ TruffleDapp_Metacoin](https://www.jianshu.com/p/6af41265a37b) +- 笔名辉哥 [【白皮书】Bancor协议:通过智能合约为加密货币提供持续流动性(附PDF下载)](https://www.jianshu.com/p/cbfb9abf8e07) +- 笔名辉哥 [【易错概念】以实例形式深入浅出讲透BANCOR算法](https://www.jianshu.com/p/fe48ed1f38cd) +- AmyWu [通过小游戏学习Ethereum DApps编程(6)](https://www.jianshu.com/p/3ef0914daba9) + + +## 20180908 +- 笔名辉哥 [第二十三课 如何部署TRUFFLE智能合约到以太坊主网(以宠物商店为例)](https://www.jianshu.com/p/d02381201033) +- AmyWu [通过小游戏学习Ethereum DApps编程(5)](https://www.jianshu.com/p/e5ed2d26587d) + +## 20180901 +- AmyWu [通过小游戏学习Ethereum DApps编程(4)](https://www.jianshu.com/p/ed9857d616f5) + +## 20180825 +- AmyWu [通过小游戏学习Ethereum DApps编程(3)](https://www.jianshu.com/p/c9300c8f285a) + +## 20180818 +- AmyWu [通过小游戏学习Ethereum DApps编程(2)](https://www.jianshu.com/p/3eaee42a5f63) +- 冯宇 [Hyperledger Explorer简介](https://www.jianshu.com/p/1709d6f50f5a) + +## 20180811 +- 王文刚 [简述智能合约--基于交付的项目](https://www.jianshu.com/p/1d099288a512) +- AmyWu [通过小游戏学习Ethereum DApps编程(1)](https://www.jianshu.com/p/05e6ca067838) +- 冯宇 [Hyperledger Cello简介](https://www.jianshu.com/p/afdf62088fe1) + +## 20180804 +- AmyWu [搭建你的第一个以太坊智能合约 (1)](https://www.jianshu.com/p/f96a518c46e8) +- 胡键 [区块链周周记:共识算法](https://www.jianshu.com/p/9ce900fb6f91) +- 王文刚 [区块链白皮书分享.ppt](https://github.com/xifarm/blockchain-learning/blob/develop/20180803%20%E5%8C%BA%E5%9D%97%E9%93%BE%E7%99%BD%E7%9A%AE%E4%B9%A6%E5%88%86%E4%BA%AB.ppt) +- 冯宇 [ERC20代币合约开发相关函数和事件](https://www.jianshu.com/p/a3a197ce9268) +- BoB [Upgradable smart contracts](./upgradable-smart-contract-step-by-step.md) + +## 20180728 +- AmyWu [Hyperledger Fabric的一次交易的旅程](https://www.jianshu.com/p/a5dc83988dbc) +- 胡键 [OpenZeppelin周记:打开地图](https://www.jianshu.com/p/3d09bbafd8f2) +- 冯宇 [理解ERC20代币合约](https://www.jianshu.com/p/c6c0256124fe) +- 王文刚 [众说区块链:区块链应用场景之Token](https://mp.weixin.qq.com/s?__biz=MzA5NDAxNzIzNg==&mid=2450005496&idx=1&sn=5a9251763e9a53d21f0796b749741dd8&chksm=87a9be43b0de37555b65487e587bde9f8a8052ad4199cfaed697c528728b2c605be0c93f4639&scene=38#wechat_redirect) + +## 20180721 +- AmyWu [如何使用Docker快速启动EOSIO环境](https://www.jianshu.com/p/7ea632fe1499) +- 王文刚 [智能合约内容分享.ppt](https://github.com/xifarm/blockchain-learning/blob/HiBlock-develop/%E6%99%BA%E8%83%BD%E5%90%88%E7%BA%A6%E5%86%85%E5%AE%B9%E5%88%86%E4%BA%AB.pptx) +- 冯宇 [从开发者的角度快速解读以太坊白皮书](https://www.jianshu.com/p/41ae276ae65e) +- BoB [如何发布和使用ERC875代币](https://github.com/HiBlock/non-fungible-token/blob/master/how-to-issue-erc875-nfts-cn.md) +- 冯学雷 [钱包](https://www.jianshu.com/p/bf5129b202be) + +## 20180714 +- 冯宇 [搭建以太坊测试链的简易教程](https://www.jianshu.com/p/904aaae80320) +- 王文刚 [2018-7-10 分享PPT 以太坊常用术语-王文刚](https://github.com/xifarm/blockchain-learning/blob/develop/2018-7-10%20%E4%BB%A5%E5%A4%AA%E5%9D%8A%E5%B8%B8%E7%94%A8%E6%9C%AF%E8%AF%AD-%E7%8E%8B%E6%96%87%E5%88%9A.pdf) +- 阿飞 [区块链-以太坊学习笔记(九)](https://blog.csdn.net/lxfgzm/article/details/81074144) +- 胡键 [面向老程序员的Solidity摘要](https://www.jianshu.com/p/ec5ad71e28aa) +- 冯学雷 [股票交易和数字货币交易对比](https://www.jianshu.com/p/312c15e11938) +- AmyWu [关于dApp的问与答](https://www.jianshu.com/p/25409b86da70) + +## 20180707 +- AmyWu [Hyperledger Fabric实践(3) 部署](https://www.jianshu.com/p/7181bc275316) +- 冯宇 [使用Jenkins对以太坊Dapp应用持续集成](https://www.jianshu.com/p/1dfcca96bb65) +- 胡键 [以太坊发币(ERC20)姿势解读](https://www.jianshu.com/p/d78353772029) +- BoB [以太坊的学习笔记](https://github.com/etherchina/ethereum) +- 王文刚 [常用MAC技巧---搭建以太坊私联过程经验](https://www.jianshu.com/p/0af88528c114) +- 冯学雷 [快速搭建以太坊私链](https://www.jianshu.com/p/d2d21ff15c89) +- 阿飞 [区块链-以太坊学习笔记(八)](https://blog.csdn.net/lxfgzm/article/details/80980392) +- 笔名辉哥 [第5课 EOS环境搭建入门(私链节点-钱包-密钥-账号)](https://www.jianshu.com/p/533f849489b1) + +## 20180630 +- BoB [关于Learning Blockchain Together](./learning-blockchain-together.md) +- 笔名辉哥 [第4课 如何在UBUNTU虚拟机上编译EOS完成环境搭建?](https://www.jianshu.com/p/55cd194eff7a) +- AmyWu [Hyperledger Fabric实践(2) 部署Hyperledger Composer理论](https://www.jianshu.com/p/4f3c5dbc5f67) +- 胡键 [以太坊开发极简入门](https://www.jianshu.com/p/bec173e6cf73) +- 冯宇[区块链跨链交易简介](https://www.jianshu.com/p/1540de9f370e) +- 阿飞 [区块链-以太坊学习笔记(七)](https://blog.csdn.net/lxfgzm/article/details/80879497) +- 王文刚 [简单谈谈区块链的事情](https://www.jianshu.com/p/c3120d546672) +- 冯学雷 [搭建以太坊客户端](https://www.jianshu.com/p/bf23baf3e358) + +## 20180623 +- BoB [Agile and Blockchain](./agile-and-blockchain.md) +- AmyWu [Hyperledger Fabric实践(1) 组建最简网络](https://www.jianshu.com/p/1b83cb9d9aa9) +- 阿飞 [区块链-以太坊学习笔记(六)](https://blog.csdn.net/lxfgzm/article/details/80796459) +- 胡键 HiBlock西安23号活动图文:[区块链周周记:兵器谱](https://www.jianshu.com/p/a10052a5bbd4) +- 冯宇:[Hyperledger学习小结](https://www.jianshu.com/p/8294e7f441d1) +- 笔名辉哥:[第十五课 手把手教你以太坊ENS域名注册,抢做一个3000万的发财梦!](https://www.jianshu.com/p/d4b951ff21b1) + +## 20180616 +- AmyWu [Hyperledger Fabric构架简述之二 节点](https://www.jianshu.com/p/8097a7dde804) +- 笔名辉哥 [第十二课 SOLIDITY语法难点解析及故障排查](https://www.jianshu.com/p/275ed3d7aeb7) +- 冯宇 [Hyperledger Composer开发流程](https://www.jianshu.com/p/43000b5ebd3d) +- 阿飞 [区块链-以太坊学习笔记(五)](https://blog.csdn.net/lxfgzm/article/details/80796382) +- 胡键 [区块链周周记:Token](https://www.jianshu.com/p/1a1c449f848c) +- BoB [ERC20 中文版](https://github.com/bobjiang/EIPs/blob/master/EIPS-CN/eip-20.md) + +## 20180609 +- BoB [How to issue ERC875 token](https://github.com/HiBlock/non-fungible-token/blob/master/how-to-issue-erc875-token.md) +- AmyWu [Hyperledger Fabric构架简述之一](https://www.jianshu.com/p/d0334265e33e) +- 阿飞 [区块链-以太坊学习笔记(四)](https://blog.csdn.net/lxfgzm/article/details/80646578) +- 冯宇 [Hyperledger Composer概念介绍](https://www.jianshu.com/p/ebb5f25bd3f7) +- 笔名辉哥[第十四课 以太坊开发从入门到精通学习导航](https://www.jianshu.com/p/6851fb958220) +- 胡键 [区块链周周记:一位初学者的观点](https://www.jianshu.com/p/5ffe26dfe369) + +## 20180602 +- 笔名辉哥 - [第十三课 如何在DAPP应用实现自带钱包转账功能](https://www.jianshu.com/p/139a71c0c497) +- 阿东 [怎样拥有硬件钱包?币博士手把手教你!](https://mp.weixin.qq.com/s/PFJDFqq4xQnhnhriORoisw) +- AmyWu [Hyperledger的Composer和Fabric到底是什么关系?](https://www.jianshu.com/p/15cc600b340f) +- 冯宇 [Linux环境下安装和使用Hyperledger Composer](https://www.jianshu.com/p/f20e3046c2a1) +- 胡键 [Hyperledger Fabric周周记:权限](https://www.jianshu.com/p/c502db96db15) +- 阿飞 [区块链-以太坊学习笔记(三)](https://blog.csdn.net/lxfgzm/article/details/80575346) +- BoB [以太坊入门ppt](https://github.com/HiBlock/blockchain-learning/blob/develop/blockchain2.0-ethereum-introduction.pptx) + +## 20180527 +- 胡键 [HyperLedger Fabric快速入门视频](https://m.qlchat.com/topic/details?topicId=2000001352286793) +- 冯宇 [Hyperledger Fabric网络手工运行](https://www.jianshu.com/p/9b6265ee6f4a) +- 笔名辉哥 - [第十一课 从宠物商店案例看DAPP架构和WEB3.JS交互接口](https://www.jianshu.com/p/47174718960b) +- BoB [如何筹办区块链的黑客马拉松](./how-to-hold-blockathon.pdf) +- 阿飞 [区块链-以太坊学习笔记(二)](https://blog.csdn.net/lxfgzm/article/details/80474443) +- 毛明旺 [风格指南(style guide)说明----solidity 语言中文文档](https://mp.weixin.qq.com/s/dL9Q7KGA2QramQG05NSYRQ) +- 毛明旺 [合约(Contracts)-- solidity语言中文文档](https://mp.weixin.qq.com/s/M-4fILUZ3AKcDVbsWiTcmw) + ## 20180520 +- 阿东 - [区块链走向何方,或许从美国证劵史可以得到答案](https://github.com/cdtakumi/HiBlock-learning/wiki/%E5%8C%BA%E5%9D%97%E9%93%BE%E8%B5%B0%E5%90%91%E4%BD%95%E6%96%B9%EF%BC%8C%E6%88%96%E8%AE%B8%E4%BB%8E%E7%BE%8E%E5%9B%BD%E8%AF%81%E5%8A%B5%E5%8F%B2%E5%8F%AF%E4%BB%A5%E5%BE%97%E5%88%B0%E7%AD%94%E6%A1%88) - 笔名辉哥 -[第十课 Solidity语言编辑器REMIX指导大全](https://www.jianshu.com/p/2110ed61d2cc) - BoB [Smart contract traveller guide](./smart-contract-traveller-guides.md) - +- 冯宇 [Hyperledger Fabric模型和工具介绍](https://www.jianshu.com/p/dbca08046432) +- 倔强的小红军 [CryptoZombies游戏学习Solidity笔记](./CryptoZombies游戏学习Solidity笔记.md) +- 胡键 [Hyperledger Fabric周周记:Composer](https://www.jianshu.com/p/9ff2cca70981) +- 阿飞 [区块链-以太坊学习笔记(一)](https://blog.csdn.net/lxfgzm/article/details/80399755) ## 20180513 - BoB - 以太坊实战之环境准备:[Youtube观看](https://www.youtube.com/playlist?list=PLnP6dU8KobC-QzHcbHFWIBmHwoxPqKq9p) | [CSDN观看](https://edu.csdn.net/course/detail/8078) - 胡键 - [Hyperledger Fabric周周记:起源](https://www.jianshu.com/p/267ac1f2d67d) @@ -26,7 +211,8 @@ 每周日进行整理,未完成输出,第一次警告,第二次直接清退 [输出进度](https://docs.google.com/spreadsheets/d/1192TcjGNVEhPl470y5y2Z3aZ9So0Imzucxbkm5Nxvn0/edit?usp=sharing) -## 社区需要你 -- 技术布道者:要求,1. 对区块链技术有热情; 2. 对技术布道有热情; 3. 请参考1和2 -- 联系方式:bob@hiblock.net -- 微信:hiblocknet +## 有关HiBlock区块链社区 + +- [HiBlock github首页](https://github.com/HiBlock) + +HiBlock 秉承开放、协作、透明、链接、分享的价值观,致力打造一个专注于区块链的开发者社区,我们不仅在开发者中宣传推广区块链,还会帮助开发者真正掌握区块链技术和应用。我们有线上活动(如一起译文档、一起学以太坊、一起学EOS等),有培训课程(提供专业的区块链技术培训 http://hiblock.net/topics/node16 )、也有线下沙龙聚会(全国各城进行线下交流),还有blockathon(链接全球区块链开发者)。详情参考:https://github.com/HiBlock/hiblock/tree/master/meetup diff --git a/agile-and-blockchain.md b/agile-and-blockchain.md new file mode 100644 index 0000000..b11dcdc --- /dev/null +++ b/agile-and-blockchain.md @@ -0,0 +1,98 @@ +# Agile and Blockchain + +## The origin + +Many say blockchain is just a decentralized ledger, it is true, but not the essential part for blockchain. I (BoB) as an experienced agile guru (Certified Scrum Trainer from [scrumalliance.org](http://scrumalliance.org/)), would anatomize blockchain with you together and compare agile and blockchain, and try to find the fundamental for both. + +In the beginning, let's start from the history to understand how they come. + +### what is agile + +In 2001, there are 17 software pioneers gathering in snowbird to discuss the light software development methods. Finally they conclude Agile Manifesto with agile principles as well. More details, see also [Agile Manifesto](http://agilemanifesto.org/). + +> We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value: +Individuals and interactions over processes and tools +Working software over comprehensive documentation +Customer collaboration over contract negotiation +Responding to change over following a plan +That is, while there is value in the items on the right, we value the items on the left more. + +### what is blockchain + +> A blockchain,[1][2][3] originally block chain,[4][5] is a continuously growing list of records, called blocks, which are linked and secured using cryptography.[1][6] Each block typically contains a cryptographic hash of the previous block,[6] a timestamp, and transaction data.[7] By design, a blockchain is resistant to modification of the data. It is "an open, distributed ledger that can record transactions between two parties efficiently and in a verifiable and permanent way".[8] For use as a distributed ledger, a blockchain is typically managed by a peer-to-peer network collectively adhering to a protocol for inter-node communication and validating new blocks. Once recorded, the data in any given block cannot be altered retroactively without alteration of all subsequent blocks, which requires consensus of the network majority. -- [Definition from wikipedia](https://en.wikipedia.org/wiki/Blockchain) + +In 2008, a person (not sure whether a man or woman, still secret now) published a whitepaper named *BitCoin: A peer-to-peer electronic cash system*. + +Blockchain technology is mentioned for the first time there. And as we know, the whitepaper is delivered in cryptopunker maillist first. + +## The same + +Agile and blockchain are 2 different concepts but they have several same points which are under the surface. They are: + +- Transparency +- Community +- Self organizing + +### Transparency (Trust) + +Agile as an experimental process is based on 3 pillars: + +- transparency +- inspect +- adapt + +For example, in agile, information radiator is well used in many teams, in order to visualize and make it transparent. So that it increases trust. ( I see, then I believe ) + +Blockchain's key charactoristics is Tamper-proof, which based on : + +- only add, no edit or delete +- public transaction information (each transaction recorded on chain, and could be queried) + +So for agile and blockchain, both are transparent, agile intends to visualize information, and blockchain intends to make transaction (core of blockchain) public. + +### Community + +From the history, we can see both are from community, agile is from face to face meetup to discuss, and blockchain is from a maillist dicussion. + +So community is a fundamental, but what is community, and why we need community. + +In blockchain area, many communities, but what I see is many people don't understand community, and abuse community. (E.g only for advertisement or promotion product/idea) + +Actually community is consensus, is a group people to have similar interest, is a group people who have similar belief. Based on that, community could exist, and live, but community is NOT for profit, is NOT for advertisement, is NOT for sales. + +### Self organizing + +Agile is organization design process, which is based on self organizing feature team ( in special for Scrum ). Empower people by simplifying/decreasing roles in org. + +Blockchain is decentralized, so that means in blockchain there is no central point, no one is authority. Everyone could join or exit blockchain freely. It's more like self organizing with economics considering. + +## The differency + +Although agile and blockchain have many same points at basis, both have differencies as well, let's take a look what are different. + +### People vs. Technology + +In agile, it is key to respect people, which means to empower and focus people in agile organization. But for blockchain, it focuses technology more. I am not saying people is not important in blockchain, but it is a bit more focus. + +### Offline vs. Online + +The most efficient and effective method of conveying information to and within a development team is face-to-face conversation. -- From Agile principles + +BLockchain field, it is decentralized, is open source, so most use cases are online collaborations. Such as github, slack, gitters, etc. Strangers start to gather with consensus, to work on one product (may be in github or gitlab). And then core developers could meet offline. + +So for blockchain, in the beginning, it should be online, but at last, it must be offline, back to agile principles. + +### Company vs. Community + +Agile is adopted by companies, specially by huge companies, it is because for huge companies they realized to adapt the change quickly to win the market, this is a core competency. So many agile gurus (like speakers, trainers) emerged, like me [BoB Jiang](http://bobjiang.com/). + +But for blockchain, it is community based from the scatch. Maybe just a few people have an idea, and have some codes in repository, some people gathered around the repository/idea, and provide more codes. + +In the future, there are at least 2 kinds of organizations, company based and community based. And there would be more and more community based organization arises. + + +## HiBlock community + +Last, but not least, [hiblock community](https://hiblock.one) focuses on blockchain technology, could provide services like technology training, consulting, smart contract auditing, organizing hackthon etc. + +If you have interest, please [Mail us](mailto:info@hiblock.one) . diff --git a/blockchain2.0-ethereum-introduction.pptx b/blockchain2.0-ethereum-introduction.pptx new file mode 100644 index 0000000..de89224 Binary files /dev/null and b/blockchain2.0-ethereum-introduction.pptx differ diff --git a/how-to-hold-blockathon.pdf b/how-to-hold-blockathon.pdf new file mode 100644 index 0000000..7624ecc Binary files /dev/null and b/how-to-hold-blockathon.pdf differ diff --git a/images/blockchain-learning-status.png b/images/blockchain-learning-status.png new file mode 100644 index 0000000..9f6fdeb Binary files /dev/null and b/images/blockchain-learning-status.png differ diff --git a/learning-blockchain-together.md b/learning-blockchain-together.md new file mode 100644 index 0000000..0fa1a2d --- /dev/null +++ b/learning-blockchain-together.md @@ -0,0 +1,43 @@ +# Learning blockchain together + +## What is the learning blockchain together + +Learning Blockchain together ([HiBlock区块链技术布道](https://github.com/HiBlock/blockchain-learning)),成立于2018年5月13日,是一个以输出的方式来加速区块链技术学习的小组。 + +我们的宗旨是:抱团学习,一起学习共同输出,相互鼓励与扶持。 + +### 现状 + +持续7周时间,10位来自不同地区的小伙伴累计输出文章等素材44篇。给大家点个赞! + +![](./images/blockchain-learning-status.png) + +## What can I get + +最好的学习就是教会别人,最好的学习是以目标为导向,不断思考不断输出的方式。 + +所以在这里,你不仅仅是写出自己的思想,还能结交一群同样喜欢思考的小伙伴。 + +## What can I do + +非常简单,拿起你的键盘,写下你对于区块链的思考与认识。每周一篇文章,固定节奏与频率,和小伙伴们一起! + +加入我们? 参考下面的如何加入小结。 + +## How to join + +- [github repo](https://github.com/HiBlock/blockchain-learning) +- 技术布道者:要求,1. 对区块链技术有热情; 2. 对技术布道有热情; 3. 请参考1和2 +- 联系方式:bob@hiblock.net 、 微信:hiblocknet + +## 关于 HiBlock 社区 + +HiBLock区块链社区秉承开放、协作、透明、链接、分享的价值观,致力打造一个专注于区块链的开发者社区,我们不仅在开发者中宣传推广区块链,还会帮助开发者真正掌握区块链技术和应用。 + +[HiBlock官网](https://hiblock.one/contact/) + +## HiBlock community + +Last, but not least, [hiblock community](https://hiblock.one) focuses on blockchain technology, could provide services like technology training, consulting, smart contract auditing, organizing hackthon etc. + +If you have interest, please [Mail us](mailto:info@hiblock.one) . diff --git "a/storj\346\212\200\346\234\257\350\257\246\350\247\243.pdf" "b/storj\346\212\200\346\234\257\350\257\246\350\247\243.pdf" new file mode 100644 index 0000000..ed20fc9 Binary files /dev/null and "b/storj\346\212\200\346\234\257\350\257\246\350\247\243.pdf" differ diff --git a/upgradable-smart-contract-step-by-step.md b/upgradable-smart-contract-step-by-step.md new file mode 100644 index 0000000..2d7be8c --- /dev/null +++ b/upgradable-smart-contract-step-by-step.md @@ -0,0 +1,196 @@ +# How to program an upgradable smart contract step by step + +## introduction + +As an information transform network, it is good for internet. And as we known [Agile](http://agilemanifesto.org/) and iteration is becoming popular in software development field. + +The good news for blockchain is that blockchain is design to [Tamper resistance](https://en.wikipedia.org/wiki/Tamper_resistance), but following is the bad news, it is hard to upgrade in blockchain field (e.g even we have found bugs in smart contract, it is hard to upgrade/fix it), which is preventing blockchain evolving. + +We would introduce a way to upgrade your smart contract with [ZepplinOS](https://zeppelinos.org/). + +## installation/preparation + +First of all, we need to setup/prepare environment. Here we need: + +- zos +- ganache-cli +- truffle + +### install zos + +We will use command line tool for ZeppelinOS `zos` : + +``` +$ npm install -g zos +``` + +### install truffle/ganache-cli + +Install truffle, you can refer the [truffle official website](https://truffleframework.com/docs/getting_started/installation). + +``` +$ npm install -g truffle +``` + +Install ganache-cli + +``` +$ npm install --save ganache-cli +``` + +## init project + +``` +$ mkdir zos-demo +$ cd zos-demo +$ npm init -y +$ zos init zos-demo +``` + +**Notice**: the zos.json file that was produced. This is the configuration file that makes zos aware of your smart contract architecture. Feel free to read up on the zos.json file format to understand how zos sees your project. + +``` +$ npm install --save zos-lib +``` + +## prepare smart contract in solidity + +In `contracts/` folder create a new file named `CounterContrat.sol` with following code: + +``` +pragma solidity ^0.4.21; +import "zos-lib/contracts/migrations/Migratable.sol"; +contract CounterContract is Migratable { + uint256 public counter; + function initialize(uint256 _counter) isInitializer("CounterContract", "0") public { + counter = _counter; + } + + function increment() public { + counter += 1; + } +} +``` + +For an upgradable contract, instead, replace constructor with an `initialize` function to set up the initial smart contract state. Make sure the `initialize` function with `isInitializer` modifer that take the name of your contract and version ID. + +**NOTE:** If you do use a constructor in an upgradeable smart contract, everything you set in the constructor will be ignored. + +### Test locally (start ganache-cli) + +Issue following command in a separate console: + +``` +$ npx ganache-cli --port 9545 +``` + +Then deploy smart contract to local network. (in another console) and add contract to zos and push it to local network. + +``` +$ zos add CounterContract +$ zos push --network local +``` + +**NOTE:** If encountering following failure, check your `hosts` file to make sure define `localhost` as '127.0.0.1' + +``` +Writing artifacts to ./build/contracts + +Could not connect to your Ethereum client. Please check that your Ethereum client: + - is running + - is accepting RPC connections (i.e., "--rpc" option is used in geth) + - is accessible over the network + - is properly configured in your Truffle configuration file (truffle.js) +``` + +Mostly it should treat `localhost` as '127.0.0.1', but sometime `hosts` file corrupts. + +You can edit `truffle-config.js` to change host to '127.0.0.1'. + +### invoke contract + +Next, we’ll create and initialize an upgradeable instance of CounterContract with zos. The `--args` option corresponds with the parameters of our initialize method. + +``` +$ zos create CounterContract --init initialize --args 42 --network local +``` +**Note:** the output line ‘CounterContract proxy:
’. This is the address you will use for CounterContract. Save this address, as it is the permanent address for CounterContract. As following: + +``` +Creating CounterContract proxy and calling initialize with: + - _counter (uint256): "42" + TX receipt received: 0x18746572bd744e231d8f0a9996a9afba8c2424e9c6329d1b7e71d429926b31d7 + CounterContract proxy: 0xfb011a654e7c39a19932ced52c04adec748ecdff +Successfully written zos.local.json +0xfb011a654e7c39a19932ced52c04adec748ecdff +``` + +Then we can test it in truffle console, launch truffle console by: + +``` +$ npm truffle console --network=local +``` + +We will see console with prefix `truffle(local)>`. And issue following command to set var: + +``` +truffle(local)> counterContract = CounterContract.at("0xfb011a654e7c39a19932ced52c04adec748ecdff") +truffle(local)> counterContract.increment() +truffle(local)> counterContract.counter().then(counter => counter.toNumber()) +truffle(local)> 43 + +``` + +## upgrade smart contracts + +**NOTE:** for upgradable smart contracts, only support to add varables/functions, must not remove codes from previous contracts. + +For example, we add a new function as following: + +``` +pragma solidity ^0.4.21; +import "zos-lib/contracts/migrations/Migratable.sol"; + +contract CounterContract is Migratable { + uint256 public counter; +mapping(uint256 => address) public history; + +function initialize(uint256 _counter) isInitializer("CounterContract", "0") public { + counter = _counter; + } + +function increment() public { + counter += 1; + history[counter] = msg.sender; + } + +function incrementByTwo() public { + counter += 2; + history[counter] = msg.sender; + } +} +``` + +### push and update contracts + +exit truffle console with command (.exit) + +``` +$ zos push --network local +$ zos update CounterContract --network local +$ npx truffle console --network=local +``` + +Entering truffle console, + +``` +truffle(local)> counterContract = CounterContract.at("0xfb011a654e7c39a19932ced52c04adec748ecdff") +truffle(local)> counterContract.incrementByTwo() +truffle(local)> counterContract.counter().then(counter => counter.toNumber()) +truffle(local)> 45 + +``` + +**NOTE:** If at any point you’ve stopped Ganache and need to restart this process all over, make sure you delete zos.local.json file as well. This isn’t a problem for other networks, since typically networks don’t get wiped out :) + +Edited from [ZeppelinOS Blog](https://blog.zeppelinos.org/getting-started-with-zeppelinos/) diff --git "a/\346\231\272\350\203\275\345\220\210\347\272\246\345\206\205\345\256\271\345\210\206\344\272\253.pptx" "b/\346\231\272\350\203\275\345\220\210\347\272\246\345\206\205\345\256\271\345\210\206\344\272\253.pptx" new file mode 100644 index 0000000..ac700f2 Binary files /dev/null and "b/\346\231\272\350\203\275\345\220\210\347\272\246\345\206\205\345\256\271\345\210\206\344\272\253.pptx" differ