<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by 黎跃春 on Medium]]></title>
        <description><![CDATA[Stories by 黎跃春 on Medium]]></description>
        <link>https://medium.com/@liyuechun?source=rss-1af82e3a363d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*p-KMhPjIXRpZu4CBAtJe7g.png</url>
            <title>Stories by 黎跃春 on Medium</title>
            <link>https://medium.com/@liyuechun?source=rss-1af82e3a363d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 01:22:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@liyuechun/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[【Solidity智能合约开发第01篇】3分钟学会使用MetaMask钱包]]></title>
            <link>https://medium.com/@liyuechun/solidity%E6%99%BA%E8%83%BD%E5%90%88%E7%BA%A6%E5%BC%80%E5%8F%91%E7%AC%AC01%E7%AF%87-3%E5%88%86%E9%92%9F%E5%AD%A6%E4%BC%9A%E4%BD%BF%E7%94%A8metamask%E9%92%B1%E5%8C%85-bd9abaa5b9be?source=rss-1af82e3a363d------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd9abaa5b9be</guid>
            <dc:creator><![CDATA[黎跃春]]></dc:creator>
            <pubDate>Fri, 24 Dec 2021 11:06:46 GMT</pubDate>
            <atom:updated>2021-12-24T11:06:46.752Z</atom:updated>
            <content:encoded><![CDATA[<p>### 第一步、安装Chrome浏览器</p><p>请移步到：[<a href="https://www.google.com/intl/zh-CN/chrome/](https://www.google.com/intl/zh-CN/chrome/)">https://www.google.com/intl/zh-CN/chrome/](https://www.google.com/intl/zh-CN/chrome/)</a> 下载安装即可。</p><p>### 第二步、打开Chrome浏览器，打开 [chrome网上商店](<a href="https://chrome.google.com/webstore/category/extensions?hl=zh-CN">https://chrome.google.com/webstore/category/extensions?hl=zh-CN</a>) 链接，如下图所示</p><p>![](<a href="http://file.liyuechun.com/QQ20200530-111705%402x.png">http://file.liyuechun.com/QQ20200530-111705%402x.png</a>)</p><p>### 第三步、搜索框输入Metamask进行插件搜索,并将MetaMask添加到Chrome</p><p>![](<a href="http://file.liyuechun.com/QQ20200530-111838%402x.png">http://file.liyuechun.com/QQ20200530-111838%402x.png</a>)</p><p>### 第四步、添加成功后，会显示如下页面</p><p>![](<a href="https://file.liyuechun.com/WX20211224-152007%402x.png">https://file.liyuechun.com/WX20211224-152007%402x.png</a>)</p><p>### 第五步、点击开始使用,如果你已经有钱包的助记词或者私钥了，可以直接点击左边导入到钱包即可，这里我们直接点击右边创建钱包，创建一个新的钱包</p><p>![](<a href="http://file.liyuechun.com/QQ20200530-112335%402x.png">http://file.liyuechun.com/QQ20200530-112335%402x.png</a>)</p><p>#### ○ Next -👉`创建钱包`</p><p>![](<a href="https://file.liyuechun.com/WX20211224-152727%402x.png">https://file.liyuechun.com/WX20211224-152727%402x.png</a>)</p><p>#### Next -👉`I Agree`</p><p>![](<a href="http://file.liyuechun.com/QQ20200530-113001%402x.png">http://file.liyuechun.com/QQ20200530-113001%402x.png</a>)</p><p>#### ○ Next -👉创建</p><p>![](<a href="http://file.liyuechun.com/QQ20200530-113223%402x.png">http://file.liyuechun.com/QQ20200530-113223%402x.png</a>)</p><p>#### ○ Next -👉`下载私密备份密语并进行妥善保管，切记，禁止外泄，外泄将会导致你的代币被其他人盗走`</p><p>![](<a href="http://file.liyuechun.com/QQ20200530-113820%402x.png">http://file.liyuechun.com/QQ20200530-113820%402x.png</a>)</p><p>#### ○ Next -👉 这里按照备份的12个助记词的顺序依次选中填入上面的空白框中，如果顺序有错，将无法进行下一步</p><p>![](<a href="http://file.liyuechun.com/QQ20200530-114140%402x.png">http://file.liyuechun.com/QQ20200530-114140%402x.png</a>)</p><p>#### ○ Next — 👉 全部完成钱包创建完毕</p><p>![](<a href="https://file.liyuechun.com/WX20211224-172857%402x.png">https://file.liyuechun.com/WX20211224-172857%402x.png</a>)</p><p>### 第六步、如何显示和连接其他测试网络</p><p>刚创建好的钱包和以前版本有些区别，如下如所示，你并未看见测试网络。</p><p>![](<a href="https://file.liyuechun.com/WX20211224-170507@2x.png">https://file.liyuechun.com/WX20211224-170507@2x.png</a>)</p><p>点击设置以后，我们看到网络栏有相关的测试网络配置。</p><p>![](<a href="https://file.liyuechun.com/WX20211224-170603@2x.png">https://file.liyuechun.com/WX20211224-170603@2x.png</a>)</p><p>接下来切换到高级栏，打开显示测试网的开关。</p><p>![](<a href="https://file.liyuechun.com/WX20211224-173404@2x.png">https://file.liyuechun.com/WX20211224-173404@2x.png</a>)</p><p>![](<a href="https://file.liyuechun.com/WX20211224-173426@2x.png">https://file.liyuechun.com/WX20211224-173426@2x.png</a>)</p><p>接下来切换过来后，就可以看到所有网络了。</p><p>![](<a href="https://file.liyuechun.com/WX20211224-173622@2x.png">https://file.liyuechun.com/WX20211224-173622@2x.png</a>)</p><p>### 第七步、如何获取Kovan测试网测试币</p><p>1. 方法一：打开[<a href="https://gitter.im/kovan-testnet/faucet](https://gitter.im/kovan-testnet/faucet),">https://gitter.im/kovan-testnet/faucet](https://gitter.im/kovan-testnet/faucet),</a>输入你自己的钱包地址。<br>![](<a href="https://file.liyuechun.com/WX20211224-175259@2x.png">https://file.liyuechun.com/WX20211224-175259@2x.png</a>)</p><p>2. 方法二：打开[<a href="https://ethdrop.dev/](https://ethdrop.dev/)">https://ethdrop.dev/](https://ethdrop.dev/)</a>地址，输入钱包地址。<br>![](<a href="https://file.liyuechun.com/WX20211224-175403@2x.png">https://file.liyuechun.com/WX20211224-175403@2x.png</a>)</p><p>好了，MetaMask钱包的安装和使用咱就先到这里，后面的Solidity合约开发时，MetaMask会一直伴随我们的教程。祝工作愉快，THANKS！！！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd9abaa5b9be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[【以太坊钱包开发一】MyEtherWallet钱包开发项目概述]]></title>
            <link>https://medium.com/chaindesk/%E4%BB%A5%E5%A4%AA%E5%9D%8A%E9%92%B1%E5%8C%85%E5%BC%80%E5%8F%91%E4%B8%80-myetherwallet%E9%92%B1%E5%8C%85%E5%BC%80%E5%8F%91%E9%A1%B9%E7%9B%AE%E6%A6%82%E8%BF%B0-7cbdcb1c3ee5?source=rss-1af82e3a363d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cbdcb1c3ee5</guid>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <category><![CDATA[ethics]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[黎跃春]]></dc:creator>
            <pubDate>Wed, 17 Apr 2019 10:09:52 GMT</pubDate>
            <atom:updated>2019-04-17T10:09:52.695Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*WznuYwrvb4lq5rkAickAjQ.jpeg" /><figcaption>来源：百度</figcaption></figure><h3>项目介绍</h3><p>钱包种类非常多，主流的有以太坊钱包，比特币钱包，EOS钱包以及其他类型的虚拟货币钱包。在咱们这次课程中是来开发使用最频繁的钱包 - - 以太坊钱包，在博主主页也能找到比特币钱包，EOS钱包开发等钱包开发课程本课程“二十四小时玩转MyEtherWallet钱包开发”主要分为两大部分，第一部分（第一章〜第四章）：熟悉MyEtherWallet钱包以及搞清楚以太坊钱包理论;第二部分（第五章〜第十二章）：编码实现以太坊钱包项目。</p><p>以太坊作为一个广泛使用的区块链开发平台，包含的数字货币资产的转移和投资必然需要使用到钱包，因此钱包是区块链领域必需掌握的知识，另外也是交易所开发的核心。目前企业对钱包开发的需求较大，很少有成熟的钱包开发教程，因此特推出此教程满足企业与市场上对钱包的需求，以帮助大家快速全面的掌握以太坊钱包理论与开发实践。</p><p>本教程围绕以太坊钱包项目开发逐步进行讲解，该项目以的NodeJS语言编写后端，使用网络前端演示内容包含：视频，文档，源码。</p><h3>本教程能学到什么</h3><ul><li>彻底搞清楚账户系统中地址，密码，密钥存储私钥，助记词之间的关系</li><li>通过编码实现生成助记词与使用助记词解锁钱包账号</li><li>轻松上手与以太坊区块链交互的Web3.js库</li><li>连接到具有真实性的以太坊测试网络上开发钱包</li><li>调用的NodeJS令牌智能合约API</li><li>安全管理和转移你的令牌数字资产</li></ul><h3>主要用户群体</h3><ul><li>数字货币投资者</li><li>区块链学习者</li><li>钱包应用开发者</li><li>交易所开发者</li><li>转行做区块链开发的工程师</li></ul><h3>需要具备的技术</h3><ul><li>前端开发基础：HTML，JavaScript中，CSS语法</li><li>熟悉的NodeJS开发环境与IDE（本教程使用的是VSCode）</li><li>的NodeJS开发基础：熟悉兴亚框架等</li></ul><h3>教程大纲</h3><ol><li>项目概述</li><li>以太坊MyEtherWallet钱包功能演示</li><li>不得不说：钱包地址生成过程</li><li>密码，私钥，密钥存储与助记词之间的爱恨情仇</li><li>钱包项目整体架构设计</li><li>编码：生成账户的地址，私钥，密钥库，助记词</li><li>解锁钱包账号姿势一：私钥</li><li>解锁钱包账号姿势二：密钥库+密码</li><li>解锁钱包账号姿势三：助记词</li><li>浅出：如何实现以太币转账</li><li>深入：如何通过钱包集成第三方数字货币以及转账实现</li><li>游戏结束：总结</li></ol><h3>项目路线</h3><p>本次课程以MyEtherWallet网页钱包的重要功能作为开发需求，由此，项目的路线规划是：</p><ul><li>清晰MyEtherWallet的功能并掌握其用法</li><li>介绍以太坊钱包中涉及的重点理论知识</li><li>项目架构搭建：以的NodeJS开发后端，使用了兴亚与相关框架，前端以网络进行交互</li><li>使用web3.js与以太坊区块链进行交互一步步实现各个功能，其中只有助记词使用了其它技术实现</li></ul><p><strong>版权声明：博客中的文章版权归博主所有，未经授权禁止转载，转载请联系作者（微信：lixu1770105）取得同意并注明出处。</strong></p><p><strong>未经授权禁止转载，改编，转载请注明出处！</strong></p><p><strong>本文地址：</strong><a href="https://chaindesk.cn/witbook/1/1"><strong>https</strong></a><strong>：//chaindesk.cn/witbook/1/1</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cbdcb1c3ee5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chaindesk/%E4%BB%A5%E5%A4%AA%E5%9D%8A%E9%92%B1%E5%8C%85%E5%BC%80%E5%8F%91%E4%B8%80-myetherwallet%E9%92%B1%E5%8C%85%E5%BC%80%E5%8F%91%E9%A1%B9%E7%9B%AE%E6%A6%82%E8%BF%B0-7cbdcb1c3ee5">【以太坊钱包开发一】MyEtherWallet钱包开发项目概述</a> was originally published in <a href="https://medium.com/chaindesk">chengxuka</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[【EOS钱包开发 一】EOS不得不说的一些概念]]></title>
            <link>https://medium.com/chaindesk/eos%E9%92%B1%E5%8C%85%E5%BC%80%E5%8F%91-%E4%B8%80-eos%E4%B8%8D%E5%BE%97%E4%B8%8D%E8%AF%B4%E7%9A%84%E4%B8%80%E4%BA%9B%E6%A6%82%E5%BF%B5-f755a418fb66?source=rss-1af82e3a363d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f755a418fb66</guid>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[blockchain-startup]]></category>
            <category><![CDATA[eosio]]></category>
            <category><![CDATA[eos]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[黎跃春]]></dc:creator>
            <pubDate>Wed, 17 Apr 2019 10:02:21 GMT</pubDate>
            <atom:updated>2019-04-17T10:02:21.131Z</atom:updated>
            <content:encoded><![CDATA[<h4>EOS是什么</h4><p>EOS是Enterprise Operation System的缩写，它是商用分布式应用设计的一款区块链操作系统。EOS是引入的一种新的区块链架构EOSIO，用于实现分布式应用的性能扩展。EOS并不像比特币和以太坊那样是货币，而是基于EOSIO软件项目之上发布的代币，被称为区块链3.0。</p><h4>EOS的主要特点</h4><ul><li>EOS有点类似于微软的windows平台，通过创建一个对开发者友好的区块链底层平台，支持多个应用同时运行，为开发dAPP提供底层的模板。</li><li>EOS通过并行链和DPOS的方式解决了延迟和数据吞吐量的难题，EOS是每秒可以上千级别的处理量，而比特币每秒7笔左右，以太坊是每秒30–40笔。</li><li>EOS没有手续费，在EOS上开发dApp，需要用到的网络和计算资源是按照开发者拥有的EOS的比例分配的。当你拥有了EOS的话，就相当于拥有了计算机资源，随着DAPP的开发，你可以将手里的EOS租赁给别人使用。简单来说，就是你拥有了EOS，就相当于拥有了一套房租给别人收房租，或者说拥有了一块地租给别人建房。</li></ul><h4>EOSIO主要的程序</h4><ul><li>nodeos（node + eos = nodeos）：可以使用插件配置以运行节点的核心EOSIO节点守护进程。可以生成区块、节点验证、RPC API接口。</li><li>cleos （cli + eos = cleos）：是一个命令行工具，可以与nodeos公开的REST API进行交互并管理钱包。</li><li>keosd （key + eos = keosd）：是一个轻客户端钱包，负责管理钱包，以便在广播到网络之前保护密钥和签署交易，在本地计算机上运行并安全地将EOSIO密钥存储在钱包的组件中。</li><li>Eoscpp：是一个编译器，将C++代码编译为WASM和ABI。它生成.wasm、.abi的文件并上传到区块链。</li></ul><p>下图说明了这些组件之间的基本关系。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-pu2OvIz-z7oqgsP.png" /><figcaption>来源：chaindesk.cn</figcaption></figure><h4>EOS的账户体系</h4><p>EOS的账户体系是EOS中的亮点特性之一，实现了基于角色的权限管理和账户恢复功能，使得用户可以灵活地以一种组织化的方式管理账户，并极大程度上保证了资产的安全性。</p><p>EOS账户的特点：</p><ul><li>EOS中的账户名是12位可读标识符，由用户自定义，在区块链中唯一。它是转账时的标识，而其它区块链账的标识一般是地址。</li><li>EOS的一个账户下面可以包含多对公私钥，每对拥有不同的权限，而常见区块链项目的账户只有一对公私钥。</li><li>EOS中每个账户刚创建时一般由个体拥有，通过单一公私钥便能进行所有操作，后续可根据需要通过权限配置将该账户扩展成组织账户，由多对公私钥，即多个主体所共同控制，甚至可为组织外部个体或组织分配部分操作权限，从而实现极其灵活的组织管理方式。</li><li>EOS上的所有交易行为都是通过账户来完成的，通过账户执行任意操作时，EOSIO首先会验证操作者是否拥有足够的权限，验证通过该操作才能生效。</li></ul><h4>EOS账号的权限</h4><p>EOS中，每个账户创建时会自带两个原生权限：owner和active权限。这也是默认的账户权限配置，另外还支持自定义权限。</p><ul><li>owner权限：代表账户所有权，该权限可进行所有操作，包括更改owner权限，可由一对或多对EOS公私钥或另一账户的某权限实现权限控制。因此，代表着owner权限的EOS公私钥是最重要的，必须安全保管好。</li><li>active权限：active即活跃权限，能进行除更改owner权限以外的所有操作，比如说转账、投票、购买ram等等。也是通过一对或多对EOS公私钥或另一账户的某权限实现权限控制。</li><li>自定义权限：除了两个原生权限以外，EOS还支持自定义权限。我们可以将active的部分权限，比如说投票权，任命给一个自定义权限voting。那么无须owner、active权限所对应的私钥对投票操作进行签名，单单通过voting权限所对应的私钥对投票操作进行签名便可完成投票操作。</li></ul><p>因此通过权限配置可以将EOS账户的部分操作权限分配给第三方进行，避免了直接给出active权限的私钥，从而实现极其灵活和安全的组织管理方式。</p><h4>权重和阈值</h4><p>每个权限都会有一个阀值，初始时为1。权限下的每对公私钥都会有一个权重，初始时每个权限只有一对公私钥且权重为1。后续账户可以修改权限的阀值，可以对每个主体（即每对EOS公私钥或账号）分配不同的权重，还可以修改权限由多个主体管理。只有当公私钥的权重大于等于阀值才能拥有该权限进行相应操作。</p><p>常见区块链项目的币就放在公钥里，只有一对公私钥，因此知道私钥便可转走，而EOS中币是放在账户里的，公钥里面放的是带权重的钥匙，转走账户里面的币需要拥有转账权限的钥匙的权重之和达到阈值才可进行。</p><h4>创建账号与转账的费用</h4><p>EOS主网中，账号的创建需要保存在EOS主网中，需要占用区块链生产节点的内存资源，一般为4K大小。而内存资源是有限的宝贵资源，因此创建账号是要成本的，一般需要花费6美元。而内存价格和EOS价格是随市场变动的，因此EOS主网账户注册价格也是变动的。因此每创建一个EOS新账号都需要其他EOS账号消耗一定量的EOS来帮忙创建，最初始的EOS账号由EOS主网在映射阶段创建完成。</p><p>而账户进行转账等操作时，是没有手续费的，但是需要用到EOS主网的CPU和带宽资源。CPU就像会计的算账能力，带宽则可理解成转账的通道，这个需要通过EOS抵押才能换取，但是不会产生消耗，不用了可以赎回。</p><h4>EOS的资源利用机制</h4><p>我们知道，比特币和以太坊中的交易手续费机制，其目的就是防止大量交易使系统拥堵。而EOS取消了交易手续费，那么如何避免系统资源的滥用？因而EOS设计了一种新的资源使用机制：根据账户中EOS的数量来分配系统资源，包括：RAM(内存), Network BandWidth (网络带宽) 以及 CPU BandWidth (CPU 带宽）。这些资源需要购买吗？如何交易？接着往下看。</p><p>RAM(内存)：</p><p>在 EOS 中, RAM(内存)的主要特点包括：</p><ul><li>要将数据存储在区块链中需要消耗RAM，比如在 EOS 中转账、购买资源、投票等操作的时候，都有可能会消耗 RAM (内存)。</li><li>如果你的 RAM 消耗殆尽，那么你是无法进行上述这些需要消耗RAM的操作的，所以我们需要有足够的RAM。</li><li>通过购买获得的 EOS RAM 资源可以买卖，买卖的价格根据市场行情动态调节，这个特点与买卖EOS一样。</li><li>RAM可以通过EOS购买的方式获得也可以通过好友帮你购买，这个特点和通过抵押方式获取 CPU 资源以及 NET 资源不太一样。</li><li>用户在买卖 RAM 资源的时候，各需要消耗 0.5 % (千分之五) 的手续费，总共是 1% 的手续费。这笔费用被存在 eosio.ramfee 中，由 BP 节点进行管理。</li><li>内存是消耗资源，不可赎回，只能买卖。</li></ul><p>CPU带宽与网络带宽</p><p>在EOS中，CPU带宽与网络带宽的特性差不多，它们的主要特点包括：</p><ul><li>它们采用抵押EOS的方式获取。当不再需要CPU与带宽时，抵押的EOS通证可以赎回，在赎回的时候，存在三天的赎回期。</li><li>如果你持有全网1%的EOS，那就可以抵押这些EOS来获得全网1%的CPU和带宽。这样就可以隔离开所有的DAPP，防止资源竞争和恶意的DDOS供给，无论其他的DAPP如何拥堵， 你自己的带宽都不受影响。</li><li>每次使用转账功能时，都会消耗网络带宽资源。</li><li>网络带宽取决于过去三天消费的平均值，作为你下一次执行操作的费率。</li><li>如果没有足够的网络带宽资源的话，你是无法使用 EOS 网络转账等基本功能的。</li><li>带宽资源是可以随着时间的推移，自动释放。</li></ul><p><strong>版权声明：博客中的文章版权归博主所有，未经授权禁止转载，转载请联系作者（微信：lixu1770105）取得同意并注明出处。</strong></p><p><strong>未经授权禁止转载、改编，转载请注明出处！</strong></p><p><strong>本文地址: </strong><a href="https://chaindesk.cn/witbook/2/18"><strong>https://chaindesk.cn/witbook/2/18</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f755a418fb66" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chaindesk/eos%E9%92%B1%E5%8C%85%E5%BC%80%E5%8F%91-%E4%B8%80-eos%E4%B8%8D%E5%BE%97%E4%B8%8D%E8%AF%B4%E7%9A%84%E4%B8%80%E4%BA%9B%E6%A6%82%E5%BF%B5-f755a418fb66">【EOS钱包开发 一】EOS不得不说的一些概念</a> was originally published in <a href="https://medium.com/chaindesk">chengxuka</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （下篇）-ipfs + Ethereum 大图片存储]]></title>
            <link>https://medium.com/chaindesk/ipfs-%E5%8C%BA%E5%9D%97%E9%93%BE-%E7%B3%BB%E5%88%97-%E5%85%A5%E9%97%A8%E7%AF%87-ipfs-ethereum-%E4%B8%8B%E7%AF%87-ipfs-ethereum-%E5%A4%A7%E5%9B%BE%E7%89%87%E5%AD%98%E5%82%A8-ea228631e660?source=rss-1af82e3a363d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea228631e660</guid>
            <category><![CDATA[ipfs-tutorial]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ipfs]]></category>
            <dc:creator><![CDATA[黎跃春]]></dc:creator>
            <pubDate>Wed, 17 Apr 2019 09:28:41 GMT</pubDate>
            <atom:updated>2019-04-17T09:28:41.766Z</atom:updated>
            <content:encoded><![CDATA[<h3>【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （下篇）-ipfs + Ethereum 大图片存储</h3><h3>目录</h3><ul><li><a href="https://chaindesk.cn/witbook/12/143#1-%E7%B3%BB%E5%88%97%E6%96%87%E7%AB%A0">1. 系列文章</a></li><li><a href="https://chaindesk.cn/witbook/12/143#2-%E9%A1%B9%E7%9B%AE%E6%8F%8F%E8%BF%B0%E5%8F%8A%E6%95%88%E6%9E%9C%E5%B1%95%E7%A4%BA">2. 项目描述及效果展示</a></li><li><a href="https://chaindesk.cn/witbook/12/143#3-%E9%98%85%E8%AF%BB%E6%9C%AC%E6%96%87%E9%9C%80%E8%A6%81%E6%8E%8C%E6%8F%A1%E7%9A%84%E7%9F%A5%E8%AF%86">3. 阅读本文需要掌握的知识</a></li><li><a href="https://chaindesk.cn/witbook/12/143#4-%E6%BA%90%E7%A0%81">4. 源码</a></li><li><a href="https://chaindesk.cn/witbook/12/143#5-%E8%BF%90%E8%A1%8C%E7%A8%8B%E5%BA%8F">5. 运行程序</a></li><li><a href="https://chaindesk.cn/witbook/12/143#6-%E6%8A%80%E6%9C%AF%E4%BA%A4%E6%B5%81">6. 技术交流</a></li></ul><h3>1. 系列文章</h3><ul><li><a href="http://www.chaindesk.cn/witbook/12/139">【IPFS + 区块链 系列】 入门篇 — IPFS环境配置</a></li><li><a href="http://www.chaindesk.cn/witbook/12/140">【IPFS + 区块链 系列】 入门篇 — IPFS+IPNS+个人博客搭建</a></li><li><a href="http://www.chaindesk.cn/witbook/12/141">【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （上篇）-js-ipfs-api — 数据上传到IPFS</a></li><li><a href="http://www.chaindesk.cn/witbook/12/142">【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （中篇）-js-ipfs-api — 图片上传到IPFS以及下载</a></li></ul><h3>2. 项目描述及效果展示</h3><p>这篇文章通过truffle unbox react创建项目，安装ipfs-api，将图片存储到ipfs，将图片hash存储到Ethereum区块链，取数据时先从区块链读取图片hash，再通过hash从ipfs读取数据，解决了区块链大数据存储成本高昂的问题。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*M94sEVNY7Zd901FG.gif" /><figcaption>来源：chaindesk.cn</figcaption></figure><h3>3. 阅读本文需要掌握的知识</h3><p>阅读本文需要将先学习上面的系列文章，由于本文前端使用了大量的React语法，所以建议学习一些<a href="http://edu.csdn.net/course/play/4749">React语法</a>，还需要学习<a href="http://truffleframework.com/">truffle framework</a>。</p><h3>4. 源码</h3><p>其实这篇文章的内容就是上面几篇文章的综合结合体，所以在这里我将不再对代码做过多的概述。</p><pre><strong>import</strong> React, {Component} <strong>from</strong> &#39;react&#39;<br><strong>import</strong> SimpleStorageContract <strong>from</strong> &#39;../build/contracts/SimpleStorage.json&#39;<br><strong>import</strong> getWeb3 <strong>from</strong> &#39;./utils/getWeb3&#39;</pre><pre><strong>import</strong> &#39;./css/oswald.css&#39;<br><strong>import</strong> &#39;./css/open-sans.css&#39;<br><strong>import</strong> &#39;./css/pure-min.css&#39;<br><strong>import</strong> &#39;./App.css&#39;</pre><pre>const ipfsAPI = require(&#39;ipfs-api&#39;);<br>const ipfs = ipfsAPI({host: &#39;localhost&#39;, port: &#39;5001&#39;, protocol: &#39;http&#39;});</pre><pre>const contract = require(&#39;truffle-contract&#39;)<br>const simpleStorage = contract(SimpleStorageContract)<br>let account;</pre><pre>// Declaring <strong>this</strong> <strong>for</strong> later so we can chain functions on SimpleStorage.<br>let contractInstance;</pre><pre>let saveImageOnIpfs = (reader) =&gt; {<br>  <strong>return</strong> <strong>new</strong> Promise(function(resolve, reject) {<br>    const buffer = Buffer.<strong>from</strong>(reader.result);<br>    ipfs.add(buffer).<strong>then</strong>((response) =&gt; {<br>      console.log(response)<br>      resolve(response[0].hash);<br>    }).<strong>catch</strong>((err) =&gt; {<br>      console.error(err)<br>      reject(err);<br>    })<br>  })<br>}</pre><pre><strong>class</strong> <strong>App</strong> <strong>extends</strong> <strong>Component</strong> {<br>  constructor(props) {<br>    <strong>super</strong>(props)</pre><pre>    <strong>this</strong>.state = {<br>      blockChainHash: null,<br>      web3: null,<br>      address: null,<br>      imgHash: null,<br>      isWriteSuccess: false<br>    }<br>  }</pre><pre>  componentWillMount() {</pre><pre>    ipfs.swarm.peers(function(err, res) {<br>      <strong>if</strong> (err) {<br>        console.error(err);<br>      } <strong>else</strong> {<br>        // var numPeers = res.Peers === null ? 0 : res.Peers.length;<br>        // console.log(&quot;IPFS - connected to &quot; + numPeers + &quot; peers&quot;);<br>        console.log(res);<br>      }<br>    });</pre><pre>    getWeb3.<strong>then</strong>(results =&gt; {<br>      <strong>this</strong>.setState({web3: results.web3})</pre><pre>      // Instantiate contract once web3 provided.<br>      <strong>this</strong>.instantiateContract()<br>    }).<strong>catch</strong>(() =&gt; {<br>      console.log(&#39;Error finding web3.&#39;)<br>    })<br>  }</pre><pre>  <strong>instantiateContract</strong> = () =&gt; {</pre><pre>    simpleStorage.setProvider(<strong>this</strong>.state.web3.currentProvider);<br>    <strong>this</strong>.state.web3.eth.getAccounts((error, accounts) =&gt; {<br>      account = accounts[0];<br>      simpleStorage.at(&#39;0x66e9bbfe244799149a9c4eb708a34ea7c9ce67e2&#39;).<strong>then</strong>((contract) =&gt; {<br>        console.log(contract.address);<br>        contractInstance = contract;<br>        <strong>this</strong>.setState({address: contractInstance.address});<br>        <strong>return</strong>;<br>      });<br>    })</pre><pre>  }<br>  render() {<br>    <strong>return</strong> (&lt;div className=&quot;App&quot;&gt;<br>      {<br>        <strong>this</strong>.state.address<br>          ? &lt;h1&gt;合约地址：{<strong>this</strong>.state.address}&lt;/h1&gt;<br>          : &lt;div/&gt;<br>      }<br>      &lt;h2&gt;上传图片到IPFS：&lt;/h2&gt;<br>      &lt;div&gt;<br>        &lt;label id=&quot;file&quot;&gt;Choose file to upload&lt;/label&gt;<br>        &lt;input type=&quot;file&quot; ref=&quot;file&quot; id=&quot;file&quot; name=&quot;file&quot; multiple=&quot;multiple&quot;/&gt;<br>      &lt;/div&gt;<br>      &lt;div&gt;<br>        &lt;button onClick={() =&gt; {<br>            var file = <strong>this</strong>.refs.file.files[0];<br>            var reader = <strong>new</strong> FileReader();<br>            // reader.readAsDataURL(file);<br>            reader.readAsArrayBuffer(file)<br>            reader.onloadend = function(e) {<br>              console.log(reader);<br>              saveImageOnIpfs(reader).<strong>then</strong>((hash) =&gt; {<br>                console.log(hash);<br>                <strong>this</strong>.setState({imgHash: hash})<br>              });</pre><pre>            }.bind(<strong>this</strong>);</pre><pre>          }}&gt;将图片上传到IPFS并返回图片HASH&lt;/button&gt;<br>      &lt;/div&gt;<br>      {<br>        <strong>this</strong>.state.imgHash<br>          ? &lt;div&gt;<br>              &lt;h2&gt;imgHash：{<strong>this</strong>.state.imgHash}&lt;/h2&gt;<br>              &lt;button onClick={() =&gt; {<br>                  contractInstance.set(<strong>this</strong>.state.imgHash, {from: account}).<strong>then</strong>(() =&gt; {<br>                    console.log(&#39;图片的hash已经写入到区块链！&#39;);<br>                    <strong>this</strong>.setState({isWriteSuccess: true});<br>                  })<br>                }}&gt;将图片hash写到区块链：contractInstance.set(imgHash)&lt;/button&gt;<br>            &lt;/div&gt;<br>          : &lt;div/&gt;<br>      }<br>      {<br>        <strong>this</strong>.state.isWriteSuccess<br>          ? &lt;div&gt;<br>              &lt;h1&gt;图片的hash已经写入到区块链！&lt;/h1&gt;<br>              &lt;button onClick={() =&gt; {<br>                  contractInstance.get({from: account}).<strong>then</strong>((data) =&gt; {<br>                    console.log(data);<br>                    <strong>this</strong>.setState({blockChainHash: data});<br>                  })<br>                }}&gt;从区块链读取图片hash：contractInstance.get()&lt;/button&gt;<br>            &lt;/div&gt;<br>          : &lt;div/&gt;<br>      }<br>      {<br>        <strong>this</strong>.state.blockChainHash<br>          ? &lt;div&gt;<br>              &lt;h3&gt;从区块链读取到的hash值：{<strong>this</strong>.state.blockChainHash}&lt;/h3&gt;<br>            &lt;/div&gt;<br>          : &lt;div/&gt;<br>      }<br>      {<br>        <strong>this</strong>.state.blockChainHash<br>          ? &lt;div&gt;<br>              &lt;h2&gt;浏览器访问：{&quot;http://localhost:8080/ipfs/&quot; + <strong>this</strong>.state.imgHash}&lt;/h2&gt;<br>              &lt;img alt=&quot;&quot; style={{<br>                  width: 1600<br>                }} src={&quot;http://localhost:8080/ipfs/&quot; + <strong>this</strong>.state.imgHash}/&gt;<br>            &lt;/div&gt;<br>          : &lt;img alt=&quot;&quot;/&gt;<br>      }<br>    &lt;/div&gt;);<br>  }<br>}</pre><pre><strong>export</strong> <strong>default</strong> App</pre><h3>5. 运行程序</h3><ul><li>项目下载</li></ul><pre><strong>$</strong> git clone https://github.com/liyuechun/IPFS-Ethereum-Image.git<br><strong>$</strong> cd IPFS-Ethereum-Image<br><strong>$</strong> npm install</pre><ul><li>运行程序</li></ul><pre>$ ipfs daemon <em>// 终端一</em><br>$ npm start   <em>// 终端二</em></pre><p><strong>未经授权禁止转载、改编，转载请注明出处！</strong></p><p><strong>本文地址: </strong><a href="https://chaindesk.cn/witbook/12/143"><strong>https://chaindesk.cn/witbook/12/143</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea228631e660" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chaindesk/ipfs-%E5%8C%BA%E5%9D%97%E9%93%BE-%E7%B3%BB%E5%88%97-%E5%85%A5%E9%97%A8%E7%AF%87-ipfs-ethereum-%E4%B8%8B%E7%AF%87-ipfs-ethereum-%E5%A4%A7%E5%9B%BE%E7%89%87%E5%AD%98%E5%82%A8-ea228631e660">【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （下篇）-ipfs + Ethereum 大图片存储</a> was originally published in <a href="https://medium.com/chaindesk">chengxuka</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （中篇）-js-ipfs-api — IPFS图片上传与下载]]></title>
            <link>https://medium.com/chaindesk/ipfs-%E5%8C%BA%E5%9D%97%E9%93%BE-%E7%B3%BB%E5%88%97-%E5%85%A5%E9%97%A8%E7%AF%87-ipfs-ethereum-%E4%B8%AD%E7%AF%87-js-ipfs-api-ipfs%E5%9B%BE%E7%89%87%E4%B8%8A%E4%BC%A0%E4%B8%8E%E4%B8%8B%E8%BD%BD-cd64a5dc3e54?source=rss-1af82e3a363d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd64a5dc3e54</guid>
            <category><![CDATA[ipfs-tutorial]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <dc:creator><![CDATA[黎跃春]]></dc:creator>
            <pubDate>Wed, 17 Apr 2019 09:21:20 GMT</pubDate>
            <atom:updated>2019-04-17T09:21:20.639Z</atom:updated>
            <content:encoded><![CDATA[<h3>【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （中篇）-js-ipfs-api — IPFS图片上传与下载</h3><h3>目录</h3><ul><li><a href="https://chaindesk.cn/witbook/12/142#1-%E9%A1%B9%E7%9B%AE%E6%95%88%E6%9E%9C%E5%9B%BE">1. 项目效果图</a></li><li><a href="https://chaindesk.cn/witbook/12/142#2-%E5%88%9B%E5%BB%BA-React-%E9%A1%B9%E7%9B%AE">2. 创建React项目</a></li><li><a href="https://chaindesk.cn/witbook/12/142#3-%E5%AE%8C%E6%88%90-UI-%E9%80%BB%E8%BE%91">3. 完成UI逻辑</a></li><li><a href="https://chaindesk.cn/witbook/12/142#4-%E5%AE%89%E8%A3%85-ipfs-api">4. 安装ipfs-api</a></li><li><a href="https://chaindesk.cn/witbook/12/142#5-App-.-js-%E5%AF%BC%E5%85%A5-IPFS-">5. App.js导入IPFS</a></li><li><a href="https://chaindesk.cn/witbook/12/142#6-%E5%AE%9E%E7%8E%B0%E4%B8%8A%E4%BC%A0%E5%9B%BE%E7%89%87%E5%88%B0-IPFS-%E7%9A%84-Promise-%E5%87%BD%E6%95%B0">6. 实现上传图片到IPFS的Promise函数</a></li><li><a href="https://chaindesk.cn/witbook/12/142#7-%E4%B8%8A%E4%BC%A0%E5%9B%BE%E7%89%87%E5%88%B0-IPFS">7. 上传图片到IPFS</a></li><li><a href="https://chaindesk.cn/witbook/12/142#8-%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81">8. 完整代码</a></li><li><a href="https://chaindesk.cn/witbook/12/142#9-%E8%BF%90%E8%A1%8C%E9%A1%B9%E7%9B%AE">9. 运行项目</a></li><li><a href="https://chaindesk.cn/witbook/12/142#10-%E6%80%BB%E7%BB%93">10. 总结</a></li><li><a href="https://chaindesk.cn/witbook/12/142#11-%E6%8A%80%E6%9C%AF%E4%BA%A4%E6%B5%81">11. 技术交流</a></li></ul><h3>系列文章</h3><ul><li><a href="http://www.chaindesk.cn/witbook/12/139">【IPFS + 区块链 系列】 入门篇 — IPFS环境配置</a></li><li><a href="http://www.chaindesk.cn/witbook/12/140">【IPFS + 区块链 系列】 入门篇 — IPFS+IPNS+个人博客搭建</a></li><li><a href="http://www.chaindesk.cn/witbook/12/141">【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （上篇）-js-ipfs-api — 数据上传到IPFS</a></li></ul><h3>1. 项目效果图</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OZmmPfnW3YZ3yDcQ.gif" /><figcaption>来源：chaindesk.cn</figcaption></figure><p>选择图片，点击Submit将图片提交到IPFS，并且返回IPFS的HASH值，再通过HASH从IPFS读取图片。</p><h3>2. 创建React项目</h3><p>具体不知道怎么操作的，请移步到<a href="http://liyuechun.org/2017/11/22/ipfs-api/">【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （上篇）-js-ipfs-api</a>。</p><pre>$ create-react-app ipfs_img</pre><h3>3. 完成UI逻辑</h3><p>将下面的代码拷贝替换掉App.js里面的代码。</p><pre><strong>import</strong> <strong>React</strong>, {<strong>Component</strong>} from &#39;react&#39;</pre><pre><strong>class</strong> <strong>App</strong> <strong>extends</strong> <strong>Component</strong> {<br>  constructor(props) {<br>    <strong>super</strong>(props)</pre><pre>    <strong>this</strong>.state = {<br>      imgSrc: null<br>    }<br>  }<br></pre><pre>  render() {<br>    <strong>return</strong> (&lt;div className=&quot;App&quot;&gt;</pre><pre>      &lt;h2&gt;上传图片到<strong>IPFS</strong>：&lt;/h2&gt;<br>      &lt;div&gt;<br>        &lt;label id=&quot;file&quot;&gt;<strong>Choose</strong> file to upload&lt;/label&gt;<br>        &lt;input <strong>type</strong>=&quot;file&quot; ref=&quot;file&quot; id=&quot;file&quot; name=&quot;file&quot; multiple=&quot;multiple&quot;/&gt;<br>      &lt;/div&gt;<br>      &lt;div&gt;<br>        &lt;button onClick={() =&gt; {<br>            <strong>var</strong> file = <strong>this</strong>.refs.file.files[0];<br>            <strong>var</strong> reader = <strong>new</strong> <strong>FileReader</strong>();<br>            <em>// reader.readAsDataURL(file);</em><br>            reader.readAsArrayBuffer(file)<br>            reader.onloadend = (e) =&gt; {<br>              console.log(reader);<br>              <em>// 上传数据到IPFS</em><br>            }</pre><pre>          }}&gt;<strong>Submit</strong>&lt;/button&gt;<br>      &lt;/div&gt;<br>      {<br>        <strong>this</strong>.state.imgSrc<br>          ? &lt;div&gt;<br>              &lt;h2&gt;{&quot;http://localhost:8080/ipfs/&quot; + <strong>this</strong>.state.imgSrc}&lt;/h2&gt;<br>              &lt;img alt=&quot;区块链部落&quot; style={{<br>                  width: 1600<br>                }} src={&quot;http://localhost:8080/ipfs/&quot; + <strong>this</strong>.state.imgSrc}/&gt;<br>            &lt;/div&gt;<br>          : &lt;img alt=&quot;&quot;/&gt;<br>      }<br>    &lt;/div&gt;);<br>  }<br>}</pre><pre>export <strong>default</strong> <strong>App</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ivhDaeOQzhd3pBDz.gif" /><figcaption>来源：chaindesk.cn</figcaption></figure><h3>4. 安装ipfs-api</h3><pre>localhost:1126 yuechunli$ cd ipfs_img/<br>localhost:ipfs_img yuechunli$ ls<br>README.md    package.json    src<br>node_modules    public        yarn.lock<br>localhost:ipfs_img yuechunli$ npm install --save-dev ipfs-api</pre><h3>5. App.js导入IPFS</h3><pre><strong>const ipfsAPI</strong> = require(&#39;ipfs-api&#39;);<br><strong>const ipfs</strong> = ipfsAPI({host: &#39;localhost&#39;, port: &#39;5001&#39;, protocol: &#39;http&#39;});</pre><h3>6. 实现上传图片到IPFS的Promise函数</h3><pre>let saveImageOnIpfs = (reader) =&gt; {<br>  <strong>return</strong> <strong>new</strong> Promise(function(resolve, reject) {<br>    const buffer = Buffer.<strong>from</strong>(reader.result);<br>    ipfs.add(buffer).<strong>then</strong>((response) =&gt; {<br>      console.log(response)<br>      resolve(response[0].hash);<br>    }).<strong>catch</strong>((err) =&gt; {<br>      console.error(err)<br>      reject(err);<br>    })<br>  })<br>}</pre><h3>7. 上传图片到IPFS</h3><pre><strong>var</strong> file = <strong>this</strong>.refs.file.files[0];<br><strong>var</strong> reader = <strong>new</strong> FileReader();<br><em>// reader.readAsDataURL(file);</em><br>reader.readAsArrayBuffer(file)<br>reader.onloadend = <strong>function</strong>(e) {<br>  console.log(reader);<br>  saveImageOnIpfs(reader).then((hash) =&gt; {<br>    console.log(hash);<br>    <strong>this</strong>.setState({imgSrc: hash})<br>  });<br>}</pre><ul><li>reader.readAsDataURL(file);上传图片路径。</li><li>reader.readAsArrayBuffer(file)上传图片内容</li><li>上传图片</li></ul><pre>saveImageOnIpfs(reader).<strong>then</strong>((hash) =&gt; {<br>    console.log(hash);<br>    <strong>this</strong>.setState({imgSrc: hash})<br>  });</pre><p>hash即是上传到IPFS的图片的HASH地址，this.setState({imgSrc: hash})将hash保存到状态机变量imgSrc中。</p><h3>8. 完整代码</h3><pre><strong>import</strong> React, {Component} <strong>from</strong> &#39;react&#39;</pre><pre>const ipfsAPI = require(&#39;ipfs-api&#39;);<br>const ipfs = ipfsAPI({host: &#39;localhost&#39;, port: &#39;5001&#39;, protocol: &#39;http&#39;});</pre><pre>let saveImageOnIpfs = (reader) =&gt; {<br>  <strong>return</strong> <strong>new</strong> Promise(function(resolve, reject) {<br>    const buffer = Buffer.<strong>from</strong>(reader.result);<br>    ipfs.add(buffer).<strong>then</strong>((response) =&gt; {<br>      console.log(response)<br>      resolve(response[0].hash);<br>    }).<strong>catch</strong>((err) =&gt; {<br>      console.error(err)<br>      reject(err);<br>    })<br>  })<br>}</pre><pre><strong>class</strong> <strong>App</strong> <strong>extends</strong> <strong>Component</strong> {<br>  constructor(props) {<br>    <strong>super</strong>(props)</pre><pre>    <strong>this</strong>.state = {<br>      imgSrc: null<br>    }<br>  }</pre><pre>  render() {<br>    <strong>return</strong> (&lt;div className=&quot;App&quot;&gt;</pre><pre>      &lt;h2&gt;上传图片到IPFS：&lt;/h2&gt;<br>      &lt;div&gt;<br>        &lt;label id=&quot;file&quot;&gt;Choose file to upload&lt;/label&gt;<br>        &lt;input type=&quot;file&quot; ref=&quot;file&quot; id=&quot;file&quot; name=&quot;file&quot; multiple=&quot;multiple&quot;/&gt;<br>      &lt;/div&gt;<br>      &lt;div&gt;<br>        &lt;button onClick={() =&gt; {<br>            var file = <strong>this</strong>.refs.file.files[0];<br>            var reader = <strong>new</strong> FileReader();<br>            // reader.readAsDataURL(file);<br>            reader.readAsArrayBuffer(file)<br>            reader.onloadend = (e) =&gt; {<br>              console.log(reader);<br>              // 上传数据到IPFS<br>              saveImageOnIpfs(reader).<strong>then</strong>((hash) =&gt; {<br>                console.log(hash);<br>                <strong>this</strong>.setState({imgSrc: hash})<br>              });<br>            }</pre><pre>          }}&gt;Submit&lt;/button&gt;<br>      &lt;/div&gt;<br>      {<br>        <strong>this</strong>.state.imgSrc<br>          ? &lt;div&gt;<br>              &lt;h2&gt;{&quot;http://localhost:8080/ipfs/&quot; + <strong>this</strong>.state.imgSrc}&lt;/h2&gt;<br>              &lt;img alt=&quot;区块链部落&quot; style={{<br>                  width: 1600<br>                }} src={&quot;http://localhost:8080/ipfs/&quot; + <strong>this</strong>.state.imgSrc}/&gt;<br>            &lt;/div&gt;<br>          : &lt;img alt=&quot;&quot;/&gt;<br>      }<br>    &lt;/div&gt;);<br>  }<br>}</pre><pre><strong>export</strong> <strong>default</strong> App</pre><h3>9. 运行项目</h3><ul><li>npm start</li><li>新建终端，启动节点服务ipfs daemon</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r01GViEEZ3IK83D8.gif" /><figcaption>来源：chaindesk.cn</figcaption></figure><h3>10. 总结</h3><p>这本文章主要复习如何创建React项目，如何安装ipfs-api，如何编写上传图片到IPFS的Promise函数，下一篇我们将介绍，如何将图片hash存储到区块链，如何从区块链取到hash，并且通过hash从ipfs拿到图片。</p><p><strong>未经授权禁止转载、改编，转载请注明出处！</strong></p><p><strong>本文地址: </strong><a href="https://chaindesk.cn/witbook/12/142"><strong>https://chaindesk.cn/witbook/12/142</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd64a5dc3e54" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chaindesk/ipfs-%E5%8C%BA%E5%9D%97%E9%93%BE-%E7%B3%BB%E5%88%97-%E5%85%A5%E9%97%A8%E7%AF%87-ipfs-ethereum-%E4%B8%AD%E7%AF%87-js-ipfs-api-ipfs%E5%9B%BE%E7%89%87%E4%B8%8A%E4%BC%A0%E4%B8%8E%E4%B8%8B%E8%BD%BD-cd64a5dc3e54">【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （中篇）-js-ipfs-api — IPFS图片上传与下载</a> was originally published in <a href="https://medium.com/chaindesk">chengxuka</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （上篇）-js-ipfs-api]]></title>
            <link>https://medium.com/chaindesk/ipfs-%E5%8C%BA%E5%9D%97%E9%93%BE-%E7%B3%BB%E5%88%97-%E5%85%A5%E9%97%A8%E7%AF%87-ipfs-ethereum-%E4%B8%8A%E7%AF%87-js-ipfs-api-ad95fc100626?source=rss-1af82e3a363d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad95fc100626</guid>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[ipfs-tutorial]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ipfs]]></category>
            <dc:creator><![CDATA[黎跃春]]></dc:creator>
            <pubDate>Wed, 17 Apr 2019 08:47:20 GMT</pubDate>
            <atom:updated>2019-04-17T08:47:20.161Z</atom:updated>
            <content:encoded><![CDATA[<h3>【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （上篇）-js-ipfs-api</h3><h3>目录</h3><ul><li><a href="https://chaindesk.cn/witbook/12/141#1-%E5%86%85%E5%AE%B9%E7%AE%80%E4%BB%8B">1. 内容简介</a></li><li><a href="https://chaindesk.cn/witbook/12/141#2-IPFS-HTTP%E6%95%88%E6%9E%9C%E5%9B%BE">2. IPFS-HTTP效果图</a></li><li><a href="https://chaindesk.cn/witbook/12/141#3-%E5%AE%9E%E7%8E%B0%E6%AD%A5%E9%AA%A4">3. 实现步骤</a></li><li><a href="https://chaindesk.cn/witbook/12/141#31-%E5%AE%89%E8%A3%85create-react-app">3.1 安装create-react-app</a></li><li><a href="https://chaindesk.cn/witbook/12/141#32-React%E9%A1%B9%E7%9B%AE%E5%88%9B%E5%BB%BA">3.2 React项目创建</a></li><li><a href="https://chaindesk.cn/witbook/12/141#33-%E8%BF%90%E8%A1%8CReact%E9%A1%B9%E7%9B%AE">3.3 运行React项目</a></li><li><a href="https://chaindesk.cn/witbook/12/141#34-%E6%B5%8F%E8%A7%88%E9%A1%B9%E7%9B%AE">3.4 浏览项目</a></li><li><a href="https://chaindesk.cn/witbook/12/141#35-%E5%AE%89%E8%A3%85%60ipfs-api%60">3.5 安装</a><a href="https://chaindesk.cn/witbook/12/141#35-%E5%AE%89%E8%A3%85%60ipfs-api%60">ipfs-api</a></li><li><a href="https://chaindesk.cn/witbook/12/141#36-%E5%AE%8C%E6%88%90UI%E9%80%BB%E8%BE%91">3.6 完成UI逻辑</a></li><li><a href="https://chaindesk.cn/witbook/12/141#37-%E5%AF%BC%E5%85%A5IPFS">3.7 导入IPFS</a></li><li><a href="https://chaindesk.cn/witbook/12/141#38-%E7%BC%96%E5%86%99%E4%B8%8A%E4%BC%A0%E5%A4%A7%E6%96%87%E6%9C%AC%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%88%B0IPFS%E7%9A%84Promise%E5%87%BD%E6%95%B0">3.8 编写上传大文本字符串到IPFS的Promise函数</a></li><li><a href="https://chaindesk.cn/witbook/12/141#39-%E4%B8%8A%E4%BC%A0%E6%95%B0%E6%8D%AE%E5%88%B0IPFS">3.9 上传数据到IPFS</a></li><li><a href="https://chaindesk.cn/witbook/12/141#310-%E8%B7%A8%E5%9F%9F%E8%B5%84%E6%BA%90%E5%85%B1%E4%BA%ABCORS%E9%85%8D%E7%BD%AE">3.10 跨域资源共享CORS配置</a></li><li><a href="https://chaindesk.cn/witbook/12/141#311-%E5%86%8D%E6%AC%A1%E5%88%B7%E6%96%B0%E7%BD%91%E9%A1%B5%E6%8F%90%E4%BA%A4%E6%95%B0%E6%8D%AE%E5%B9%B6%E5%9C%A8%E7%BA%BF%E6%9F%A5%E7%9C%8B%E6%95%B0%E6%8D%AE">3.11 再次刷新网页提交数据并在线查看数据</a></li><li><a href="https://chaindesk.cn/witbook/12/141#312-%E4%BB%8EIPFS%E8%AF%BB%E5%8F%96%E6%95%B0%E6%8D%AE">3.12 从IPFS读取数据</a></li><li><a href="https://chaindesk.cn/witbook/12/141#313-%E6%80%BB%E7%BB%93">3.13 总结</a></li><li><a href="https://chaindesk.cn/witbook/12/141#4-%E4%B8%8B%E7%AF%87%E6%96%87%E7%AB%A0%E9%A2%84%E5%91%8A">4. 下篇文章预告</a></li></ul><h3>1. 内容简介</h3><ul><li><a href="http://www.chaindesk.cn/witbook/12/139">【IPFS + 区块链 系列】 入门篇 — IPFS环境配置</a></li><li><a href="http://www.chaindesk.cn/witbook/12/140">【IPFS + 区块链 系列】 入门篇 — IPFS+IPNS+个人博客搭建</a></li></ul><p>在前面两篇文章中，第一篇春哥给大家详细介绍了IPFS环境配置，第二篇介绍了IPFS如何搭建个人博客，通过这两篇文章相信大家已经对IPFS有所了解，接下来的这篇文章，我们将为大家讲解js-ipfs-api的简单使用，如何将数据上传到IPFS，以及如何从IPFS通过HASH读取数据。</p><h3>2. IPFS-HTTP效果图</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*76HuoibTKiPIj7Lh.gif" /></figure><h3>3. 实现步骤</h3><h3>3.1 安装create-react-app</h3><p><strong>参考文档：</strong><a href="https://reactjs.org/tutorial/tutorial.html">https://reactjs.org/tutorial/tutorial.html</a></p><pre>localhost:1123 yuechunli$ npm install -g create-react-app</pre><h3>3.2 React项目创建</h3><pre>localhost:1123 yuechunli$ create-react-app ipfs-http-demo<br>localhost:ipfs-http-demo yuechunli$ ls<br>README.md    package.json    src<br>node_modules    public        yarn.lock<br>localhost:ipfs-http-demo yuechunli$</pre><h3>3.3 运行React项目</h3><pre>localhost:ipfs-<strong>http</strong>-demo yuechunli$ npm start</pre><pre>Compiled successfully!</pre><pre>You can now view ipfs-<strong>http</strong>-demo <strong>in</strong> <strong>the</strong> browser.</pre><pre>  Local:            <strong>http</strong>://localhost:3000/<br>  On Your Network:  <strong>http</strong>://192.168.0.107:3000/</pre><pre>Note that <strong>the</strong> development build is <strong>not</strong> optimized.<br>To create <strong>a</strong> production build, use yarn build.</pre><h3>3.4 浏览项目</h3><p>浏览器浏览http://localhost:3000。</p><p>效果如下：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YqAnNz46Hnz2uufG.png" /></figure><h3>3.5 安装ipfs-api</h3><p><strong>⚠️：在这里我就不过多的去介绍React的使用以及开发，如果感兴趣的可以去看</strong><a href="http://edu.csdn.net/course/play/4749"><strong>这套React的视频</strong></a><strong>，学完这套视频你可以直接进企业找React相关的前端开发工作。</strong></p><ul><li>项目结构</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nV3UBsJNj-BliLTE.png" /></figure><ul><li>安装ipfs-api</li></ul><p>切换到项目根目录，安装ipfs-api。</p><pre>$ npm <strong>install</strong> <em>--save ipfs-api</em></pre><pre>localhost:ipfs-http-demo yuechunli$ ls<br>README.md    <strong>package</strong>.json    src<br>node_modules    <strong>public</strong>        yarn.lock<br>localhost:ipfs-http-demo yuechunli$ pwd<br>/Users/liyuechun/Desktop/1123/ipfs-http-demo<br>localhost:ipfs-http-demo yuechunli$ npm install --save ipfs-api</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FBLNB60fdW3KLv2L.png" /></figure><p><strong>⚠️：ipfs安装完后，如上图所示，接下来刷新一下浏览器，看看项目是否有问题，正常来讲，一切会正常，🍭🍭🍭，Continue，Continue，Continue……</strong></p><h3>3.6 完成UI逻辑</h3><p>拷贝下面的代码，将src/App.js里面的代码直接替换掉。</p><pre><strong>import</strong> React, { Component } <strong>from</strong> &#39;react&#39;;<br><strong>import</strong> &#39;./App.css&#39;;</pre><pre><strong>class</strong> <strong>App</strong> <strong>extends</strong> <strong>Component</strong> {<br></pre><pre>      <strong>constructor</strong>(props) {<br>          <strong>super</strong>(props);<br>          <strong>this</strong>.state = {<br>            strHash: null,<br>            strContent: null<br>          }<br>      }</pre><pre>    render() {<br>      <strong>return</strong> (<br>        &lt;<strong>div</strong> className=&quot;App&quot;&gt;<br>          &lt;<strong>input</strong><br>            ref=&quot;ipfsContent&quot;<br>            style={{width: 200,height: 40,borderWidth:2}}/&gt;<br>          &lt;<strong>button</strong> onClick={() =&gt; {<br>            let ipfsContent = this.refs.ipfsContent.value;<br>            console.log(ipfsContent);<br>          }}&gt;提交到IPFS&lt;/<strong>button</strong>&gt;</pre><pre>          &lt;<strong>p</strong>&gt;{this.state.strHash}&lt;/<strong>p</strong>&gt;</pre><pre>          &lt;<strong>button</strong> onClick={() =&gt; {<br>            console.log(&#39;从ipfs读取数据。&#39;)<br>           }}&gt;读取数据&lt;/<strong>button</strong>&gt;<br>           &lt;<strong>h1</strong>&gt;{this.state.strContent}&lt;/<strong>h1</strong>&gt;<br>        &lt;/<strong>div</strong>&gt;<br>      );<br>    }<br>}</pre><pre>export default App;</pre><p>上面的代码完成的工作是，当我们在输入框中输入一个字符串时，点击<strong>提交到IPFS</strong>按钮，将文本框中的内容取出来打印，后续我们需要将这个数据上传到IPFS。点击<strong>读取数据</strong>按钮，我们也只是随便打印了一个字符串，后面需要从IPFS读取数据，然后将读取的数据存储到状态机变量strContent中并且展示出来。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NDr0V8i5tPt9E5vt.gif" /></figure><h3>3.7 导入IPFS</h3><pre><strong>const ipfsAPI</strong> = require(&#39;ipfs-api&#39;);<br><strong>const ipfs</strong> = ipfsAPI({host: &#39;localhost&#39;, port: &#39;5001&#39;, protocol: &#39;http&#39;});</pre><h3>3.8 编写上传大文本字符串到IPFS的Promise函数</h3><pre><strong>saveTextBlobOnIpfs</strong> = (blob) =&gt; {<br>    <strong>return</strong> <strong>new</strong> Promise(function(resolve, reject) {<br>      const descBuffer = Buffer.<strong>from</strong>(blob, &#39;utf-8&#39;);<br>      ipfs.add(descBuffer).<strong>then</strong>((response) =&gt; {<br>        console.log(response)<br>        resolve(response[0].hash);<br>      }).<strong>catch</strong>((err) =&gt; {<br>        console.error(err)<br>        reject(err);<br>      })<br>    })<br>  }</pre><p>response[0].hash返回的是数据上传到IPFS后返回的HASH字符串。</p><h3>3.9 上传数据到IPFS</h3><pre><strong>this</strong>.saveTextBlobOnIpfs(ipfsContent).<strong>then</strong>((hash) =&gt; {<br>    console.log(hash);<br>    <strong>this</strong>.setState({strHash: hash});<br>});</pre><p>ipfsContent是从文本框中取到的数据，调用this.saveTextBlobOnIpfs方法将数据上传后，会返回字符串hash，并且将hash存储到状态机变量strHash中。</p><p><strong>目前完整的代码：</strong></p><pre><strong>import</strong> React, {Component} <strong>from</strong> &#39;react&#39;;<br><strong>import</strong> &#39;./App.css&#39;;</pre><pre><strong>const</strong> ipfsAPI = require(&#39;ipfs-api&#39;);<br><strong>const</strong> ipfs = ipfsAPI({host: &#39;localhost&#39;, port: &#39;5001&#39;, protocol: &#39;http&#39;});</pre><pre><strong>class</strong> <strong>App</strong> <strong>extends</strong> <strong>Component</strong> {</pre><pre>  <strong>constructor</strong>(props) {<br>    <strong>super</strong>(props);<br>    <strong>this</strong>.state = {<br>      strHash: null,<br>      strContent: null<br>    }<br>  }</pre><pre>  saveTextBlobOnIpfs = (blob) =&gt; {<br>    <strong>return</strong> <strong>new</strong> Promise(<strong>function</strong>(resolve, reject) {<br>      <strong>const</strong> descBuffer = Buffer.from(blob, &#39;utf-8&#39;);<br>      ipfs.add(descBuffer).then((response) =&gt; {<br>        console.log(response)<br>        resolve(response[0].hash);<br>      }).catch((err) =&gt; {<br>        console.error(err)<br>        reject(err);<br>      })<br>    })<br>  }</pre><pre>  render() {<br>    <strong>return</strong> (&lt;<strong>div</strong> className=&quot;App&quot;&gt;<br>      &lt;<strong>input</strong> ref=&quot;ipfsContent&quot; style={{<br>          width: 200,<br>          height: 40,<br>          borderWidth: 2<br>        }}/&gt;<br>      &lt;<strong>button</strong> onClick={() =&gt; {<br>          let ipfsContent = this.refs.ipfsContent.value;<br>          console.log(ipfsContent);<br>          this.saveTextBlobOnIpfs(ipfsContent).then((hash) =&gt; {<br>            console.log(hash);<br>            this.setState({strHash: hash});<br>          });<br>        }}&gt;提交到IPFS&lt;/<strong>button</strong>&gt;</pre><pre>      &lt;<strong>p</strong>&gt;{this.state.strHash}&lt;/<strong>p</strong>&gt;</pre><pre>      &lt;<strong>button</strong> onClick={() =&gt; {<br>          console.log(&#39;从ipfs读取数据。&#39;)<br>        }}&gt;读取数据&lt;/<strong>button</strong>&gt;<br>      &lt;<strong>h1</strong>&gt;{this.state.strContent}&lt;/<strong>h1</strong>&gt;<br>    &lt;/<strong>div</strong>&gt;);<br>  }<br>}</pre><pre>export default App;</pre><p><strong>测试：</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*16pxjdGLJwohm9nF.gif" /></figure><h3>3.10 跨域资源共享CORS配置</h3><p>跨域资源共享( CORS )配置，依次在终端执行下面的代码：</p><pre>localhost:ipfs-http-demo yuechunli$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods &#39;[&quot;PUT&quot;, &quot;GET&quot;, &quot;POST&quot;, &quot;OPTIONS&quot;]&#39;</pre><pre>localhost:ipfs-http-demo yuechunli$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin &#39;[&quot;*&quot;]&#39;</pre><pre>localhost:ipfs-http-demo yuechunli$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials &#39;[&quot;true&quot;]&#39;</pre><pre>localhost:ipfs-http-demo yuechunli$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers &#39;[&quot;Authorization&quot;]&#39;</pre><pre>localhost:ipfs-http-demo yuechunli$ ipfs config --json API.HTTPHeaders.Access-Control-Expose-Headers &#39;[&quot;Location&quot;]&#39;</pre><p>用正确的端口运行daemon：</p><pre>localhost:ipfs-http-demo yuechunli$ ipfs config Addresses.API<br>/ip4/127.0.0.1/tcp/5001<br>localhost:ipfs-http-demo yuechunli$ ipfs config Addresses.API /ip4/127.0.0.1/tcp/5001<br>localhost:ipfs-http-demo yuechunli$ ipfs daemon</pre><h3>3.11 再次刷新网页提交数据并在线查看数据</h3><ul><li>上传数据，并且查看返回hash值</li><li>在线查看上传到IPFS的数据</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v8h8_T6L9Jzu5U9H.gif" /></figure><h3>3.12 从IPFS读取数据</h3><ul><li>ipfs.cat</li></ul><pre>ipfs.cat(<strong>this</strong>.state.strHash).<strong>then</strong>((stream) =&gt; {<br>    console.log(stream);<br>    let strContent = Utf8ArrayToStr(stream);<br>    console.log(strContent);<br>    <strong>this</strong>.setState({strContent: strContent});<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lzmmfQVeqJa_jDvb.png" /></figure><p>stream为Uint8Array类型的数据，下面的方法是将Uint8Array转换为string字符串。</p><ul><li>Utf8ArrayToStr</li></ul><pre><strong>function</strong> <strong>Utf8ArrayToStr</strong>(array) {<br>    <strong>var</strong> out, i, len, c;<br>    <strong>var</strong> char2, char3;</pre><pre>    out = &quot;&quot;;<br>    len = <strong>array</strong>.length;<br>    i = 0;<br>    <strong>while</strong>(i &lt; len) {<br>    c = <strong>array</strong>[i++];<br>    <strong>switch</strong>(c &gt;&gt; 4)<br>      {<br>        <strong>case</strong> 0: <strong>case</strong> 1: <strong>case</strong> 2: <strong>case</strong> 3: <strong>case</strong> 4: <strong>case</strong> 5: <strong>case</strong> 6: <strong>case</strong> 7:<br>          <em>// 0xxxxxxx</em><br>          out += String.fromCharCode(c);<br>          <strong>break</strong>;<br>        <strong>case</strong> 12: <strong>case</strong> 13:<br>          <em>// 110x xxxx   10xx xxxx</em><br>          char2 = <strong>array</strong>[i++];<br>          out += String.fromCharCode(((c &amp; 0x1F) &lt;&lt; 6) | (char2 &amp; 0x3F));<br>          <strong>break</strong>;<br>        <strong>case</strong> 14:<br>          <em>// 1110 xxxx  10xx xxxx  10xx xxxx</em><br>          char2 = <strong>array</strong>[i++];<br>          char3 = <strong>array</strong>[i++];<br>          out += String.fromCharCode(((c &amp; 0x0F) &lt;&lt; 12) |<br>                         ((char2 &amp; 0x3F) &lt;&lt; 6) |<br>                         ((char3 &amp; 0x3F) &lt;&lt; 0));<br>          <strong>break</strong>;<br>        <strong>default</strong>:<br>          <strong>break</strong>;<br>      }<br>    }</pre><pre>    <strong>return</strong> out;<br>}</pre><ul><li>完整源码</li></ul><pre><strong>import</strong> React, {Component} <strong>from</strong> &#39;react&#39;;<br><strong>import</strong> &#39;./App.css&#39;;</pre><pre><strong>const</strong> ipfsAPI = require(&#39;ipfs-api&#39;);<br><strong>const</strong> ipfs = ipfsAPI({host: &#39;localhost&#39;, port: &#39;5001&#39;, protocol: &#39;http&#39;});</pre><pre><strong>function</strong> <strong>Utf8ArrayToStr</strong>(array) {<br>  <strong>var</strong> out,<br>    i,<br>    len,<br>    c;<br>  <strong>var</strong> char2,<br>    char3;</pre><pre>  out = &quot;&quot;;<br>  len = array.length;<br>  i = 0;<br>  <strong>while</strong> (i &lt; len) {<br>    c = array[i++];<br>    <strong>switch</strong> (c &gt;&gt; 4) {<br>      <strong>case</strong> 0:<br>      <strong>case</strong> 1:<br>      <strong>case</strong> 2:<br>      <strong>case</strong> 3:<br>      <strong>case</strong> 4:<br>      <strong>case</strong> 5:<br>      <strong>case</strong> 6:<br>      <strong>case</strong> 7:<br>        <em>// 0xxxxxxx</em><br>        out += String.fromCharCode(c);<br>        <strong>break</strong>;<br>      <strong>case</strong> 12:<br>      <strong>case</strong> 13:<br>        <em>// 110x xxxx   10xx xxxx</em><br>        char2 = array[i++];<br>        out += String.fromCharCode(((c &amp; 0x1F) &lt;&lt; 6) | (char2 &amp; 0x3F));<br>        <strong>break</strong>;<br>      <strong>case</strong> 14:<br>        <em>// 1110 xxxx  10xx xxxx  10xx xxxx</em><br>        char2 = array[i++];<br>        char3 = array[i++];<br>        out += String.fromCharCode(((c &amp; 0x0F) &lt;&lt; 12) | ((char2 &amp; 0x3F) &lt;&lt; 6) | ((char3 &amp; 0x3F) &lt;&lt; 0));<br>        <strong>break</strong>;<br>      <strong>default</strong>:<br>        <strong>break</strong>;<br>    }<br>  }</pre><pre>  <strong>return</strong> out;<br>}</pre><pre><strong>class</strong> <strong>App</strong> <strong>extends</strong> <strong>Component</strong> {</pre><pre>  <strong>constructor</strong>(props) {<br>    <strong>super</strong>(props);<br>    <strong>this</strong>.state = {<br>      strHash: null,<br>      strContent: null<br>    }<br>  }</pre><pre>  saveTextBlobOnIpfs = (blob) =&gt; {<br>    <strong>return</strong> <strong>new</strong> Promise(<strong>function</strong>(resolve, reject) {<br>      <strong>const</strong> descBuffer = Buffer.from(blob, &#39;utf-8&#39;);<br>      ipfs.add(descBuffer).then((response) =&gt; {<br>        console.log(response)<br>        resolve(response[0].hash);<br>      }).catch((err) =&gt; {<br>        console.error(err)<br>        reject(err);<br>      })<br>    })<br>  }</pre><pre>  render() {<br>    <strong>return</strong> (&lt;<strong>div</strong> className=&quot;App&quot;&gt;<br>      &lt;<strong>input</strong> ref=&quot;ipfsContent&quot; style={{<br>          width: 200,<br>          height: 40,<br>          borderWidth: 2<br>        }}/&gt;<br>      &lt;<strong>button</strong> onClick={() =&gt; {<br>          let ipfsContent = this.refs.ipfsContent.value;<br>          console.log(ipfsContent);<br>          this.saveTextBlobOnIpfs(ipfsContent).then((hash) =&gt; {<br>            console.log(hash);<br>            this.setState({strHash: hash});<br>          });<br>        }}&gt;提交到IPFS&lt;/<strong>button</strong>&gt;</pre><pre>      &lt;<strong>p</strong>&gt;{this.state.strHash}&lt;/<strong>p</strong>&gt;</pre><pre>      &lt;<strong>button</strong> onClick={() =&gt; {<br>          console.log(&#39;从ipfs读取数据。&#39;)<br>          ipfs.cat(this.state.strHash).then((stream) =&gt; {<br>            console.log(stream);<br>            let strContent = Utf8ArrayToStr(stream);<br>            console.log(strContent);<br>            this.setState({strContent: strContent});<br>          });<br>        }}&gt;读取数据&lt;/<strong>button</strong>&gt;<br>      &lt;<strong>h1</strong>&gt;{this.state.strContent}&lt;/<strong>h1</strong>&gt;<br>    &lt;/<strong>div</strong>&gt;);<br>  }<br>}</pre><pre>export default App;</pre><h3>3.13 总结</h3><p>这篇文章主要讲解如何配置React环境，如何创建React项目，如何安装js-ipfs-api，如何上传数据，如何设置开发环境，如何下载数据等等内容。通过这篇文章的系统学习，你会掌握js-ipfs-api在项目中的使用流程。</p><p>这是【IPFS + 区块链 系列】 入门篇 - IPFS + Ethereum （上篇）-js-ipfs-api，下篇讲解如何将IPFS和以太坊智能合约结合进行数据存储。</p><h3>4. 下篇文章预告</h3><p>这是【IPFS + 区块链 系列】 入门篇 - IPFS + Ethereum （上篇）-js-ipfs-api，下篇讲解如何将IPFS和以太坊智能合约结合进行数据存储。</p><p><strong>未经授权禁止转载、改编，转载请注明出处！</strong></p><p><strong>本文地址: </strong><a href="https://chaindesk.cn/witbook/12/141"><strong>https://chaindesk.cn/witbook/12/141</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad95fc100626" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chaindesk/ipfs-%E5%8C%BA%E5%9D%97%E9%93%BE-%E7%B3%BB%E5%88%97-%E5%85%A5%E9%97%A8%E7%AF%87-ipfs-ethereum-%E4%B8%8A%E7%AF%87-js-ipfs-api-ad95fc100626">【IPFS + 区块链 系列】 入门篇 — IPFS + Ethereum （上篇）-js-ipfs-api</a> was originally published in <a href="https://medium.com/chaindesk">chengxuka</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[【IPFS + 区块链 系列】 入门篇 — IPFS+IPNS+个人博客搭建]]></title>
            <link>https://medium.com/chaindesk/ipfs-%E5%8C%BA%E5%9D%97%E9%93%BE-%E7%B3%BB%E5%88%97-%E5%85%A5%E9%97%A8%E7%AF%87-ipfs-ipns-%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA-3d18cce58e86?source=rss-1af82e3a363d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d18cce58e86</guid>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[ipfs-tutorial]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[黎跃春]]></dc:creator>
            <pubDate>Wed, 17 Apr 2019 08:40:51 GMT</pubDate>
            <atom:updated>2019-04-17T08:40:51.335Z</atom:updated>
            <content:encoded><![CDATA[<h3>【IPFS + 区块链 系列】 入门篇 — IPFS+IPNS+个人博客搭建</h3><p>在阅读这篇文章之前，你需要先学习<a href="http://www.chaindesk.cn/witbook/12/139">【IPFS + 区块链 系列】 入门篇 — IPFS环境配置</a>这篇文章。</p><h3>目录</h3><ul><li><a href="https://chaindesk.cn/witbook/12/140#1-%E5%A6%82%E4%BD%95%E5%9C%A8IPFS%E6%96%B0%E5%A2%9E%E4%B8%80%E4%B8%AA%E6%96%87%E4%BB%B6">1. 如何在IPFS新增一个文件</a></li><li><a href="https://chaindesk.cn/witbook/12/140#11-%E6%96%B0%E5%BB%BAfile.txt%E6%96%87%E4%BB%B6">1.1 新建file.txt文件</a></li><li><a href="https://chaindesk.cn/witbook/12/140#12-%E6%9F%A5%E7%9C%8Bipfs%E7%9B%B8%E5%85%B3%E5%91%BD%E4%BB%A4">1.2 查看ipfs相关命令</a></li><li><a href="https://chaindesk.cn/witbook/12/140#13-%E5%B0%86file.txt%E6%B7%BB%E5%8A%A0%E5%88%B0ipfs%E8%8A%82%E7%82%B9">1.3 将file.txt添加到ipfs节点</a></li><li><a href="https://chaindesk.cn/witbook/12/140#2-%E9%80%9A%E8%BF%87ipfs%E5%88%9B%E5%BB%BA%E7%9B%AE%E5%BD%95%E5%AD%98%E5%82%A8%E6%96%87%E4%BB%B6">2. 通过ipfs创建目录存储文件</a></li><li><a href="https://chaindesk.cn/witbook/12/140#3-%E5%A6%82%E4%BD%95%E5%9C%A8IPFS%E6%96%B0%E5%A2%9E%E4%B8%80%E4%B8%AA%E7%9B%AE%E5%BD%95">3. 如何在IPFS新增一个目录</a></li><li><a href="https://chaindesk.cn/witbook/12/140#31-%E4%BD%BF%E7%94%A8ipfs%20add%20-r%E5%8F%AF%E4%BB%A5%E4%B8%8A%E4%BC%A0%E4%B8%80%E6%95%B4%E4%B8%AA%E7%9B%AE%E5%BD%95">3.1 使用ipfs add -r可以上传一整个目录</a></li><li><a href="https://chaindesk.cn/witbook/12/140#32-%E9%80%9A%E8%BF%87%E8%B7%AF%E5%BE%84%E8%AE%BF%E9%97%AEcontactme.txt%E6%96%87%E4%BB%B6%E6%95%B0%E6%8D%AE">3.2 通过路径访问contactme.txt文件数据</a></li><li><a href="https://chaindesk.cn/witbook/12/140#33-%E9%80%9A%E8%BF%87Hash%E6%9F%A5%E7%9C%8B%E6%95%B0%E6%8D%AEIPFS%E7%BD%91%E7%BB%9C%E6%95%B0%E6%8D%AE">3.3 通过Hash查看数据IPFS网络数据</a></li><li><a href="https://chaindesk.cn/witbook/12/140#4-%E5%88%9B%E5%BB%BA%E7%AE%80%E6%98%93%E7%9A%84%E7%BD%91%E9%A1%B5%E5%8F%91%E5%B8%83%E5%88%B0IPFS">4. 创建简易的网页发布到IPFS</a></li><li><a href="https://chaindesk.cn/witbook/12/140#41-%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAindex.html%E6%96%87%E4%BB%B6">4.1 创建一个index.html文件</a></li><li><a href="https://chaindesk.cn/witbook/12/140#42-%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAstyle.css%E6%96%87%E4%BB%B6">4.2 创建一个style.css文件</a></li><li><a href="https://chaindesk.cn/witbook/12/140#43-%E6%B7%BB%E5%8A%A0%E5%88%B0ipfs">4.3 添加到ipfs</a></li><li><a href="https://chaindesk.cn/witbook/12/140#44-%E7%BD%91%E7%BB%9C%E5%90%8C%E6%AD%A5">4.4 网络同步</a></li><li><a href="https://chaindesk.cn/witbook/12/140#45-%E8%AE%BF%E9%97%AE%E7%BD%91%E7%AB%99">4.5 访问网站</a></li><li><a href="https://chaindesk.cn/witbook/12/140#46-%E5%8F%91%E5%B8%83%E5%88%B0IPNS">4.6 发布到IPNS</a></li><li><a href="https://chaindesk.cn/witbook/12/140#5-%E5%8F%91%E5%B8%83%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2">5. 发布个人博客</a></li><li><a href="https://chaindesk.cn/witbook/12/140#51-%E6%90%AD%E5%BB%BA%E9%9D%99%E6%80%81%E5%8D%9A%E5%AE%A2">5.1 搭建静态博客</a></li><li><a href="https://chaindesk.cn/witbook/12/140#52-%E8%8A%82%E7%82%B9ID%E6%9B%BF%E6%8D%A2">5.2 节点ID替换</a></li><li><a href="https://chaindesk.cn/witbook/12/140#53-%E6%B5%8F%E8%A7%88%E5%8D%9A%E5%AE%A2">5.3 浏览博客</a></li><li><a href="https://chaindesk.cn/witbook/12/140#6-%E4%B8%8B%E7%AF%87%E9%A2%84%E6%8A%A5">6. 下篇预报</a></li><li><a href="https://chaindesk.cn/witbook/12/140#61-%60ipfs%20+%20ethereum%60%60Dapp%60%E5%BC%80%E5%8F%91%E5%85%A5%E9%97%A8">6.1 </a><a href="https://chaindesk.cn/witbook/12/140#61-%60ipfs%20+%20ethereum%60%60Dapp%60%E5%BC%80%E5%8F%91%E5%85%A5%E9%97%A8">ipfs + ethereum``Dapp开发入门</a></li></ul><h3>1. 如何在IPFS新增一个文件</h3><h3>1.1 新建file.txt文件</h3><p>打开终端，切换到桌面，新建一个文件夹1121，切换到1121中，通过vi新建一个文件file.txt，文件里面输入春哥微信号liyc1215保存并且退出。</p><pre>localhost:Desktop yuechunli$ <strong>pwd</strong><br>/Users/liyuechun/Desktop<br>localhost:Desktop yuechunli$ mkdir 1121<br>localhost:Desktop yuechunli$ <strong>cd</strong> 1121/<br>localhost:1121 yuechunli$ <strong>vi</strong> <strong>file</strong>.txt<br>localhost:1121 yuechunli$ <strong>cat</strong> <strong>file</strong>.txt <br>liyc1215<br>localhost:1121 yuechunli$</pre><h3>1.2 查看ipfs相关命令</h3><pre>localhost:1121 yuechunli$ ipfs help<br>USAGE<br>  ipfs - Global p2p merkle-dag filesystem.</pre><pre>  ipfs [<strong>--config</strong>=&lt;config&gt; | -c] [<strong>--debug</strong>=&lt;debug&gt; | -D] [<strong>--help</strong>=&lt;help&gt;] [<strong>-h</strong>=&lt;h&gt;] [<strong>--local</strong>=&lt;local&gt; | -L] [<strong>--api</strong>=&lt;api&gt;] &lt;command&gt; ...</pre><pre>SUBCOMMANDS<br>  BASIC COMMANDS<br>    init          Initialize ipfs local configuration<br>    add &lt;path&gt;    Add a file <strong>to</strong> IPFS<br>    cat &lt;ref&gt;     Show IPFS object data<br>    get &lt;ref&gt;     Download IPFS objects<br>    ls &lt;ref&gt;      List links <strong>from</strong> an object<br>    refs &lt;ref&gt;    List hashes of links <strong>from</strong> an object</pre><pre>  DATA STRUCTURE COMMANDS<br>    block         Interact with raw blocks <strong>in</strong> the datastore<br>    object        Interact with raw dag nodes<br>    files         Interact with objects as <strong>if</strong> they were a unix filesystem<br>    dag           Interact with IPLD documents (experimental)</pre><pre>  ADVANCED COMMANDS<br>    daemon        Start a long-running daemon process<br>    mount         Mount an IPFS read-only mountpoint<br>    resolve       Resolve any type of name<br>    name          Publish <strong>and</strong> resolve IPNS names<br>    key           Create <strong>and</strong> list IPNS name keypairs<br>    dns           Resolve DNS links<br>    pin           Pin objects <strong>to</strong> local storage<br>    repo          Manipulate the IPFS repository<br>    stats         Various operational stats<br>    p2p           Libp2p stream mounting<br>    filestore     Manage the filestore (experimental)</pre><pre>  NETWORK COMMANDS<br>    id            Show info about IPFS peers<br>    bootstrap     Add <strong>or</strong> remove bootstrap peers<br>    swarm         Manage connections <strong>to</strong> the p2p network<br>    dht           Query the DHT <strong>for</strong> values <strong>or</strong> peers<br>    ping          Measure the latency of a connection<br>    diag          Print diagnostics</pre><pre>  TOOL COMMANDS<br>    config        Manage configuration<br>    version       Show ipfs version information<br>    update        Download <strong>and</strong> apply go-ipfs updates<br>    commands      List all available commands</pre><h3>1.3 将file.txt添加到ipfs节点</h3><pre>localhost:1121 yuechunli$ <strong>ls</strong><br><strong>file</strong>.txt<br>localhost:1121 yuechunli$ ipfs add <strong>file</strong>.txt <br>added QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T <strong>file</strong>.txt<br>localhost:1121 yuechunli$ <strong>cat</strong> <strong>file</strong>.txt <br>liyc1215<br>localhost:1121 yuechunli$ ipfs <strong>cat</strong> QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T<br>liyc1215<br>localhost:1121 yuechunli$</pre><p>当执行完ipfs add file.txt这个命令以后，会将file.txt添加到ipfs当前的节点中，并且会对file.txt文件生成一个唯一的hash``QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T，如果想查看本地ipfs节点的数据，可以通过ipfs cat QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T进行查看。</p><p><strong>⚠️：</strong>当我试图通过http://ipfs.io/ipfs/QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T进行数据访问时，无法访问，如下图所示：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uMIETUY7Fe7n42yltGl3Hw.png" /><figcaption>来源：chaindesk.cn</figcaption></figure><p><strong>⚠️：</strong>虽然数据已经添加到当前的你自己的IPFS节点中，但是并没有同步到IPFS网络，所以暂时在网络上无法访问。</p><p><strong>⚠️：重要：接下来执行下面的命令同步节点数据到</strong><strong>IPFS网络，再试图在网络上查看数据。</strong></p><ul><li>同步节点</li></ul><p>新建一个终端，执行ipfs daemon。</p><pre>localhost:.ipfs yuechunli$ ipfs daemon<br>Initializing daemon...<br>Adjusting current ulimit to 2048...<br>Successfully raised file descriptor limit to 2048.<br>Swarm listening on /ip4/111.196.246.151/tcp/3637<br>Swarm listening on /ip4/127.0.0.1/tcp/4001<br>Swarm listening on /ip4/169.254.170.167/tcp/4001<br>Swarm listening on /ip4/192.168.0.107/tcp/4001<br>Swarm listening on /ip6/::1/tcp/4001<br>API server listening on /ip4/127.0.0.1/tcp/5001<br>Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080<br>Daemon <strong>is</strong> ready</pre><ul><li>从IPFS网络查看数据</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Now8tcVDiNJN2dNKnyOiVw.png" /></figure><p>浏览器访问<a href="https://ipfs.io/ipfs/QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T">https://ipfs.io/ipfs/QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T</a></p><h3>2. 通过ipfs创建目录存储文件</h3><p>在着上面的步骤走，我们可以通过ipfs cat QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T liyc1215查看添加到ipfs网络的file.txt文件的内容，如下：</p><pre>localhost:1121 yuechunli$ ipfs <strong>cat</strong> QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T<br>liyc1215<br>localhost:1121 yuechunli$</pre><p>当然，我们也可以通过ipfs的相关命令在ipfs的根目录下面创建文件夹，并且将file.txt文件<strong>移动</strong>或者<strong>拷贝</strong>到我们创建的文件夹中。</p><p><strong>⚠️：cp不会改变文件hash，mv会改变hash寻址。</strong></p><pre>localhost:1121 yuechunli$ ipfs <strong>cat</strong> QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T<br>liyc1215<br>localhost:1121 yuechunli$ ipfs <strong>files</strong> mkdir /LiYueChun<br>localhost:1121 yuechunli$ ipfs <strong>files</strong> <strong>cp</strong> /ipfs/QmbrevseVQKf1vsYMsxCscRf6D7S2dftYpHwxkYf94pc7T /LiYueChun/<strong>file</strong>.txt<br>localhost:1121 yuechunli$ ipfs <strong>files</strong> <strong>ls</strong> /<br>LiYueChun<br>localhost:1121 yuechunli$ ipfs <strong>files</strong> <strong>ls</strong> /LiYueChun/<br><strong>file</strong>.txt<br>localhost:1121 yuechunli$ ipfs <strong>files</strong> <strong>read</strong> /LiYueChun/<strong>file</strong>.txt<br>liyc1215<br>localhost:1121 yuechunli$</pre><h3>3. 如何在IPFS新增一个目录</h3><h3>3.1 使用ipfs add -r可以上传一整个目录</h3><pre>localhost:1121 yuechunli$ ipfs add -r ipfs-tutorial/<br>added QmYx4BnhnLXeMWF5mKu16fJgUBiVP7ECXh7qcsUZnXiRxc ipfs-tutorial/contactme.txt<br>added QmfKdWsguobA3aDPvSxLB3Bq4HMKyqKSgFr2NFUuVH8n31 ipfs-tutorial/eth-fabric.png<br>added QmXe8jTxTh5MZP6BK5cnj19mXNTKVMzNyUJZUHuYyr5dk1 ipfs-tutorial/gongzhonghao.png<br>added QmSsjQDVw1fvmG5RsZMgp2GjihiXn2zDv64mfHZN3AREek ipfs-tutorial</pre><h3>3.2 通过路径访问contactme.txt文件数据</h3><p>如果我们上传的是目录，那么可以通过下面几种方式访问到contactme.txt文件的数据。</p><pre>localhost:1121 yuechunli$ ipfs cat QmYx4BnhnLXeMWF5mKu16fJgUBiVP7ECXh7qcsUZnXiRxc<br>微信：liyc1215<br>区块链技术交流群：348924182<br>公众号：区块链部落<br>localhost:1121 yuechunli$ ipfs cat /ipfs/QmYx4BnhnLXeMWF5mKu16fJgUBiVP7ECXh7qcsUZnXiRxc<br>微信：liyc1215<br>区块链技术交流群：348924182<br>公众号：区块链部落<br>localhost:1121 yuechunli$ ipfs cat /ipfs/QmSsjQDVw1fvmG5RsZMgp2GjihiXn2zDv64mfHZN3AREek/contactme.txt<br>微信：liyc1215<br>区块链技术交流群：348924182<br>公众号：区块链部落<br>localhost:1121 yuechunli$</pre><h3>3.3 通过Hash查看数据IPFS网络数据</h3><ul><li><strong>访问目录：</strong><a href="https://ipfs.io/ipfs/QmSsjQDVw1fvmG5RsZMgp2GjihiXn2zDv64mfHZN3AREek">https://ipfs.io/ipfs/QmSsjQDVw1fvmG5RsZMgp2GjihiXn2zDv64mfHZN3AREek</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xsg2X-GG1uhdPSDTcYvJxw.png" /></figure><ul><li><strong>通过目录访问文件：</strong><a href="https://ipfs.io/ipfs/QmSsjQDVw1fvmG5RsZMgp2GjihiXn2zDv64mfHZN3AREek/contactme.txt">https://ipfs.io/ipfs/QmSsjQDVw1fvmG5RsZMgp2GjihiXn2zDv64mfHZN3AREek/contactme.txt</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SlMhgLsa-6DGTJms_kR_Zg.png" /></figure><ul><li><strong>通过文件hash直接访问：</strong><a href="https://ipfs.io/ipfs/QmYx4BnhnLXeMWF5mKu16fJgUBiVP7ECXh7qcsUZnXiRxc">https://ipfs.io/ipfs/QmYx4BnhnLXeMWF5mKu16fJgUBiVP7ECXh7qcsUZnXiRxc</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LnTHK3K8VTHeQ5Zt.png" /></figure><h3>4. 创建简易的网页发布到IPFS</h3><p>在这里我先自己写一个简单的网页给大家演示，先在桌面新建一个site文件夹，然后按照下面的步骤在site文件夹中建立index.html和style.css文件。</p><h3>4.1 创建一个index.html文件</h3><pre><strong>&lt;!DOCTYPE html&gt;</strong><br>&lt;<strong>html</strong> lang=&quot;en&quot;&gt;<br>&lt;<strong>head</strong>&gt;<br>  &lt;<strong>meta</strong> charset=&quot;UTF-8&quot;&gt;<br>  &lt;<strong>title</strong>&gt;Hello IPFS!&lt;/<strong>title</strong>&gt;<br>  &lt;<strong>link</strong> rel=&quot;stylesheet&quot; href=&quot;./style.css&quot; /&gt;<br>&lt;/<strong>head</strong>&gt;<br>&lt;<strong>body</strong>&gt;<br>  &lt;<strong>h1</strong>&gt;Hello IPFS!&lt;/<strong>h1</strong>&gt;<br>&lt;/<strong>body</strong>&gt;<br>&lt;/<strong>html</strong>&gt;</pre><h3>4.2 创建一个style.css文件</h3><pre><strong>h1</strong> {<br>  <strong>color</strong>: green;<br>}</pre><h3>4.3 添加到ipfs</h3><pre>localhost:Desktop yuechunli$ ipfs <strong>add </strong>-r site/<br><strong>added </strong>QmWG5rbgT9H77TGq49RXNoqN8M7DNKMnMX425nkmCB6BjS site/index.html<br><strong>added </strong>QmfGLJ3mryLvicQqzdsghq4QRhptKJtBAPe7yDJxsBGSuy site/style.css<br><strong>added </strong>QmdVEGkT5u7LtzzatTrn8JGNEF3fpuMPVs2rPCfvqRykRp site</pre><p>最后一行是项目根目录的hash，你先通过ipfs daemon同步网络，然后可以通过https://ipfs.io/ipfs/&lt;你的项目根目录hash&gt;，即https://ipfs.io/ipfs/QmdVEGkT5u7LtzzatTrn8JGNEF3fpuMPVs2rPCfvqRykRp访问项目。</p><h3>4.4 网络同步</h3><pre>localhost:Desktop yuechunli$ ipfs daemon</pre><h3>4.5 访问网站</h3><p>浏览器打开<a href="https://ipfs.io/ipfs/QmdVEGkT5u7LtzzatTrn8JGNEF3fpuMPVs2rPCfvqRykRp">https://ipfs.io/ipfs/QmdVEGkT5u7LtzzatTrn8JGNEF3fpuMPVs2rPCfvqRykRp</a>，效果图如下：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*omnkBeXksaWwrpAa2FyFVw.png" /></figure><h3>4.6 发布到IPNS</h3><p>当我们修改网站内容重新添加到ipfs时，hash会发生变化，当我们网站更新时，我们可以将网站发布到IPNS，在IPNS中，允许我们节点的域名空间中引用一个IPFS hash，也就是说我们可以通过节点ID对项目根目录的IPFS HASH进行绑定，以后我们访问网站时直接通过节点·ID访问即可，当我们更新博客时，重新发布到IPNS`即可。</p><pre>localhost:~ yuechunli$ ipfs name publish QmdVEGkT5u7LtzzatTrn8JGNEF3fpuMPVs2rPCfvqRykRp<br>Published to QmdKXkeEWcuRw9oqBwopKUa8CgK1iBktPGYaMoJ4UNt1MP: <strong>/ipfs/</strong>QmdVEGkT5u7LtzzatTrn8JGNEF3fpuMPVs2rPCfvqRykRp<br>localhost:~ yuechunli$ ipfs id<br>{<br>    &quot;ID&quot;: &quot;QmdKXkeEWcuRw9oqBwopKUa8CgK1iBktPGYaMoJ4UNt1MP&quot;<br>}</pre><p>当我们执行ipfs name publish命令时，会返回我们的节点ID，你可以通过ipfs id进行查看验证是否是你的节点ID。</p><p><strong>⚠️：验证</strong></p><pre>$ ipfs name resolve &lt;peerId&gt;</pre><pre>localhost:~ yuechunli$ ipfs name resolve QmdKXkeEWcuRw9oqBwopKUa8CgK1iBktPGYaMoJ4UNt1MP<br><strong>/ipfs/</strong>QmdVEGkT5u7LtzzatTrn8JGNEF3fpuMPVs2rPCfvqRykRp<br>localhost:~ yuechunli$</pre><p><strong>⚠️：</strong>当然我们现在就可以通过IPNS进行访问了。</p><pre><a href="https://ipfs.io/ipns/QmdKXkeEWcuRw9oqBwopKUa8CgK1iBktPGYaMoJ4UNt1MP">https://ipfs.io/ipns/QmdKXkeEWcuRw9oqBwopKUa8CgK1iBktPGYaMoJ4UNt1MP</a></pre><p><strong>⚠️⚠️⚠️：注意上面是ipns而不是ipfs。</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u9H_tqzWBAORBUzs8RueFQ.png" /></figure><p><strong>⚠️：如果你网站数据修改，需要重新发布到IPNS。</strong></p><h3>5. 发布个人博客</h3><p>你可以通过Hugo按照官方文档创建一个漂亮的静态博客<a href="http://gohugo.io/getting-started/quick-start/">Hugo官方网站</a>，当然你也可以自己编写，或者使用其他开源项目搭建。</p><h3>5.1 搭建静态博客</h3><p>大家可以自己搭建，也可以直接下载我的博客源码直接搭建。</p><p>源码地址：<a href="http://github.com/liyuechun/ipfs_blogger">http://github.com/liyuechun/ipfs_blogger</a></p><h3>5.2 节点ID替换</h3><ul><li>查看你的节点ID</li></ul><pre>localhost:ipfs_pin yuechunli$ ipfs id<br>{<br>    &quot;ID&quot;: &quot;《your peer id》&quot;<br>}<br>localhost:ipfs_pin yuechunli$</pre><p>在上面的源码中全局搜索将源码里面的QmdKXkeEWcuRw9oqBwopKUa8CgK1iBktPGYaMoJ4UNt1MP替换成你自己的ID。</p><p>接下来重复<a href="https://chaindesk.cn/witbook/12/140#4-%E5%88%9B%E5%BB%BA%E7%AE%80%E6%98%93%E7%9A%84%E7%BD%91%E9%A1%B5%E5%8F%91%E5%B8%83%E5%88%B0IPFS">4. 创建简易的网页发布到IPFS</a>的操作步骤即可。</p><h3>5.3 浏览博客</h3><p>浏览器打开<a href="https://ipfs.io/ipns/QmdKXkeEWcuRw9oqBwopKUa8CgK1iBktPGYaMoJ4UNt1MP/">https://ipfs.io/ipns/QmdKXkeEWcuRw9oqBwopKUa8CgK1iBktPGYaMoJ4UNt1MP/</a>查看项目效果。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jm6_kF9NwjUgDvDm.png" /></figure><h3>6. 下篇预报</h3><h3>6.1 ipfs + ethereum``Dapp开发入门</h3><p><strong>未经授权禁止转载、改编，转载请注明出处！</strong></p><p><strong>本文地址: </strong><a href="https://chaindesk.cn/witbook/12/140"><strong>https://chaindesk.cn/witbook/12/140</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d18cce58e86" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chaindesk/ipfs-%E5%8C%BA%E5%9D%97%E9%93%BE-%E7%B3%BB%E5%88%97-%E5%85%A5%E9%97%A8%E7%AF%87-ipfs-ipns-%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA-3d18cce58e86">【IPFS + 区块链 系列】 入门篇 — IPFS+IPNS+个人博客搭建</a> was originally published in <a href="https://medium.com/chaindesk">chengxuka</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[【IPFS + 区块链 系列】 入门篇 — IPFS环境配置]]></title>
            <link>https://medium.com/chaindesk/ipfs-%E5%8C%BA%E5%9D%97%E9%93%BE-%E7%B3%BB%E5%88%97-%E5%85%A5%E9%97%A8%E7%AF%87-ipfs%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE-20373f5e94fc?source=rss-1af82e3a363d------2</link>
            <guid isPermaLink="false">https://medium.com/p/20373f5e94fc</guid>
            <category><![CDATA[区块链技术]]></category>
            <category><![CDATA[ipfs-tutorial]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[区块链]]></category>
            <dc:creator><![CDATA[黎跃春]]></dc:creator>
            <pubDate>Wed, 17 Apr 2019 08:33:24 GMT</pubDate>
            <atom:updated>2019-04-17T08:52:16.906Z</atom:updated>
            <content:encoded><![CDATA[<h3>【IPFS + 区块链 系列】 入门篇 — IPFS环境配置</h3><p>作者：愿码(ChainDesk.CN)品牌创始人黎跃春</p><h3>目录</h3><ul><li><a href="https://chaindesk.cn/witbook/12/139#1-IPFS%E7%AE%80%E4%BB%8B">1. IPFS简介</a></li><li><a href="https://chaindesk.cn/witbook/12/139#2-IPFS%20%E6%9C%AC%E5%9C%B0%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85">2. IPFS 本地环境安装</a></li><li><a href="https://chaindesk.cn/witbook/12/139#21-%E4%B8%8B%E8%BD%BDipfs%E5%8E%8B%E7%BC%A9%E5%8C%85">2.1 下载ipfs压缩包</a></li><li><a href="https://chaindesk.cn/witbook/12/139#22-%E5%AE%89%E8%A3%85">2.2 安装</a></li><li><a href="https://chaindesk.cn/witbook/12/139#3-%E9%A1%B9%E7%9B%AE%E9%85%8D%E7%BD%AE">3. 项目配置</a></li><li><a href="https://chaindesk.cn/witbook/12/139#31-%E5%88%9B%E5%BB%BAipfs%E8%8A%82%E7%82%B9">3.1 创建ipfs节点</a></li><li><a href="https://chaindesk.cn/witbook/12/139#32-%E4%BF%AE%E6%94%B9%E8%8A%82%E7%82%B9%E9%BB%98%E8%AE%A4%E5%AD%98%E5%82%A8%E7%A9%BA%E9%97%B4">3.2 修改节点默认存储空间</a></li><li><a href="https://chaindesk.cn/witbook/12/139#33-%E6%9F%A5%E7%9C%8B%E8%8A%82%E7%82%B9id">3.3 查看节点id</a></li><li><a href="https://chaindesk.cn/witbook/12/139#34-%E5%90%AF%E5%8A%A8%E8%8A%82%E7%82%B9%E6%9C%8D%E5%8A%A1%E5%99%A8">3.4 启动节点服务器</a></li><li><a href="https://chaindesk.cn/witbook/12/139#35-%E8%B7%A8%E5%9F%9F%E8%B5%84%E6%BA%90%E5%85%B1%E4%BA%ABCORS%E9%85%8D%E7%BD%AE">3.5 跨域资源共享( CORS )配置</a></li><li><a href="https://chaindesk.cn/witbook/12/139#4-%E4%B8%8B%E7%AF%87%E9%A2%84%E5%91%8A">4. 下篇预告</a></li></ul><h3>1. IPFS简介</h3><p>IPFS（InterPlanetary File System）是一个点对点的分布式超媒体分发协议，它整合了过去几年最好的分布式系统思路，为所有人提供全球统一的可寻址空间，包括Git、自证明文件系统SFS、BitTorrent和DHT，同时也被认为是最有可能取代HTTP的新一代互联网协议。</p><p>IPFS用基于内容的寻址替代传统的基于域名的寻址，用户不需要关心服务器的位置，不用考虑文件存储的名字和路径。我们将一个文件放到IPFS节点中，将会得到基于其内容计算出的唯一加密哈希值。哈希值直接反映文件的内容，哪怕只修改1比特，哈希值也会完全不同。当IPFS被请求一个文件哈希时，它会使用一个分布式哈希表找到文件所在的节点，取回文件并验证文件数据。</p><p>IPFS是通用目的的基础架构，基本没有存储上的限制。大文件会被切分成小的分块，下载的时候可以从多个服务器同时获取。IPFS的网络是不固定的、细粒度的、分布式的网络，可以很好的适应内容分发网络的要求。这样的设计可以很好的共享各类数据，包括图像、视频流、分布式数据库、整个操作系统、模块链、8英寸软盘的备份，还有静态网站。</p><p>IPFS提供了一个友好的WEB访问接口，用户可通过http://ipfs.io/hash 获取IPFS网络中的内容，也许在不久的将来，IPFS协议将会彻底替代传统的HTTP协议。</p><h3>2. IPFS 本地环境安装</h3><h3>2.1 下载ipfs压缩包</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bFv--Rz1oL8UkxTr8SC3Iw.png" /><figcaption>来源：chaindesk.cn</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x1aQKKhU9teuOPpcbrSqWQ.png" /><figcaption>来源：chaindesk.cn</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qAM9PH7C9BsNLpYDKkTdBA.png" /><figcaption>来源：chaindesk.cn</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JDQJEQqFxELjjYQvp8AOmg.png" /><figcaption>来源：chaindesk.cn</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F5W11dv-FVSRsJKyGl5U_w.png" /><figcaption>来源：chaindesk.cn</figcaption></figure><h3>2.2 安装</h3><pre>liyuechun:Downloads yuechunli$ <strong>pwd</strong><br>/Users/liyuechun/Downloads<br>liyuechun:Downloads yuechunli$ <strong>ls</strong><br><strong>go</strong>-ipfs_v0.4.10_darwin-amd64.tar.gz<br>liyuechun:Downloads yuechunli$ tar xvfz <strong>go</strong>-ipfs_v0.4.10_darwin-amd64.tar.gz <br><strong>x</strong> <strong>go</strong>-ipfs/build-log<br><strong>x</strong> <strong>go</strong>-ipfs/install.<strong>sh</strong><br><strong>x</strong> <strong>go</strong>-ipfs/ipfs<br><strong>x</strong> <strong>go</strong>-ipfs/LICENSE<br><strong>x</strong> <strong>go</strong>-ipfs/README.md<br>liyuechun:Downloads yuechunli$ <strong>ls</strong><br><strong>go</strong>-ipfs                    <strong>go</strong>-ipfs_v0.4.10_darwin-amd64.tar.gz<br>liyuechun:Downloads yuechunli$ <strong>cd</strong> <strong>go</strong>-ipfs<br>liyuechun:<strong>go</strong>-ipfs yuechunli$ <strong>ls</strong><br>LICENSE        README.md    build-log    install.<strong>sh</strong>    ipfs<br>liyuechun:<strong>go</strong>-ipfs yuechunli$ mv ipfs /usr/local/bin/ipfs</pre><p>tar xvfz go-ipfs_v0.4.10_darwin-amd64.tar.gz文件解压。</p><p>mv ipfs /usr/local/bin/ipfs，将已解压的文件夹中的ipfs文件移动到/usr/local/bin/文件夹中。</p><h3>3. 项目配置</h3><h3>3.1 创建ipfs节点</h3><p>为了运行项目，我们需要通过ipfs init在本地计算机建立一个IPFS节点。</p><pre>localhost:.ipfs yuechunli$ cd ~/.ipfs<br>-bash: cd: /Users/liyuechun/.ipfs: No such file <strong>or</strong> directory<br>localhost:.ipfs yuechunli$ ipfs init<br>initializing IPFS node at /Users/liyuechun/.ipfs<br>generating 2048-bit RSA keypair...done<br>peer identity: QmdKXkeEWcuRw9oqBwopKUa8CgK1iBktPGYaMoJ4UNt1MP<br><strong>to</strong> get started, enter:</pre><pre>    ipfs cat /ipfs/QmVLDAhCY3X9P2uRudKAryuQFPM5zqA3Yij1dY8FpGbL7T/readme</pre><pre>localhost:.ipfs yuechunli$ cd ~/.ipfs<br>localhost:.ipfs yuechunli$ ls<br>blocks        datastore    version<br>config        keystore<br>localhost:.ipfs yuechunli$ open ./<br>localhost:.ipfs yuechunli$</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*utt-x68TyY_NTy5e.png" /><figcaption>来源：chaindesk.cn</figcaption></figure><h3>3.2 修改节点默认存储空间</h3><p>执行完ipfs init命令后，会在根目录生成一个.ipfs的文件夹存储节点数据。.ipfs节点默认存储空间为10个G。</p><p>如果你自己想修改节点默认存储空间，可打开终端执行下面的命令。</p><pre>localhost:.ipfs yuechunli$ export <strong>EDITOR</strong>=/usr/bin/vim<br>localhost:.ipfs yuechunli$ ipfs config edit</pre><p>执行完ipfs config edit命令后会打开一个文件，在这个文件中找到下图中春哥「微信：liyc1215」绘制红线的位置，将10GB修改成你自己想要的存储空间。修改完毕，保存退出。（PS：输入i可以开始编辑，编译完毕后按esc键，再输入:，再次输入wq保存并且退出）。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pamqa2p6Sj7Xt0Mz.png" /><figcaption>来源：chaindesk.cn</figcaption></figure><h3>3.3 查看节点id</h3><pre>localhost:.ipfs yuechunli$ ipfs id <br>{<br>    &quot;ID&quot;: &quot;QmdKXkeEWcuRw9oqBwopKUa8CgK1iBktPGYaMoJ4UNt1MP&quot;,<br>    &quot;PublicKey&quot;: &quot;CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDqJlLivZerwIYTI5K8pEzbRnmNti3rObvpa17AixKpgTPnWAvPmZr1SLBzYUjpy3coymLHkNldcEZixnWTIihKIF1pVhxJG2MzFg8vHnG7uF8vxyYE4wOZ6V4rTauYbGau1Tj/TSjzI9oKOoezitTn6ggD3p2Y6Y1/FWGRfAvG7UUBFXSMtwVkwM/F0aaP2k8vHgsZDeYLY8UCpq67dC+AgbVNieLrX/tht6D7iTYS5Ch5dMIpwxMdRLkrNx8k9CVFgvnILhdTJL4QfdNA4L5FnWJy3axhj6bRdVkBpcdgn2WAHxYW6FwkB/eFSKxwNCKsO2/C52mUNNMouN2XlObTAgMBAAE=&quot;,<br>    &quot;Addresses&quot;: null,<br>    &quot;AgentVersion&quot;: &quot;go-ipfs/0.4.10/&quot;,<br>    &quot;ProtocolVersion&quot;: &quot;ipfs/0.1.0&quot;<br>}<br>localhost:.ipfs yuechunli$</pre><p>QmdKXkeEWcuRw9oqBwopKUa8CgK1iBktPGYaMoJ4UNt1MP为你的节点ID每个节点都会有一个唯一的ID。</p><h3>3.4 启动节点服务器</h3><pre>localhost:.ipfs yuechunli$ ipfs daemon<br>Initializing daemon...<br>Adjusting current ulimit to 2048...<br>Successfully raised file descriptor limit to 2048.<br>Swarm listening on /ip4/111.196.241.208/tcp/7723<br>Swarm listening on /ip4/127.0.0.1/tcp/4001<br>Swarm listening on /ip4/192.168.0.107/tcp/4001<br>Swarm listening on /ip6/::1/tcp/4001<br>API server listening on /ip4/127.0.0.1/tcp/5001<br>Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080<br>Daemon <strong>is</strong> ready</pre><h3>3.5 跨域资源共享CORS配置</h3><p>为了后续的开发方便，我们还需要对跨域资源共享( CORS )进行配置，ctrl- c退出ipfs，然后按照下面的步骤进行跨域配置。</p><ul><li>ctrl- c退出ipfs</li><li>ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods &#39;[&quot;PUT&quot;, &quot;GET&quot;, &quot;POST&quot;, &quot;OPTIONS&quot;]&#39;</li><li>ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin &#39;[&quot;*&quot;]&#39;</li><li>ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials &#39;[&quot;true&quot;]&#39;</li><li>ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers &#39;[&quot;Authorization&quot;]&#39;</li><li>ipfs config --json API.HTTPHeaders.Access-Control-Expose-Headers &#39;[&quot;Location&quot;]&#39;</li></ul><h3>3.6 验证</h3><ul><li>启动服务器</li></ul><pre>$ ipfs daemon</pre><ul><li>新建终端执行下面的命令</li></ul><pre>ipfs cat <strong>/ipfs/</strong>QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme</pre><pre>localhost:~ yuechunli$ ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme<br>Hello and Welcome to IPFS!</pre><pre>██╗██████╗ ███████╗███████╗<br>██║██╔══██╗██╔════╝██╔════╝<br>██║██████╔╝█████╗  ███████╗<br>██║██╔═══╝ ██╔══╝  ╚════██║<br>██║██║     ██║     ███████║<br>╚═╝╚═╝     ╚═╝     ╚══════╝</pre><pre>If you&#39;re seeing this, you have successfully installed<br>IPFS and are now interfacing <strong>with</strong> the ipfs merkledag!</pre><pre> <em>-------------------------------------------------------</em><br>| <strong>Warning</strong>:                                              |<br>|   This <strong>is</strong> alpha software. <strong>Use</strong> <strong>at</strong> your own discretion! |<br>|   Much <strong>is</strong> <strong>missing</strong> <strong>or</strong> lacking polish. There <strong>are</strong> bugs.  |<br>|   <strong>Not</strong> yet secure. <strong>Read</strong> the <strong>security</strong> notes <strong>for</strong> more.   |<br> <em>-------------------------------------------------------</em></pre><pre><strong>Check</strong> <strong>out</strong> <strong>some</strong> <strong>of</strong> the other files <strong>in</strong> this <strong>directory</strong>:</pre><pre>  ./about<br>  ./<strong>help</strong><br>  ./<strong>quick</strong>-<strong>start</strong>     &lt;<em>-- usage examples</em><br>  ./readme          &lt;<em>-- this file</em><br>  ./<strong>security</strong>-notes<br>localhost:~ yuechunli$</pre><ul><li>浏览器输入下面的网址</li></ul><p>打开<a href="http://localhost:5001/webui">http://localhost:5001/webui</a>会看到一个漂亮的UI界面。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*40XtOK0xHyOgEid2PWsKVQ.png" /><figcaption>来源：chaindesk.cn</figcaption></figure><h3>4. 下篇预告</h3><p>本篇文章为IPFS + Blockchain第一篇文章。</p><p>下一篇内容：</p><ul><li>如何在IPFS新增一个文件</li><li>新增一个目录</li><li>如何在IPFS部署博客</li><li>如何访问博客</li><li>如何申请IPNS</li><li>如何将IPNS对博客hash进行解析</li><li>如何新增给博客新增文章</li></ul><p><strong>未经授权禁止转载、改编，转载请注明出处！</strong></p><p><strong>本文地址: </strong><a href="https://chaindesk.cn/witbook/12/139"><strong>https://chaindesk.cn/witbook/12/139</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20373f5e94fc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chaindesk/ipfs-%E5%8C%BA%E5%9D%97%E9%93%BE-%E7%B3%BB%E5%88%97-%E5%85%A5%E9%97%A8%E7%AF%87-ipfs%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE-20373f5e94fc">【IPFS + 区块链 系列】 入门篇 — IPFS环境配置</a> was originally published in <a href="https://medium.com/chaindesk">chengxuka</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[https://chaindesk.cn/witbook/12/139]]></title>
            <link>https://medium.com/@liyuechun/https-chaindesk-cn-witbook-12-139-3d9079967efe?source=rss-1af82e3a363d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d9079967efe</guid>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[ipfs-tutorial]]></category>
            <dc:creator><![CDATA[黎跃春]]></dc:creator>
            <pubDate>Sun, 14 Apr 2019 01:53:39 GMT</pubDate>
            <atom:updated>2019-04-14T01:53:39.392Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://chaindesk.cn/witbook/12/139">https://chaindesk.cn/witbook/12/139</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d9079967efe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>