<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>研究生的区块链学习之路 on Chen's Blog</title><link>https://NamiChen.github.io/categories/%E7%A0%94%E7%A9%B6%E7%94%9F%E7%9A%84%E5%8C%BA%E5%9D%97%E9%93%BE%E5%AD%A6%E4%B9%A0%E4%B9%8B%E8%B7%AF/</link><description>Recent content in 研究生的区块链学习之路 on Chen's Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.</copyright><lastBuildDate>Thu, 22 Apr 2021 09:06:00 +0800</lastBuildDate><atom:link href="https://NamiChen.github.io/categories/%E7%A0%94%E7%A9%B6%E7%94%9F%E7%9A%84%E5%8C%BA%E5%9D%97%E9%93%BE%E5%AD%A6%E4%B9%A0%E4%B9%8B%E8%B7%AF/index.xml" rel="self" type="application/rss+xml"/><item><title>2018-2021 研究历史</title><link>https://NamiChen.github.io/2021/2018-2020-research-history/</link><pubDate>Thu, 22 Apr 2021 09:06:00 +0800</pubDate><guid>https://NamiChen.github.io/2021/2018-2020-research-history/</guid><description>本文总结2018年12月到2021年4月的研究工作历史，不包括论文阅读工作。 2018.12 区块链主流共识算法收集了解和分析 IIoT 与区块链结合的场景收集和一些</description></item><item><title>历次和老师讨论的一些问题总结</title><link>https://NamiChen.github.io/2021/summary-of-issues-discussed-with-the-teacher/</link><pubDate>Wed, 21 Apr 2021 11:06:00 +0800</pubDate><guid>https://NamiChen.github.io/2021/summary-of-issues-discussed-with-the-teacher/</guid><description>&lt;p>每周会议摘要及老师提到的一些问题总结。&lt;/p></description></item><item><title>硕士论文的格式</title><link>https://NamiChen.github.io/2021/masters-thesis-format/</link><pubDate>Mon, 08 Mar 2021 11:00:00 +0800</pubDate><guid>https://NamiChen.github.io/2021/masters-thesis-format/</guid><description>&lt;p>当一个同学问我论文格式问题时，我欣然应允，当两个、三个同学问我论文格式问题时，我意识到了什么，当预答辩的老师在那里说着“你们不会比对着学校的格式要求一个一个看吗”的时候，我终于恍然大悟，啥，就那个写的不清不楚的东西？所以我打算自己整理一份Word 版论文格式要求，以硕士论文模板为基础，补充一些缺失细节的同时，给出在 Word 中进行这些格式设置的方法。不使用 LaTeX 的原因主要是学校要求最后的提交版本是 doc 或 docx 格式，而 LaTeX 转 word 总不能尽善尽美。&lt;/p>
&lt;p>为了描述方便，我们先声明 word 中几个区域的标准叫法，如下图所示，智能搜索框的作用在于将多步点击简化为一步搜索。&lt;/p>
&lt;p>&lt;figure>&lt;img src="https://NamiChen.github.io/svg/loading.min.svg" data-sizes="auto" data-src="https://picped-1301226557.cos.ap-beijing.myqcloud.com/YJS_20210308_word%e7%95%8c%e9%9d%a2.png" alt="" class="lazyload">&lt;/figure>&lt;/p></description></item><item><title>科研基础3-伪代码规范</title><link>https://NamiChen.github.io/2021/pseudocode-specification/</link><pubDate>Mon, 18 Jan 2021 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2021/pseudocode-specification/</guid><description>&lt;p>论文的编辑要插入两段伪代码，这里总结一下伪代码书写用到的 LaTeX 包和书写规范。&lt;/p></description></item><item><title>研究记录15-研究过程中的问题总结</title><link>https://NamiChen.github.io/2020/some-problems-in-research/</link><pubDate>Fri, 20 Nov 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/some-problems-in-research/</guid><description>&lt;p>一些以前理解上出现偏差的地方，这里做校正或完善。研究过程中发现的问题，可作为下一步研究方向的，也总结在这里。&lt;/p></description></item><item><title>区块链学习7-交易池底层实现</title><link>https://NamiChen.github.io/2020/transaction-and-txpool/</link><pubDate>Fri, 04 Sep 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/transaction-and-txpool/</guid><description>&lt;p>起源于老师提出的一个问题：区块链是如何处理同时发起的多个请求的。想了想觉得核心是交易池机制，因此准备看一下交易池的原理和实现。&lt;/p></description></item><item><title>研究记录14-重新实验及实验流程优化</title><link>https://NamiChen.github.io/2020/experimental-process-optimization-and-performance-test/</link><pubDate>Mon, 01 Jun 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/experimental-process-optimization-and-performance-test/</guid><description>&lt;p>我们对之前的实验流程做了进一步的优化，并且对添加恶意行为检测后的系统进行了进一步的性能测试。&lt;/p></description></item><item><title>智能合约知识点总结</title><link>https://NamiChen.github.io/2020/summary-of-smart-contract-knowledge-points/</link><pubDate>Mon, 04 May 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/summary-of-smart-contract-knowledge-points/</guid><description>&lt;p>项目进行过程中知识点的总结&lt;/p>
&lt;h2 id="1-字符串比较">1. 字符串比较&lt;/h2>
&lt;p>翻译自：&lt;a href="https://fravoll.github.io/solidity-patterns/string_equality_comparison.html" target="_blank">Fravoll-String Equality Comparison&lt;/a>&lt;/p>
&lt;p>比较两个给定字符串是否相等，是 Solidity 编程中最常见的一种情况，但语言本身并没有提供内置函数用于字符串比较，本文介绍两种可用方法并分析 Gas 消耗情况。&lt;/p>
&lt;h3 id="11-stringutils-库">1.1 StringUtils 库&lt;/h3>
&lt;p>第一种方法是使用 Ethereum 基金会提供的 StringUtils 库，它对每个字符进行成对比较，如果有一个字符对不匹配，则返回false。这种办法可以返回正确的结果，对于短字符串和字符不同发生在字符串前面的情况仅消耗少量 Gas。但是对于相等的字符串和长字符串，这种方法的 Gas 消耗较高，因为必须做很多比较才能得到正确结果。因此，字符串比较的两个可衡量的因素是字符串平均长度和正确率。&lt;/p>
&lt;h3 id="12-哈希函数">1.2 哈希函数&lt;/h3>
&lt;p>作者提出使用哈希函数进行比较，同时检查所提供的字符串的长度，从一开始就剔除长度不匹配的字符串。其步骤如下&lt;/p>
&lt;ol>
&lt;li>检查两个字符串是否有相同长度，通过转换为 &lt;code>bytes&lt;/code> 类型完成，因为 &lt;code>bytes&lt;/code> 类型有内置长度函数。如果相同进入第2步，如果不相同返回结果；&lt;/li>
&lt;li>使用 &lt;code>keccak256()&lt;/code> 函数对两个字符串求哈希，然后比较计算得到的哈希值，从而确定是否相等。&lt;/li>
&lt;/ol>
&lt;p>一个示例代码如下&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;span class="lnt">8
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-solidity" data-lang="solidity">&lt;span class="err">#&lt;/span> &lt;span class="err">这&lt;/span>&lt;span class="err">段&lt;/span>&lt;span class="err">代&lt;/span>&lt;span class="err">码&lt;/span>&lt;span class="err">未&lt;/span>&lt;span class="err">经&lt;/span>&lt;span class="err">安&lt;/span>&lt;span class="err">全&lt;/span>&lt;span class="err">审&lt;/span>&lt;span class="err">计&lt;/span>&lt;span class="err">，&lt;/span>&lt;span class="err">使&lt;/span>&lt;span class="err">用&lt;/span>&lt;span class="err">有&lt;/span>&lt;span class="err">风&lt;/span>&lt;span class="err">险&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">hashCompareWithLengthCheck&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">string&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kt">string&lt;/span> &lt;span class="n">b&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">internal&lt;/span> &lt;span class="k">returns&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kt">bool&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="k">if&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">bytes&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">length&lt;/span> &lt;span class="o">!=&lt;/span> &lt;span class="kt">bytes&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">b&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">length&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="k">return&lt;/span> &lt;span class="kc">false&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span> &lt;span class="k">else&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="k">return&lt;/span> &lt;span class="nf">keccak256&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">abi&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">encodePacket&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="nf">keccak256&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">abi&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">encodePacket&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">b&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;code>abi.encodePacket(...) returns (bytes)&lt;/code> 用于对给定参数执行&lt;a href="https://solidity-cn.readthedocs.io/zh/develop/abi-spec.html#abi-packed-mode" target="_blank">紧打包编码&lt;/a>，官方文档中不推荐使用 &lt;code>keccak256(...)&lt;/code> 直接计算哈希，而是使用 &lt;code>keccak256(abi.encodePacked(...))&lt;/code>&lt;/p>
&lt;h3 id="13-gas-消耗分析">1.3 Gas 消耗分析&lt;/h3>
&lt;p>在 Remix 编写代码测试了三种不同情况的字符串比较的 Gas 消耗&lt;/p>
&lt;ol>
&lt;li>比较哈希&lt;/li>
&lt;li>比较每个字符，同时比较字符串长度&lt;/li>
&lt;li>比较哈希，同时比较字符串长度&lt;/li>
&lt;/ol>
&lt;p>结果如下表所示，输入列为输入的待比较字符串，输出列的单位为 Wei&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th align="left">Input A&lt;/th>
&lt;th align="left">Input B&lt;/th>
&lt;th align="right">Hash&lt;/th>
&lt;th align="right">Character + Length&lt;/th>
&lt;th align="right">Hash + Length&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td align="left">abcdefghijklmnopqrstuvwxyz&lt;/td>
&lt;td align="left">abcdefghijklmnopqrstuvwxyz&lt;/td>
&lt;td align="right">1225&lt;/td>
&lt;td align="right">7062&lt;/td>
&lt;td align="right">1261&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td align="left">abcdefghijklmnopqrstuvwxy&lt;strong>X&lt;/strong>&lt;/td>
&lt;td align="left">abcdefghijklmnopqrstuvwxyz&lt;/td>
&lt;td align="right">1225&lt;/td>
&lt;td align="right">7012&lt;/td>
&lt;td align="right">1261&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td align="left">&lt;strong>X&lt;/strong>bcdefghijklmnopqrstuvwxyz&lt;/td>
&lt;td align="left">abcdefghijklmnopqrstuvwxyz&lt;/td>
&lt;td align="right">1225&lt;/td>
&lt;td align="right">912&lt;/td>
&lt;td align="right">1261&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td align="left">a&lt;strong>X&lt;/strong>cdefghijklmnopqrstuvwxyz&lt;/td>
&lt;td align="left">abcdefghijklmnopqrstuvwxyz&lt;/td>
&lt;td align="right">1225&lt;/td>
&lt;td align="right">1156&lt;/td>
&lt;td align="right">1261&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td align="left">ab&lt;strong>X&lt;/strong>defghijklmnopqrstuvwxyz&lt;/td>
&lt;td align="left">abcdefghijklmnopqrstuvwxyz&lt;/td>
&lt;td align="right">1225&lt;/td>
&lt;td align="right">1400&lt;/td>
&lt;td align="right">1261&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td align="left">abcdefghijkl&lt;/td>
&lt;td align="left">abcdefghijklmnopqrstuvwxyz&lt;/td>
&lt;td align="right">1225&lt;/td>
&lt;td align="right">690&lt;/td>
&lt;td align="right">707&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td align="left">a&lt;/td>
&lt;td align="left">a&lt;/td>
&lt;td align="right">1225&lt;/td>
&lt;td align="right">962&lt;/td>
&lt;td align="right">1261&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td align="left">ab&lt;/td>
&lt;td align="left">ab&lt;/td>
&lt;td align="right">1225&lt;/td>
&lt;td align="right">1156&lt;/td>
&lt;td align="right">1261&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td align="left">abc&lt;/td>
&lt;td align="left">abc&lt;/td>
&lt;td align="right">1225&lt;/td>
&lt;td align="right">1450&lt;/td>
&lt;td align="right">1261&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>可以看出，哈希+字符串长度 的比较方式 Gas 消耗更加稳定，这种方式比较高效。&lt;/p>
&lt;h2 id="2-可见性与getter函数">2. 可见性与Getter函数&lt;/h2>
&lt;p>转自：&lt;a href="https://learnblockchain.cn/docs/solidity/contracts.html#getter" target="_blank">Solidity 0.6.4 中文文档&lt;/a>&lt;/p>
&lt;p>Solidity 有两种函数调用：内部调用（Internal Function Calls）和外部调用（External Function Calls）。前者指直接或递归地调用合约内部函数，不会产生实际的 EVM 调用，因此也被称为「消息嗲用」，后者指从合约外部调用合约中的函数，会产生一个 EVM 调用。&lt;/p>
&lt;h3 id="21-可见性">2.1 可见性&lt;/h3>
&lt;p>因此，函数和状态变量有四种可见性。函数可以指定为 &lt;code>external&lt;/code>，&lt;code>public&lt;/code>，&lt;code>internal&lt;/code> 或 &lt;code>private&lt;/code>，对于状态变量， 默认是 &lt;code>internal&lt;/code> 且不能设置为 &lt;code>external&lt;/code>。&lt;/p>
&lt;ul>
&lt;li>&lt;code>external&lt;/code>：外部函数作为合约接口的一部分，意味着我们可以从其他合约和交易中调用。 一个外部函数 &lt;code>f&lt;/code> 不能从内部调用（即 &lt;code>f&lt;/code> 不起作用，但 &lt;code>this.f()&lt;/code>可以）。 当收到大量数据的时候，外部函数有时候会更有效率，因为数据不会从calldata复制到内存.&lt;/li>
&lt;li>&lt;code>public&lt;/code>：public 函数是合约接口的一部分，可以在内部或通过消息调用。对于 public 状态变量， 会自动生成一个 getter 函数（见下面）。&lt;/li>
&lt;li>&lt;code>internal&lt;/code>：这些函数和状态变量只能是内部访问（即从当前合约内部或从它派生的合约访问），不使用 &lt;code>this&lt;/code> 调用。&lt;/li>
&lt;li>&lt;code>private&lt;/code>：private 函数和状态变量仅在当前定义它们的合约中使用，并且不能被派生合约使用。&lt;/li>
&lt;/ul>
&lt;blockquote>
&lt;p>合约中的所有内容对外部观察者都是可见的。设置一些 &lt;code>private&lt;/code> 类型只能阻止其他合约访问和修改这些信息， 但是对于区块链外的整个世界它仍然是可见的。&lt;/p>
&lt;/blockquote>
&lt;p>可见性标识符的定义位置，对于状态变量来说是在类型后面，对于函数是在参数列表和返回关键字中间，如下例&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-solidity" data-lang="solidity">&lt;span class="kr">pragma solidity&lt;/span> &lt;span class="o">&amp;gt;=&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">16&lt;/span> &lt;span class="o">&amp;lt;&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">contract&lt;/span> &lt;span class="n">C&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">f&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">private&lt;/span> &lt;span class="kr">pure&lt;/span> &lt;span class="k">returns&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="n">b&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="k">return&lt;/span> &lt;span class="n">a&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="p">}&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">setData&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">internal&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="n">data&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="p">}&lt;/span>
&lt;span class="kt">uint&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="n">data&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>在下面的例子中，&lt;code>D&lt;/code> 可以调用 &lt;code>c.getData（）&lt;/code> 来获取状态存储中 &lt;code>data&lt;/code> 的值，但不能调用 &lt;code>f&lt;/code> 。 合约 &lt;code>E&lt;/code> 继承自 &lt;code>C&lt;/code> ，因此可以调用 &lt;code>compute&lt;/code>。&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-solidity" data-lang="solidity">&lt;span class="kr">pragma solidity&lt;/span> &lt;span class="o">&amp;gt;=&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span> &lt;span class="o">&amp;lt;&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">contract&lt;/span> &lt;span class="n">C&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kt">uint&lt;/span> &lt;span class="kr">private&lt;/span> &lt;span class="n">data&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">f&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">private&lt;/span> &lt;span class="k">returns&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="n">b&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="k">return&lt;/span> &lt;span class="n">a&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="p">}&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">setData&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="n">data&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="p">}&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">getData&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="k">returns&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="k">return&lt;/span> &lt;span class="n">data&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="p">}&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">compute&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kt">uint&lt;/span> &lt;span class="n">b&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">internal&lt;/span> &lt;span class="k">returns&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="k">return&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="n">b&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="c1">// 下面代码编译错误
&lt;/span>&lt;span class="c1">&lt;/span>&lt;span class="kd">contract&lt;/span> &lt;span class="n">D&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">readData&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="n">C&lt;/span> &lt;span class="n">c&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="k">new&lt;/span> &lt;span class="n">C&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kt">uint&lt;/span> &lt;span class="n">local&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">c&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">f&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="c1">// 错误：成员 `f` 不可见
&lt;/span>&lt;span class="c1">&lt;/span> &lt;span class="n">c&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">setData&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="n">local&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">c&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">getData&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="n">local&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">c&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">compute&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">5&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="c1">// 错误：成员 `compute` 不可见
&lt;/span>&lt;span class="c1">&lt;/span> &lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="kd">contract&lt;/span> &lt;span class="n">E&lt;/span> &lt;span class="kr">is&lt;/span> &lt;span class="n">C&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">g&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="n">C&lt;/span> &lt;span class="n">c&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="k">new&lt;/span> &lt;span class="n">C&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kt">uint&lt;/span> &lt;span class="n">val&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">compute&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">5&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="c1">// 访问内部成员（从继承合约访问父合约成员）
&lt;/span>&lt;span class="c1">&lt;/span> &lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="22-getter-函数">2.2 Getter 函数&lt;/h3>
&lt;p>编译器自动为所有 &lt;strong>public&lt;/strong> 状态变量创建 getter 函数。对于下面给出的合约，编译器会生成一个名为 &lt;code>data&lt;/code> 的函数， 该函数没有参数，返回值是一个 &lt;code>uint&lt;/code> 类型，即状态变量 &lt;code>data&lt;/code> 的值。 状态变量的初始化可以在声明时完成。&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-solidity" data-lang="solidity">&lt;span class="kr">pragma solidity&lt;/span> &lt;span class="o">&amp;gt;=&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span> &lt;span class="o">&amp;lt;&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">contract&lt;/span> &lt;span class="n">C&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kt">uint&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="n">data&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">42&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="kd">contract&lt;/span> &lt;span class="n">Caller&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="n">C&lt;/span> &lt;span class="n">c&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="k">new&lt;/span> &lt;span class="n">C&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">f&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kt">uint&lt;/span> &lt;span class="n">local&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">c&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">data&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>getter 函数具有外部（external）可见性。如果在内部访问 getter（即没有 &lt;code>this.&lt;/code> ），它被认为一个状态变量。 如果使用外部访问（即用 &lt;code>this.&lt;/code> ），它被认作为一个函数。&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;span class="lnt">8
&lt;/span>&lt;span class="lnt">9
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-solidity" data-lang="solidity">&lt;span class="kr">pragma solidity&lt;/span> &lt;span class="o">^&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span> &lt;span class="o">&amp;lt;&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">contract&lt;/span> &lt;span class="n">C&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kt">uint&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="n">data&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">x&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="n">data&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">3&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="c1">// 内部访问
&lt;/span>&lt;span class="c1">&lt;/span> &lt;span class="kt">uint&lt;/span> &lt;span class="n">val&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nb">this&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">data&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="c1">// 外部访问
&lt;/span>&lt;span class="c1">&lt;/span> &lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>如果你有一个数组类型的 &lt;code>public&lt;/code> 状态变量，那么你只能通过生成的 getter 函数访问数组的单个元素。 这个机制以避免返回整个数组时的高成本gas。 可以使用如 &lt;code>data(0)&lt;/code> 用于指定参数要返回的单个元素。 如果要在一次调用中返回整个数组，则需要写一个函数，例如：&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-solidity" data-lang="solidity">&lt;span class="kr">pragma solidity&lt;/span> &lt;span class="o">&amp;gt;=&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span> &lt;span class="o">&amp;lt;&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">contract&lt;/span> &lt;span class="n">arrayExample&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="c1">// public state variable
&lt;/span>&lt;span class="c1">&lt;/span> &lt;span class="kt">uint&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="n">myArray&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="c1">// 指定生成的Getter 函数
&lt;/span>&lt;span class="c1">&lt;/span> &lt;span class="cm">/*
&lt;/span>&lt;span class="cm"> function myArray(uint i) public view returns (uint) {
&lt;/span>&lt;span class="cm"> return myArray[i];
&lt;/span>&lt;span class="cm"> }
&lt;/span>&lt;span class="cm"> */&lt;/span>
&lt;span class="c1">// 返回整个数组
&lt;/span>&lt;span class="c1">&lt;/span> &lt;span class="kd">function&lt;/span> &lt;span class="n">getArray&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="kr">view&lt;/span> &lt;span class="k">returns&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="kr">memory&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="k">return&lt;/span> &lt;span class="n">myArray&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>现在可以使用 &lt;code>getArray()&lt;/code> 获得整个数组，而 &lt;code>myArray(i)&lt;/code> 是返回单个元素。&lt;/p>
&lt;p>下一个例子稍微复杂一些：&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-solidity" data-lang="solidity">&lt;span class="kr">pragma solidity&lt;/span> &lt;span class="o">^&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span> &lt;span class="o">&amp;lt;&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">contract&lt;/span> &lt;span class="n">Complex&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kd">struct&lt;/span> &lt;span class="n">Data&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kt">uint&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kt">bytes3&lt;/span> &lt;span class="n">b&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">mapping&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="o">=&amp;gt;&lt;/span> &lt;span class="kt">uint&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="n">map&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="kd">mapping&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="o">=&amp;gt;&lt;/span> &lt;span class="kd">mapping&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">bool&lt;/span> &lt;span class="o">=&amp;gt;&lt;/span> &lt;span class="n">Data&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="n">data&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>这将会生成以下形式的函数&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-solidity" data-lang="solidity">&lt;span class="kd">function&lt;/span> &lt;span class="n">data&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="n">arg1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kt">bool&lt;/span> &lt;span class="n">arg2&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kt">uint&lt;/span> &lt;span class="n">arg3&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="k">returns&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kt">bytes3&lt;/span> &lt;span class="n">b&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="n">a&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">data&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">arg1&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">arg2&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">arg3&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="n">b&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">data&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">arg1&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">arg2&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">arg3&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">b&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>请注意，因为没有好的方法来提供映射的键，所以结构中的映射被省略。&lt;/p>
&lt;h2 id="3-合约间调用">3. 合约间调用&lt;/h2>
&lt;p>之前的实验合约间的调用没有成功，这次就仔细地研究一下合约间地调用机制。分为两种情况&lt;/p>
&lt;ol>
&lt;li>调用者和被调用者在一个sol文件中&lt;/li>
&lt;li>调用者和被调用者在不同的sol文件中&lt;/li>
&lt;/ol>
&lt;p>本文提到的合约调用方法的实质是抽象合约的使用。&lt;/p>
&lt;h3 id="31-同sol文件的智能合约调用">3.1 同sol文件的智能合约调用&lt;/h3>
&lt;p>下面的智能合约中，Main和Add两个合约定义在一个Main.sol文件中，可以同时编译，然后逐个部署。&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-js" data-lang="js">&lt;span class="nx">pragma&lt;/span> &lt;span class="nx">solidity&lt;/span> &lt;span class="o">^&lt;/span>&lt;span class="mf">0.5&lt;/span>&lt;span class="mf">.0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="nx">contract&lt;/span> &lt;span class="nx">Main&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="nx">Add&lt;/span> &lt;span class="nx">add&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="nx">constructor&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">address&lt;/span> &lt;span class="nx">_m&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="nx">add&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">Add&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">_m&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="nx">Addnumber&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="nx">view&lt;/span> &lt;span class="nx">returns&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">uint&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="k">return&lt;/span> &lt;span class="nx">add&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">add5&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">10&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="nx">contract&lt;/span> &lt;span class="nx">Add&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="nx">add5&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">uint&lt;/span> &lt;span class="nx">s&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="nx">pure&lt;/span> &lt;span class="nx">returns&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">uint&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">{&lt;/span>
&lt;span class="k">return&lt;/span> &lt;span class="mi">5&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="nx">s&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>以使用Remix为例，点击编译按钮编译Main.sol文件，将会同时编译Main和Add两个合约。&lt;/p>
&lt;p>&lt;figure>&lt;img src="https://NamiChen.github.io/svg/loading.min.svg" data-sizes="auto" data-src="https://picped-1301226557.cos.ap-beijing.myqcloud.com/YJS_20191108_68472178-e6294d00-025a-11ea-8b4b-41a53b471c18.png" alt="编译" class="lazyload">&lt;figcaption class="image-caption">编译&lt;/figcaption>&lt;/figure>&lt;/p>
&lt;p>然后首先部署Add合约，因为Main合约的部署需要Add的合约地址作为参数。切换到部署和运行选项卡，选择Add合约，点击&lt;code>Deploy&lt;/code>，成功部署后，复制合约地址。&lt;/p>
&lt;p>&lt;figure>&lt;img src="https://NamiChen.github.io/svg/loading.min.svg" data-sizes="auto" data-src="https://picped-1301226557.cos.ap-beijing.myqcloud.com/YJS_20191108_68472256-0e18b080-025b-11ea-9a24-e324c82cd7b5.png" alt="deploy simple Add" class="lazyload">&lt;figcaption class="image-caption">deploy simple Add&lt;/figcaption>&lt;/figure>&lt;/p>
&lt;p>然后重新选择Main合约，填入Add合约地址作为参数，点击部署按钮。&lt;/p>
&lt;p>&lt;figure>&lt;img src="https://NamiChen.github.io/svg/loading.min.svg" data-sizes="auto" data-src="https://picped-1301226557.cos.ap-beijing.myqcloud.com/YJS_20191108_68472285-1a047280-025b-11ea-8bb5-a1fb5c65574e.png" alt="deploy simple Main" class="lazyload">&lt;figcaption class="image-caption">deploy simple Main&lt;/figcaption>&lt;/figure>&lt;/p>
&lt;p>测试合约间调用，由合约内容可知，Main合约中的Addnumber函数调用了Add合约的add5函数，传入参数为10，得到的结果应为15。展开左侧的&lt;code>Deployed Contracts&lt;/code>，点击Addnumber进行调用，结果如下。&lt;/p>
&lt;p>&lt;figure>&lt;img src="https://NamiChen.github.io/svg/loading.min.svg" data-sizes="auto" data-src="https://picped-1301226557.cos.ap-beijing.myqcloud.com/YJS_20191108_68472220-f5a89600-025a-11ea-9d2a-b39c8e39a810.png" alt="call test" class="lazyload">&lt;figcaption class="image-caption">call test&lt;/figcaption>&lt;/figure>&lt;/p>
&lt;h3 id="32-不同sol文件的智能合约调用">3.2 不同sol文件的智能合约调用&lt;/h3>
&lt;p>这一次我们测试不同sol文件的智能合约调用，来一个复杂一点的，两个合约分别是Add.sol和Main.sol。&lt;/p>
&lt;p>Add.sol使用了一个结构体来定义数值，并通过映射定义查找表来寻找这个值。文件中定义了两个函数，numRegister用来向表中添加数值，addValue用来将从表中查到的指定值+5返回。之所以用这个结构是因为我们的项目里用到了，这里来测试一下可不可行。&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-js" data-lang="js">&lt;span class="nx">pragma&lt;/span> &lt;span class="nx">solidity&lt;/span> &lt;span class="o">^&lt;/span>&lt;span class="mf">0.5&lt;/span>&lt;span class="mf">.0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="nx">contract&lt;/span> &lt;span class="nx">Add&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="nx">struct&lt;/span> &lt;span class="nx">Num&lt;/span>&lt;span class="p">{&lt;/span>
&lt;span class="nx">uint&lt;/span> &lt;span class="nx">value&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="nx">mapping&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">uint&lt;/span> &lt;span class="p">=&amp;gt;&lt;/span> &lt;span class="nx">Num&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="nx">lookupTable&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="nx">numRegister&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">uint&lt;/span> &lt;span class="nx">key&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">uint&lt;/span> &lt;span class="nx">_value&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="nx">lookupTable&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="nx">key&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">value&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">_value&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="nx">addValue&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">uint&lt;/span> &lt;span class="nx">key&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="nx">view&lt;/span> &lt;span class="nx">returns&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">uint&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="k">return&lt;/span> &lt;span class="nx">lookupTable&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="nx">key&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">value&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="mi">5&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Main.sol没有多大变化&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-js" data-lang="js">&lt;span class="nx">pragma&lt;/span> &lt;span class="nx">solidity&lt;/span> &lt;span class="o">^&lt;/span>&lt;span class="mf">0.5&lt;/span>&lt;span class="mf">.0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="nx">contract&lt;/span> &lt;span class="nx">Main&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="nx">Add&lt;/span> &lt;span class="nx">add&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="nx">constructor&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">address&lt;/span> &lt;span class="nx">_m&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="nx">add&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">Add&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">_m&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="nx">Addnumber&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="nx">view&lt;/span> &lt;span class="nx">returns&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">uint&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="k">return&lt;/span> &lt;span class="nx">add&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">addValue&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">5&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="nx">contract&lt;/span> &lt;span class="nx">Add&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="nx">addValue&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">uint&lt;/span> &lt;span class="nx">key&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="nx">view&lt;/span> &lt;span class="nx">returns&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">uint&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>仍然是先编译部署Add合约，部署后调用numRegister函数写入数值5，并调用addValue函数测试返回。&lt;/p>
&lt;p>&lt;figure>&lt;img src="https://NamiChen.github.io/svg/loading.min.svg" data-sizes="auto" data-src="https://picped-1301226557.cos.ap-beijing.myqcloud.com/YJS_20191108_68472316-2d174280-025b-11ea-96a6-51af8dd4fd4c.png" alt="deploy comlex Add" class="lazyload">&lt;figcaption class="image-caption">deploy comlex Add&lt;/figcaption>&lt;/figure>&lt;/p>
&lt;p>接着编译部署Main合约，复制Add合约地址作为初始化参数，部署后调用Addnumber函数测试&lt;/p>
&lt;p>&lt;figure>&lt;img src="https://NamiChen.github.io/svg/loading.min.svg" data-sizes="auto" data-src="https://picped-1301226557.cos.ap-beijing.myqcloud.com/YJS_20191108_68472331-399b9b00-025b-11ea-933f-8c03ff95c55a.png" alt="deploy comlex Main" class="lazyload">&lt;figcaption class="image-caption">deploy comlex Main&lt;/figcaption>&lt;/figure>&lt;/p>
&lt;h3 id="33-总结">3.3 总结&lt;/h3>
&lt;p>合约内的调用方法是相同的，都要先实例化，然后传入被调合约地址，接着才能调用。而写在不同sol文件中时，需要额外声明被调合约的抽象合约，有些文章中说使用&lt;code>call&lt;/code>，&lt;code>callcode&lt;/code>或&lt;code>delegatecall&lt;/code>，但并不建议，因为这三个函数都是非常底层的函数，破坏了类型的安全，只能作为最后的手段使用。&lt;/p>
&lt;p>详细的解释参考了&lt;a href="https://ethereum.stackexchange.com/questions/9733/calling-function-from-deployed-contract" target="_blank">StackExchange-Calling function from deployed contract&lt;/a>&lt;/p>
&lt;h2 id="4-函数修饰词pure和view">4. 函数修饰词pure和view&lt;/h2>
&lt;p>转自&lt;a href="https://learnblockchain.cn/docs/solidity/contracts.html#view" target="_blank">深入理解Solidity-函数&lt;/a>&lt;/p>
&lt;p>这两个函数修饰词的作用是告诉编译器函数是否会读取/修改状态，view 表示保证不修改状态，pure 表示保证不读取也不修改状态。Solidity v0.4.17 之前没有这两个修饰词，而是使用 constant 关键字，和 view 的含义相同，不过在 v0.5.0 之后被移除，现在只能使用这两个 view 和 pure。&lt;/p>
&lt;h3 id="41-view-视图函数">4.1 view 视图函数&lt;/h3>
&lt;p>Getter 方法会被自动标记为 &lt;code>view&lt;/code>，除此之外，一个 view 修饰的例子如下&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-solidity" data-lang="solidity">&lt;span class="kr">pragma solidity&lt;/span> &lt;span class="o">&amp;gt;=&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">5&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span> &lt;span class="o">&amp;lt;&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">contract&lt;/span> &lt;span class="n">C&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">f&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kt">uint&lt;/span> &lt;span class="n">b&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="kr">view&lt;/span> &lt;span class="k">returns&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="k">return&lt;/span> &lt;span class="n">a&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">b&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="mi">42&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="nb">now&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>view 保证函数不修改状态，以下操作会被认为是修改状态&lt;/p>
&lt;ol>
&lt;li>修改状态变量。&lt;/li>
&lt;li>产生事件。&lt;/li>
&lt;li>创建其它合约。&lt;/li>
&lt;li>使用 &lt;code>selfdestruct&lt;/code>。&lt;/li>
&lt;li>通过调用发送以太币。&lt;/li>
&lt;li>调用任何没有标记为 &lt;code>view&lt;/code> 或者 &lt;code>pure&lt;/code> 的函数。&lt;/li>
&lt;li>使用低级调用。&lt;/li>
&lt;li>使用包含特定操作码的内联汇编。&lt;/li>
&lt;/ol>
&lt;h3 id="42-pure-纯函数">4.2 pure 纯函数&lt;/h3>
&lt;p>pure 保证不读取也不修改状态，不修改的定义上面已经提到，下面的操作被认为是读取状态&lt;/p>
&lt;ol>
&lt;li>读取状态变量。&lt;/li>
&lt;li>访问 &lt;code>address(this).balance&lt;/code> 或者 &lt;code>.balance&lt;/code>。&lt;/li>
&lt;li>访问 &lt;code>block&lt;/code>，&lt;code>tx&lt;/code>， &lt;code>msg&lt;/code> 中任意成员 （除 &lt;code>msg.sig&lt;/code> 和 &lt;code>msg.data&lt;/code> 之外）。&lt;/li>
&lt;li>调用任何未标记为 &lt;code>pure&lt;/code> 的函数。&lt;/li>
&lt;li>使用包含某些操作码的内联汇编。&lt;/li>
&lt;/ol>
&lt;p>一个 pure 修饰的例子如下&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-solidity" data-lang="solidity">&lt;span class="kr">pragma solidity&lt;/span> &lt;span class="o">&amp;gt;=&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">5&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span> &lt;span class="o">&amp;lt;&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">contract&lt;/span> &lt;span class="n">C&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kd">function&lt;/span> &lt;span class="n">f&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kt">uint&lt;/span> &lt;span class="n">b&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="kr">public&lt;/span> &lt;span class="kr">pure&lt;/span> &lt;span class="k">returns&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kt">uint&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="k">return&lt;/span> &lt;span class="n">a&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">b&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="mi">42&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="5-浮点数处理">5. 浮点数处理&lt;/h2>
&lt;p>首先声明，Solidity 中支持浮点数定义，但无法赋值和进行计算。文档中对其描述是「目前还不完全支持」，虽然这意味着以后可能会完全支持，但等不及了，下面记录几个可参考的资料。&lt;/p>
&lt;ol>
&lt;li>来自 &lt;a href="https://ethereum.stackexchange.com/questions/83785/what-fixed-or-float-point-math-libraries-are-available-in-solidity" target="_blank">ethereum stackexchange&lt;/a> 中的回答，介绍了一些可用的库；&lt;/li>
&lt;li>&lt;a href="https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMathQuad.md" target="_blank">ABDK Math Quad&lt;/a>，包含两个合约库，一个支持定点数，一个支持浮点数；&lt;/li>
&lt;li>Mikhail Vladimirov 的 &lt;a href="https://medium.com/coinmonks/math-in-solidity-part-1-numbers-384c8377f26d" target="_blank">Math in Solidity&lt;/a> 系列文章，介绍如何在 Solidity 中处理各种数学运算，写的非常棒。&lt;/li>
&lt;/ol>
&lt;h2 id="6-地址类型">6. 地址类型&lt;/h2>
&lt;p>在智能合约中显式传入地址类型时，可能会出现如下错误&lt;/p>
&lt;blockquote>
&lt;p>Address checksum&lt;/p>
&lt;p>This looks like an address but has an invalid checksum. If this is not used as an address, please prepend &amp;lsquo;00&amp;rsquo;.&lt;/p>
&lt;/blockquote>
&lt;p>关于该问题的一个讨论见 &lt;a href="https://github.com/ethereum/EIPs/issues/55">https://github.com/ethereum/EIPs/issues/55&lt;/a>&lt;/p>
&lt;p>这是因为合约中现在使用地址类型必须做一个转换，不是简单的全部大写字母或小写字母，而是遵循一定的规则，这个规则见 &lt;a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md" target="_blank">ethereum/EIPs#55&lt;/a>&lt;/p>
&lt;p>但是网上提供的解决方案一般是使用JS库中的转换函数，在智能合约中无法直接解决，好在，web3提供了一个&lt;a href="https://web3-tools.netlify.com/" target="_blank">在线API接口&lt;/a>，可以调用其&lt;code>checkAddressChecksum&lt;/code>函数对地址进行转换，然后将转换后的结果直接用于合约代码。&lt;/p>
&lt;h2 id="7-gas-limit问题">7. Gas limit问题&lt;/h2>
&lt;p>在搭建的以太坊私链上进行智能合约部署时，出现了以下问题&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre class="chroma">&lt;code class="language-js" data-lang="js">&lt;span class="nx">INFO&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mi">03&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="mi">21&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="mi">13&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mi">50&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mf">11.690&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="nx">Served&lt;/span> &lt;span class="nx">eth_sendTransaction&lt;/span> &lt;span class="nx">reqid&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">24&lt;/span> &lt;span class="nx">t&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mf">684.186&lt;/span>&lt;span class="nx">µs&lt;/span> &lt;span class="nx">err&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;exceeds block gas limit&amp;#34;&lt;/span>
&lt;span class="nb">Error&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="nx">exceeds&lt;/span> &lt;span class="nx">block&lt;/span> &lt;span class="nx">gas&lt;/span> &lt;span class="nx">limit&lt;/span> &lt;span class="kc">undefined&lt;/span>
&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>出现该错误的原因如错误描述，是当前合约所需的gas超过了区块的最大gas。这可能与参数gasLimit有关。在创世区块的配置文件中，我们使用了默认的配置值，为&lt;code>0x2fefd8&lt;/code>，转换为10进制即&lt;code>3141592&lt;/code>。&lt;/p>
&lt;p>注：&lt;a href="http://tool.oschina.net/hexconvert/" target="_blank">在线转换工具&lt;/a>&lt;/p></description></item><item><title>研究记录13-添加恶意行为检测机制</title><link>https://NamiChen.github.io/2020/credit-based-mechanism/</link><pubDate>Tue, 28 Apr 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/credit-based-mechanism/</guid><description>&lt;p>吸收了一些新论文的想法，对原访问控制系统功能做了补充，添加了恶意行为检测（或者称为动态访问控制），目的是减少恶意行为，增加合法行为在区块链中得到确认的几率。所有调整总结查看 &lt;a href="#jump">附录I&lt;/a>。&lt;/p></description></item><item><title>An Attribute-Based Distributed Access Control for Blockchain-enabled IoT</title><link>https://NamiChen.github.io/2020/an-attribute-based-distributed-access-control-for-blockchain-enabled-iot/</link><pubDate>Wed, 22 Apr 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/an-attribute-based-distributed-access-control-for-blockchain-enabled-iot/</guid><description>P. Wang, Y. Yue, W. Sun, and J. Liu, “An Attribute-Based Distributed Access Control for Blockchain-enabled IoT,” in 2019 International Conference on Wireless and Mobile Computing, Networking and Communications (WiMob), Barcelona, Spain, Oct. 2019, pp. 1–6, doi: 10.1109/WiMOB.2019.8923232. 第一作者是西电的，国家自然科学基金项目成果，研</description></item><item><title>Attribute-Based Access Control</title><link>https://NamiChen.github.io/2020/attribute-based-access-control/</link><pubDate>Wed, 22 Apr 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/attribute-based-access-control/</guid><description>V. C. Hu, D. R. Kuhn, and D. F. Ferraiolo, “Attribute-Based Access Control,” Computer, vol. 48, no. 2, pp. 85–88, Feb. 2015, doi: 10.1109/MC.2015.33. 1. 引言 传统的访问控制基于用户身份（分</description></item><item><title>Supply Chain Management Automation using Wireless Sensor Networks</title><link>https://NamiChen.github.io/2020/supply-chain-management-automation-using-wireless-sensor-networks/</link><pubDate>Mon, 20 Apr 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/supply-chain-management-automation-using-wireless-sensor-networks/</guid><description>L. Evers and P. Havinga, “Supply Chain Management Automation using Wireless Sensor Networks,” in 2007 IEEE Internatonal Conference on Mobile Adhoc and Sensor Systems, Pisa, Italy, Oct. 2007, pp. 1–3, doi: 10.1109/MOBHOC.2007.4428689. 注：插图来自原论文和网络。 1. 引言 这篇论文</description></item><item><title>Blockchain and Deep Reinforcement Learning Empowered Intelligent 5G Beyond</title><link>https://NamiChen.github.io/2020/blockchain-and-deep-reinforcement-learning-empowered-intelligent-5g-beyond/</link><pubDate>Mon, 13 Apr 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/blockchain-and-deep-reinforcement-learning-empowered-intelligent-5g-beyond/</guid><description>Day Y, Xu D, Maharjan S, 等. Blockchain and Deep Reinforcement Learning Empowered Intelligent 5G Beyond[J]. IEEE Network, 2019, 33(3): 10–17. DOI:10.1109/MNET.2019.1800376. 1. 引言 区块链和 AI 会在 6G 中扮演关键角色，前者可保证分布式网络安全，后者可用于智能资源管</description></item><item><title>研究记录12-区块链与D2D内容缓存/计算卸载方向探索</title><link>https://NamiChen.github.io/2020/blockchain-for-d2d-cache-or-computing-offload/</link><pubDate>Fri, 03 Apr 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/blockchain-for-d2d-cache-or-computing-offload/</guid><description>1. 概念引入 论文1提到，一些邻近的用户设备（User Equipment, UE）组合其计算能力，服务于具有更高性能需求的应用可以叫做 ad-hoc cloud。实际应用需要解决</description></item><item><title>面对疫情区块链可以做些什么</title><link>https://NamiChen.github.io/2020/what-can-blockchain-do-during-the-covid-19/</link><pubDate>Mon, 16 Mar 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/what-can-blockchain-do-during-the-covid-19/</guid><description>这场年初爆发的疫情在国内控制住以后，反而开始在全世界其它国家蔓延，如大数据、5G等技术均在当前这场疫情中产生了自己的作用，区块链能做些什么，</description></item><item><title>LVChain： A Lightweight and Vote-based Blockchain for Access Control in the IoT</title><link>https://NamiChen.github.io/2020/lvchain-a-lightweight-and-vote-based-blockchain-for-access-control-in-the-iot/</link><pubDate>Fri, 14 Feb 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/lvchain-a-lightweight-and-vote-based-blockchain-for-access-control-in-the-iot/</guid><description>Yu, Yue &amp;amp; Zhang, Sheng &amp;amp; Chen, Chao &amp;amp; Zhong, Xiaoxiong. (2018). LVChain: A Lightweight and Vote-based Blockchain for Access Control in the IoT. 870-874. DOI: 10.1109/CompComm.2018.8780687 KeyWord: IoT, security, Blockchain, access authorization, BLE-based devies 注：插图经过重新绘制，照片来自原论文截图。 1. 引言 IoT与生活联系的越来</description></item><item><title>Efficient Distributed Authentication and Access Control System</title><link>https://NamiChen.github.io/2020/efficient-distributed-authentication-and-access-control-system/</link><pubDate>Sun, 09 Feb 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/efficient-distributed-authentication-and-access-control-system/</guid><description>Benhadj Djilali H., Tandjaoui D. (2019) Efficient Distributed Authentication and Access Control System Management for Internet of Things Using Blockchain. In: Renault É., Boumerdassi S., Leghris C., Bouzefrane S. (eds) Mobile, Secure, and Programmable Networking. MSPN 2019. Lecture Notes in Computer Science, vol 11557. Springer, Cham DOI：https://doi.org/10</description></item><item><title>A Blockchain based access control for IoT</title><link>https://NamiChen.github.io/2020/a-blockchain-based-access-control-for-iot/</link><pubDate>Thu, 06 Feb 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/a-blockchain-based-access-control-for-iot/</guid><description>Imen Riabi, Yosr Dhif, Hella Kaffel Ben Ayed, Khaled Zaatouri. A Blockchain based access control for IoT[C]. International Wireless Communications &amp;amp; Mobile Computing Conference (IWCMC), 2019. DOI: 10.1109/IWCMC.2019.8766506 Keywords: Access control, Blockchain, Smart Contract, Internet of Things 注：本文图片来自原论文。 1. 引入 作者的考虑主要基于三点 传统中心化的访</description></item><item><title>研究记录11-新访问控制方案的实现与测试</title><link>https://NamiChen.github.io/2020/optimize-the-implementation-and-testing-of-the-system/</link><pubDate>Wed, 15 Jan 2020 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2020/optimize-the-implementation-and-testing-of-the-system/</guid><description>&lt;p>根据之前几篇文章的分析，我们对优化后的新方案进行了实现，本篇介绍新方案的一些测试与验证过程。代码可以参考 BBRAC 仓库的 &lt;a href="https://github.com/shuzang/BBRAC/tree/truffle" target="_blank">truffle&lt;/a> 分支，但是该分支包括后面添加的恶意行为检测的内容，是进行了二次完善后的代码。&lt;/p></description></item><item><title>研究记录10-实验场景的分析与选择</title><link>https://NamiChen.github.io/2019/analysis-and-selection-of-experimental-scenes/</link><pubDate>Fri, 06 Dec 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/analysis-and-selection-of-experimental-scenes/</guid><description>&lt;p>考虑到开题时老师给的意见和编写论文的需要，这里再分析一次场景，并选择一个合适的纳入实验。&lt;/p></description></item><item><title>研究记录9-区块链用于物联网访问控制梳理</title><link>https://NamiChen.github.io/2019/blockchain-based-access-control-for-iot/</link><pubDate>Fri, 29 Nov 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/blockchain-based-access-control-for-iot/</guid><description>这篇文章是关于区块链用于物联网访问控制的总结，有两个目的，一是梳理脑子里的思路，指导接下来的研究方向，二是作为之后要完成的小论文的参考。 在开</description></item><item><title>区块链方向有参考价值的文章收集</title><link>https://NamiChen.github.io/2019/articles-about-blockchain/</link><pubDate>Tue, 26 Nov 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/articles-about-blockchain/</guid><description>很多区块链领域极有启发性的文章或者介绍极为详细的文章都很值得保存，以前直接将文章完整的转载过来，但最近发现这种方法占用空间而且毫无意义，因此</description></item><item><title>An ABAC Model in RFID Systems Based on DApp for Healthcare Environments</title><link>https://NamiChen.github.io/2019/an-abac-model-in-rfid-systems-based-on-dapp-for-healthcare-environments/</link><pubDate>Mon, 11 Nov 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/an-abac-model-in-rfid-systems-based-on-dapp-for-healthcare-environments/</guid><description>Figueroa, Añorga, and Arrizabalaga, “An Attribute-Based Access Control Model in RFID Systems Based on Blockchain Decentralized Applications for Healthcare Environments,” Computers, vol. 8, no. 3, p. 57, Jul. 2019, doi: 10.3390/computers8030057. Keywords: blockchain, smart contract, RFID, ABAC, access control, IoT, healthcare 1. 引言 在医疗领域</description></item><item><title>以太坊开发8-Truffle框架安装使用</title><link>https://NamiChen.github.io/2019/use-truffle-develop-ethereum-project/</link><pubDate>Wed, 06 Nov 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/use-truffle-develop-ethereum-project/</guid><description>Truffle和Ganache的安装使用 1. 安装Truffle 在Ubuntu18.04 下安装运行，要求Node.js版本高于v8.9.4 1 2 3</description></item><item><title>研究记录8-原始论文问题总结及优化考虑</title><link>https://NamiChen.github.io/2019/summary-of-problems-and-optimization-considerations-about-prototype-system/</link><pubDate>Thu, 31 Oct 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/summary-of-problems-and-optimization-considerations-about-prototype-system/</guid><description>本文介绍在论文复现过程中发现的一些问题和自己产生的一些想法。与原论文1设计架构的对比可以查看本文最后的对比表，点这里 直接跳转。 1. 应用场景思考</description></item><item><title>区块链学习6-IBFT共识</title><link>https://NamiChen.github.io/2019/ibft-consensus/</link><pubDate>Tue, 29 Oct 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/ibft-consensus/</guid><description>AMIS公司提出的 Istanbul Byzantine Fault Tolerance Consensus（简称IBFT或Istanbul BFT），是一个基于PBFT的交易一致性的共识。因为要考虑可能发</description></item><item><title>SEC-BlockEdge Security Threats in Blockchain-Edge based IIoT Network</title><link>https://NamiChen.github.io/2019/sec-blockedge-security-threats-in-blockchain-edge-based-iiot-network/</link><pubDate>Thu, 24 Oct 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/sec-blockedge-security-threats-in-blockchain-edge-based-iiot-network/</guid><description>Kumar, Tanesh &amp;amp; Braeken, An &amp;amp; Ramani, Vidhya &amp;amp; Ahmad, Ijaz &amp;amp; Harjula, Erkki &amp;amp; Ylianttila, Mika. (2019). SEC-BlockEdge: Security Threats in Blockchain-Edge based Industrial IoT Networks. 以一个木屋建造场景作为IIoT用例，简要介绍了一个区块链-边缘计算框架。然后以此为基础</description></item><item><title>Acceleration of Anomaly Detection in Blockchain Using In-GPU Cache</title><link>https://NamiChen.github.io/2019/acceleration-of-anomaly-detection-in-blockchain-using-in-gpu-cache/</link><pubDate>Wed, 16 Oct 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/acceleration-of-anomaly-detection-in-blockchain-using-in-gpu-cache/</guid><description>Morishima S, Matsutani H. Acceleration of anomaly detection in blockchain using in-GPU Cache[C]. international conference on big data and cloud computing, 2019: 244-251. 引言 区块链的不可篡改特性带来安全性的同时，由操作失误或密钥被盗造成的欺诈交易同样无法取消，因此</description></item><item><title>EdgeChain An Edge-IoT Framework and Prototype</title><link>https://NamiChen.github.io/2019/edgechain-an-edge-iot-framework-and-prototype/</link><pubDate>Tue, 15 Oct 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/edgechain-an-edge-iot-framework-and-prototype/</guid><description>EdgeChain设计 EdgeChain的核心思想是集成一个许可区块链和内部货币系统，将边缘云资源池与每个物联网设备的账户和资源使用行为关联</description></item><item><title>研究记录7-原始论文复现</title><link>https://NamiChen.github.io/2019/access-control-prototype-system-implementation/</link><pubDate>Tue, 15 Oct 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/access-control-prototype-system-implementation/</guid><description>&lt;p>本文是在前面搭建好的区块链实验平台基础上，对 Smart contract-based access control for the internet of things&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup> 这篇论文提出的访问控制方案进行复现，记录整个复现和测试的过程。&lt;/p></description></item><item><title>Securing Majority-Attack in Blockchain Using Machine Learning</title><link>https://NamiChen.github.io/2019/securing-majority-attack-in-blockchain-using-machine-learning/</link><pubDate>Thu, 10 Oct 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/securing-majority-attack-in-blockchain-using-machine-learning/</guid><description>Dey S. A Proof of Work: Securing Majority-Attack in Blockchain Using Machine Learning and Algorithmic Game Theory[J]. International Journal of Wireless and Microwave Technologies, 2018, 8(5): 1-9. Abstract 多数人攻击(majority-attack)对公链网络可能不是一个威胁，但对联盟链来</description></item><item><title>When Intrusion Detection Meets Blockchain Technology A Review</title><link>https://NamiChen.github.io/2019/when-intrusion-detection-meets-blockchain-technology-a-review/</link><pubDate>Thu, 03 Oct 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/when-intrusion-detection-meets-blockchain-technology-a-review/</guid><description>Meng W, Tischhauser E, Wang Q, et al. When Intrusion Detection Meets Blockchain Technology: A Review[J]. IEEE Access, 2018: 10179-10188. Abstract：以识别网络威胁和可能的事故为目的，入侵检测系统（IDS）已被广泛用于各种计算机网络</description></item><item><title>研究记录6-Quorum区块链实验平台搭建</title><link>https://NamiChen.github.io/2019/build-quorum-private-blockchain-network/</link><pubDate>Wed, 02 Oct 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/build-quorum-private-blockchain-network/</guid><description>&lt;p>上篇文章已经确定了使用 Quorum 区块链，本文记录搭建 Quorum 私有区块链网络的过程。值得一提的是，相比于之前区块链平台搭建的尝试，本篇所述内容已经是一个完整无冗余的方案，后续对区块链平台搭建过程的优化，更多的是根据具体情况进行取舍，以及使用新出的一些更好用的工具。&lt;/p></description></item><item><title>研究记录5-区块链与异常检测方向探索</title><link>https://NamiChen.github.io/2019/blockchain-and-anomaly-detection/</link><pubDate>Fri, 27 Sep 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/blockchain-and-anomaly-detection/</guid><description>对区块链进行异常检测（Anomaly detection）也是一个重要的方向，不过有的论文中也称作侵入检测（Intrusion detectio</description></item><item><title>研究记录4-利用虚拟机搭建实验平台(失败)</title><link>https://NamiChen.github.io/2019/using-virtual-machine-to-build-experimental-platform/</link><pubDate>Fri, 13 Sep 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/using-virtual-machine-to-build-experimental-platform/</guid><description>先声明结论：最后由于网络原因没有成功，这种在多台电脑中安装虚拟机来联网的方式是存在一定问题的，其次，本篇所述的搭建方法过于繁琐，稍有不慎需要</description></item><item><title>研究记录3-开题确定题目</title><link>https://NamiChen.github.io/2019/research-proposal-title-select/</link><pubDate>Sun, 14 Jul 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/research-proposal-title-select/</guid><description>待选题目 基于区块链的智能工厂支撑平台研究与设计 基于区块链的智能工厂存储与安全问题研究 基于智能合约的物联网访问控制方案设计与实现 基于区块链的物</description></item><item><title>A Novel Attribute-Based Access Control Scheme Using Blockchain for IoT</title><link>https://NamiChen.github.io/2019/a-novel-attribute-based-access-control-scheme-using-blockchain-for-iot/</link><pubDate>Mon, 03 Jun 2019 15:51:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/a-novel-attribute-based-access-control-scheme-using-blockchain-for-iot/</guid><description>&lt;p>Ding, Sheng, et al. &amp;ldquo;A Novel Attribute-Based Access Control Scheme Using Blockchain for IoT.&amp;rdquo; &lt;em>IEEE Access&lt;/em> 7 (2019): 38431-38441.&lt;/p>
&lt;p>DOI: &lt;a href="https://doi-org-s.webvpn.neu.edu.cn/10.1109/ACCESS.2019.2905846" target="_blank">10.1109/ACCESS.2019.2905846&lt;/a>&lt;/p>
&lt;p>KeyWord: Access control, attribute-based access control, blockchain, consortium blockchain, IoT&lt;/p>
&lt;p>注：插图经过重新绘制，照片来自原论文截图。&lt;/p>
&lt;h2 id="1-摘要">1. 摘要&lt;/h2>
&lt;p>随着智能设备数量的急剧增加，物联网近年来得到越来越多的关注和快速发展。它通过现有的网络基础设施有效地将物理世界与Internet集成在一起，以便在智能设备之间共享数据。然而，其复杂的大规模网络结构给物联网系统带来了新的安全风险和挑战。为了保证数据的安全性，传统的访问控制技术由于其复杂的访问管理和集中性导致可靠性不足，不适合直接用于物联网系统的访问控制。本文提出了一种新的基于属性的用于物联网系统的访问控制方案，大大简化了访问管理。我们使用区块链技术来记录属性的分发，以避免单点故障和数据篡改。访问控制过程也进行了优化，以满足对物联网设备进行高效和轻量化计算的需要。安全性和性能分析表明，该方案能够有效抵御多种攻击，并能在物联网系统中得到有效的实现。&lt;/p></description></item><item><title>A Blockchain-Based Solution for Enhancing Security and Privacy in Smart Factory</title><link>https://NamiChen.github.io/2019/a-blockchain-based-solution-for-enhancing-security-and-privacy-in-smart-factory/</link><pubDate>Fri, 24 May 2019 21:18:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/a-blockchain-based-solution-for-enhancing-security-and-privacy-in-smart-factory/</guid><description>&lt;p>Wan J, Li J, Imran M, et al. A Blockchain-Based Solution for Enhancing Security and Privacy in Smart Factory[J]. IEEE Transactions on Industrial Informatics, 2019.&lt;/p>
&lt;p>被引：2次&lt;/p>
&lt;h2 id="abstract">Abstract&lt;/h2>
&lt;p>通过IIoT，智能工厂进入了蓬勃发展的时期。但是，随着节点数量和网络规模的扩大，传统的IIoT架构无法再为这样庞大的系统提供有效支持。因此，我们引入了区块链。它是一种用于构建分布式网络的新兴方案，用于重塑传统的IIoT架构。首先，分析了传统IIoT架构的主要问题，总结了现有的改进。其次，我们引入了一个安全和隐私模型来帮助设计基于区块链的架构。在此基础上，我们分解并重新组织原始的IIoT架构，以形成一个新的，多中心，部分分散的架构。然后，我们引入一些相关的安全技术，以改进和优化新架构。之后，我们设计了数据交互过程和架构的算法。最后，我们使用自动生产平台来讨论具体的实现。实验结果表明，与传统架构相比，该架构提供了更好的安全性和隐私保护。因此，所提出的架构代表了原始架构的重大改进，这为IIoT开发提供了新的方向&lt;/p>
&lt;blockquote>
&lt;p>原因：节点数量和网络规模扩大，传统的IIoT架构无法再为这样庞大的系统提供有效支持。&lt;/p>
&lt;ol>
&lt;li>传统IIoT问题和现有改进（Section I）&lt;/li>
&lt;li>设计基于区块链的架构(Section II)&lt;/li>
&lt;li>安全与隐私模型(Section III)&lt;/li>
&lt;li>设计数据交互过程和算法(Section IV)&lt;/li>
&lt;li>使用自动生产平台具体实施(Section V)&lt;/li>
&lt;/ol>
&lt;/blockquote></description></item><item><title>A Review on the Application of Blockchain to the Next Generation</title><link>https://NamiChen.github.io/2019/a-review-on-the-application-of-blockchain-to-the-next-generation/</link><pubDate>Thu, 23 May 2019 17:11:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/a-review-on-the-application-of-blockchain-to-the-next-generation/</guid><description>&lt;p>Fernández-Caramés T M, Fraga-Lamas P. A Review on the Application of Blockchain for the Next Generation of Cybersecure Industry 4.0 Smart Factories[J]. arXiv preprint arXiv:1902.09604, 2019.&lt;/p>
&lt;p>DOI: &lt;a href="https://doi.org/10.1109/ACCESS.2019.2908780" target="_blank">10.1109/ACCESS.2019.2908780&lt;/a>&lt;/p>
&lt;h2 id="abstract">Abstract&lt;/h2>
&lt;p>工业4.0是一个旨在通过使用一些最新技术改进现代工厂运作方式的概念，例如用于创建工业物联网（IIoT），机器人或大数据应用的技术。其中一种技术是区块链，它能够为不同的工业领域增加信任，安全性和去中心化特性。本文重点分析使用区块链和智能合约开发工业4.0应用时产生的好处和挑战。此外，本文还对工业4.0技术中最相关的基于区块链的应用进行了全面的回顾。因此，其目的是为未来的工业4.0开发人员提供详细指南，以确定区块链如何增强下一代网络工业应用的网络安全。&lt;/p></description></item><item><title>Smart Contract-Based Access Control for the Internet of Things</title><link>https://NamiChen.github.io/2019/smart-contract-based-access-control-for-the-internet-of-things/</link><pubDate>Tue, 14 May 2019 19:10:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/smart-contract-based-access-control-for-the-internet-of-things/</guid><description>Zhang Y, Kasahara S, Shen Y, et al. Smart contract-based access control for the internet of things[J]. IEEE Internet of Things Journal, 2018. 被引：35次 Abstract 该论文调查了物联网中的访问控制问题。提出了一个基于智能合约的访问控制框架，该框架</description></item><item><title>Authentication and Authorization for the Internet of Things</title><link>https://NamiChen.github.io/2019/authentication-and-authorization-for-the-internet-of-things/</link><pubDate>Tue, 14 May 2019 15:14:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/authentication-and-authorization-for-the-internet-of-things/</guid><description>&lt;p>Kim H, Lee E A. Authentication and Authorization for the Internet of Things[J]. IT Professional, 2017, 19(5): 27-33.&lt;/p>
&lt;p>核心：locally centralized, globally distributed的认证与授权&lt;/p>
&lt;p>引入：由2016年DNS服务商Dyn受到的DDoS攻击说明物联网带来的安全挑战。由2015年乌克兰电网受到的攻击说明物联网遭受攻击的后果更具破坏性。这两者反映的是，物联网设备缺乏相应的访问控制机制，导致面对攻击不够健壮。&lt;/p></description></item><item><title>Blockchain Paradigm and Internet of Things</title><link>https://NamiChen.github.io/2019/blockchain-paradigm-and-internet-of-things/</link><pubDate>Mon, 13 May 2019 15:42:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/blockchain-paradigm-and-internet-of-things/</guid><description>&lt;p>Valentin Rakovic， Jovan Karamachoski，Vladimir Atanasovski，Liljana Gavrilovska&lt;/p>
&lt;p>Published online: 21 March 2019&lt;/p>
&lt;p>Wireless Personal Communications (2019) 106:219–235
&lt;a href="https://doi.org/10.1007/s11277-019-06270-9">https://doi.org/10.1007/s11277-019-06270-9&lt;/a>&lt;/p>
&lt;h2 id="abstract">Abstract&lt;/h2>
&lt;p>区块链是在分布式网络中提供隐私和安全的分布式分类账技术，这使得它适用于具有分布式特性的物联网。然而，区块链需要高计算能力，有高带宽开销和延迟，不适合物联网场景，为了将区块链和物联网结合，许多研究旨在开发针对于特定物联网场景需求的区块链方法。本文详细介绍了物联网区块链集成的相关问题，对当前文献和相关部署测试做了全面调查，指出了当前主要的研究和面临的挑战，并讨论了未来可能的研究领域。&lt;/p></description></item><item><title>Industry 4.0 Development and Application of Intelligent Manufacturing</title><link>https://NamiChen.github.io/2019/industry-4.0-development-and-application-of-intelligent-manufacturing/</link><pubDate>Mon, 15 Apr 2019 14:22:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/industry-4.0-development-and-application-of-intelligent-manufacturing/</guid><description>&lt;p>Author：Guo-Jian Cheng, Li-Ting Liu, Xin-Jian Qiang, Ye Liu&lt;/p>
&lt;p>Published in：2016 International Conference on Information System and Artificial Intelligence (ISAI)&lt;/p>
&lt;p>Conference Location：Hong Kong, China&lt;/p>
&lt;p>Cited times：30&lt;/p>
&lt;h2 id="abstract">Abstract&lt;/h2>
&lt;p>过去几年，工业和信息技术领域经历了深刻的变革，进入了工业4.0时代，将从嵌入式系统演变到网络物理系统（CPS）。制造业将通过互联网，整合内部和外部网络，朝着智能化方向发展。本文介绍工业4.0的发展，并以120的智慧信息技术（WIT120）为例介绍网络物理系统，然后通过数字工厂到智能工厂的例子介绍工业4.0在智能制造中的应用。最后分析工业4.0在未来的发展方向，为其在智能制造中的应用提供参考。&lt;/p></description></item><item><title>提取以太坊的区块产生时间</title><link>https://NamiChen.github.io/2019/extract-the-block-generation-time-of-ethereum/</link><pubDate>Fri, 05 Apr 2019 21:35:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/extract-the-block-generation-time-of-ethereum/</guid><description>&lt;h2 id="前言">前言&lt;/h2>
&lt;p>目的是提取以太坊的区块产生时间形成数据集，初步的思路有两种：&lt;/p>
&lt;ul>
&lt;li>爬取以太坊区块浏览器中的时间数据，然后格式化形成数据集输出&lt;/li>
&lt;li>同步以太坊的所有区块（头），利用以太坊本身提供的接口提取每个区块的时间戳信息，然后将时间戳转换为真实的日期格式形成数据集输出，&lt;a href="https://tool.lu/timestamp/" target="_blank">时间戳转换在线工具&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>查询资料过程中，了解到谷歌已提供以太坊的区块信息数据集&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup>。虽然数据集本身没有时间信息，但可以导出时间戳进行转换，了解到谷歌使用的工具是&lt;a href="https://github.com/blockchain-etl/ethereum-etl#blockscsv" target="_blank">ethereum-etl&lt;/a>，故最终的解决方案是：使用ethereum-etl导出时间戳，编写Python程序转换时间戳并导出数据集。&lt;/p></description></item><item><title>研究记录2-区块链平台选择的思考</title><link>https://NamiChen.github.io/2019/blockchain-platform-compare-and-select/</link><pubDate>Mon, 01 Apr 2019 13:11:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/blockchain-platform-compare-and-select/</guid><description>首先我们就 Ethereum 等九个平台做分析比较，从而确定要用来作为实验平台的区块链。 1. Ethereum 关于存储 以太坊生态中的一些工具和技术是用来解决大数据量存储问题的，</description></item><item><title>Distributed Blockchain-Based Data Protection Framework for Modern Power Systems</title><link>https://NamiChen.github.io/2019/distributed-blockchain-based-data-protection-framework-for-modern-power-systems/</link><pubDate>Mon, 01 Apr 2019 11:16:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/distributed-blockchain-based-data-protection-framework-for-modern-power-systems/</guid><description>&lt;p>Author：Gaoqi Liang , Steven R. Weller, Fengji Luo , Junhua Zhao, Zhao Yang Dong&lt;/p>
&lt;p>Published in：IEEE Transactions on Smart Grid 2018(Early Access)&lt;/p>
&lt;p>期刊级别：SCI I区&lt;/p>
&lt;p>被引量：19次&lt;/p>
&lt;p>keywords：Blockchain, Modern power systems, Cyber-attacks, Distributed network, False data injection attacks&lt;/p>
&lt;h2 id="abstract">Abstract&lt;/h2>
&lt;p>现代电力系统的网络安全同时吸引了学术和工业界的关注，许多针对网络攻击的检测和防御手段因此而被提出。本文提出了一种新的基于区块链的分布式保护框架，用于增强现代电力系统应对网络攻击的自抵御能力。我们对区块链技术如何用于增强电网鲁棒性和安全性做了全面的讨论，使用电表作为分布式网络的节点，将电表的测量数据打包为区块。所提出方案的有效性通过基于IEEE-118节点系统的仿真实验来说明。&lt;/p></description></item><item><title>以太坊开发7-swarm存储网络使用</title><link>https://NamiChen.github.io/2019/swarm-storage-network-using/</link><pubDate>Thu, 28 Mar 2019 19:59:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/swarm-storage-network-using/</guid><description>&lt;p>说实话，swarm的资料比较难找，倒是IPFS的比较多一点。最后只在&lt;a href="http://medium.com/" target="_blank">Medium&lt;/a>找到了一些，本篇文章就是在实践其中的一些项目，并通过这样来学习swarm。&lt;/p>
&lt;p>参考链接：&lt;a href="https://swarm-gateways.net/bzz:/theswarm.eth/" target="_blank">swarm官网&lt;/a>，&lt;a href="https://swarm-guide.readthedocs.io/en/latest/introduction.html" target="_blank">swarm文档&lt;/a>，&lt;a href="https://github.com/ethersphere" target="_blank">github项目&lt;/a>&lt;/p>
&lt;p>还有一些帮助理解的资料：&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;a href="https://ethereum.stackexchange.com/questions/55027/swarm-in-a-private-network" target="_blank">关于swarm的三个理解上的问题&lt;/a>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;a href="https://github.com/ethersphere/go-ethereum/wiki/IPFS-&amp;amp;-SWARM" target="_blank">swarm和ipfs的比较&lt;/a>&lt;/p>
&lt;/li>
&lt;/ul></description></item><item><title>A Case Study for Blockchain in Manufacturing “FabRec”</title><link>https://NamiChen.github.io/2019/a-case-study-for-blockchain-in-manufacturing-fabrec/</link><pubDate>Mon, 25 Mar 2019 10:13:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/a-case-study-for-blockchain-in-manufacturing-fabrec/</guid><description>&lt;p>Author：Atin Angrisha, Benjamin Cravera, Mahmud Hasana, Binil Starly&lt;/p>
&lt;p>Published in：46th SME North American Manufacturing Research Conference, NAMRC 46, Texas, USA&lt;/p>
&lt;p>被引量：7次&lt;/p>
&lt;p>keywords：blockchain; cyber-physical systems; smart contracts; ethereum; decentralized networks; shareable databases&lt;/p>
&lt;h2 id="abstract">Abstract&lt;/h2>
&lt;p>随着产品定制成为新的商机，制造商必须找到在无信任网络中进行协作和实现信息共享的方法。在本文中，我们提出“FabRec”：一种用于处理由各制造商使用区块链技术产生的制造信息的方法。其中，制造机器和计算节点构成去中心化网络来实现制造过程的自动化与透明化，基于对历史记录的审计实现对制造过程的第三方验证，使用智能合约实现参与者之间无纸化合同。同时，系统将与制造相关的信息分类，并使其在P2P网络上可用，以通过可验证的审计跟踪确保透明度和数据来源。我们通过组合制造机器，片上系统（SoC, System on chip）和计算节点来建立测试平台，以展示组成联盟的不同制造商可以通过分布式网络进行通信的机制。我们的测试平台原型展示了驻留在分布式网络上的计算机代码的价值：用于验证区块链的信息以及在物理世界中自动启动操作的方式。本文旨在通过测试平台揭示系统组成，为更大规模的测试做准备，并讨论区块链在制造业的未来潜力。&lt;/p></description></item><item><title>LightChain:A Lightweight Blockchain System for Industrial Internet of Things</title><link>https://NamiChen.github.io/2019/lightchaina-lightweight-blockchain-system-for-industrial-internet-of-things/</link><pubDate>Tue, 19 Mar 2019 11:00:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/lightchaina-lightweight-blockchain-system-for-industrial-internet-of-things/</guid><description>&lt;p>Author： Yinqiu Liu, Kun Wang, Yun Lin, and Wenyao Xu&lt;/p>
&lt;p>Published in：IEEE Transactions on Industrial Informatics&lt;/p>
&lt;p>State：Early Access&lt;/p>
&lt;p>Index Terms：Blockchain, Industrial Internet of Things, Distributed System, Consensus Mechanism, Data Filter.&lt;/p>
&lt;h2 id="abstract">Abstract&lt;/h2>
&lt;p>虽然区块链和IIoT之间的结合得到了广泛的关注，但区块链的高资源需求和IIoT设备的有限性能之间的矛盾还无法较好的解决。一方面，由于公钥结构、默克尔树和PoW等数学概念的引入，部署区块链需要巨大的算力；另一方面，全节点应该能同步大量的区块数据和处理P2P网络中的大量交易。IIoT设备难以承受其对存储容量和带宽的占用。本文中，我们提出了名为&lt;strong>LightChain&lt;/strong>的轻量级区块链使其适用于IIoT场景，提出了一个名为**Synergistic Multiple Proof（SMP）&lt;strong>的共识机制来促进IIoT设备间的合作，提出了一种称为&lt;/strong>LightBlock（LB）**的轻量级数据结构，用于简化广播内容。此外，还设计了一种 **Unrelated Block Offloading Filter (UBOF)**以避免分类帐的无限增长，同时不影响区块链的可追溯性。实验表明，LightChain可以将计算成本降低39.32％，将块生成速度提高74.06％。在存储和网络使用方面，降幅分别为43.35％和90.55％。&lt;/p></description></item><item><title>研究记录1-区块链的数据存储问题</title><link>https://NamiChen.github.io/2019/data-storage-in-blockchain/</link><pubDate>Sat, 16 Mar 2019 09:11:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/data-storage-in-blockchain/</guid><description>区块链的本质是一个只增数据库，这就意味着其中存储的数据会随着时间的推移不断增加，而区块链分布式的特性要求节点需要存储区块链的整个副本，因此，</description></item><item><title>以太坊开发6-Docker搭建以太坊私链</title><link>https://NamiChen.github.io/2019/use-docker-to-build-ethereum-private-chain/</link><pubDate>Tue, 12 Mar 2019 11:24:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/use-docker-to-build-ethereum-private-chain/</guid><description>&lt;p>在以太坊github的&lt;a href="https://github.com/ethereum/go-ethereum" target="_blank">官方项目地址&lt;/a>发现其支持Docker启动，同时因为Docker相对于虚拟机的易用性，决定尝试使用Docker搭建以太坊联盟链&lt;/p>
&lt;p>Docker安装部分查看自官方说明，搭建过程主要参考&lt;a href="https://www.jianshu.com/p/7994db7a2b89?from=singlemessage" target="_blank">简书-使用Docker搭建以太坊私有链并部署合约&lt;/a>&lt;/p>
&lt;h2 id="一docker安装">一、Docker安装&lt;/h2>
&lt;p>OS环境：Ubuntu 18.04 LTS(bionic)&lt;/p>
&lt;p>内核版本：4.18.0-16-generic&lt;/p>
&lt;p>处理器架构：amd64&lt;/p>
&lt;p>官方的安装说明位于：&lt;a href="https://docs.docker.com/install/linux/docker-ce/ubuntu/" target="_blank">Get Docker CE for Ubuntu&lt;/a>&lt;/p></description></item><item><title>以太坊开发5-以太坊节点连接到网络的几种方式</title><link>https://NamiChen.github.io/2019/the-way-to-connect-to-the-network-about-ethereum-node/</link><pubDate>Tue, 12 Mar 2019 08:33:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/the-way-to-connect-to-the-network-about-ethereum-node/</guid><description>文章翻译自：Connecting to the network 如何寻找对等节点 在初始化时，geth会使用一组记录在源码中的bootstrap节点来连接。要指定这些节</description></item><item><title>以太坊开发4-geth console命令</title><link>https://NamiChen.github.io/2019/geth-console-command/</link><pubDate>Fri, 08 Mar 2019 10:27:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/geth-console-command/</guid><description>&lt;p>Geth Console是一个交互式的JavaScript执行环境，其中&lt;code>&amp;gt;&lt;/code>是命令提示符。在这个环境里也内置了一些用来操作以太坊的JavaScript对象，可以直接使用这些对象。这些对象主要包括：&lt;/p>
&lt;ul>
&lt;li>eth：包含一些跟操作区块链相关的方法；&lt;/li>
&lt;li>net：包含一些查看p2p网络状态的方法；&lt;/li>
&lt;li>admin：包含一些与管理节点相关的方法；&lt;/li>
&lt;li>miner：包含启动&amp;amp;停止挖矿的一些方法；&lt;/li>
&lt;li>personal：主要包含一些管理账户的方法；&lt;/li>
&lt;li>txpool：包含一些查看交易内存池的方法；&lt;/li>
&lt;li>web3：包含了以上对象，还包含一些单位换算的方法。&lt;/li>
&lt;/ul></description></item><item><title>以太坊开发3-geth客户端命令</title><link>https://NamiChen.github.io/2019/geth-client-use/</link><pubDate>Fri, 08 Mar 2019 09:26:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/geth-client-use/</guid><description>Geth是以太坊智能合约开发工具，是一个命令行工具，所以熟悉其命令参数有助于提高开发效率。本文是geth help的翻译，基于geth 1.8.</description></item><item><title>以太坊开发2-创世区块文件genesis.json</title><link>https://NamiChen.github.io/2019/%E4%BB%A5%E5%A4%AA%E5%9D%8A%E5%BC%80%E5%8F%912-%E5%88%9B%E4%B8%96%E5%8C%BA%E5%9D%97%E6%96%87%E4%BB%B6genesis.json/</link><pubDate>Thu, 07 Mar 2019 19:48:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/%E4%BB%A5%E5%A4%AA%E5%9D%8A%E5%BC%80%E5%8F%912-%E5%88%9B%E4%B8%96%E5%8C%BA%E5%9D%97%E6%96%87%E4%BB%B6genesis.json/</guid><description>文件说明 关于genesis.json的官方说明位于两处 Private network Connecting to the network 每条区块链都以创世区块开头，而genesis.json正是创世区块的配置文</description></item><item><title>以太坊开发1-虚拟机搭建以太坊私链</title><link>https://NamiChen.github.io/2019/use-virtual-machine-builds-ethereum-private-chain/</link><pubDate>Thu, 07 Mar 2019 14:53:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/use-virtual-machine-builds-ethereum-private-chain/</guid><description>一、单虚拟机 最简单的方式是使用一个虚拟机，这也是在条件有限的情况下的最好选择。方法是在一台虚拟机上启用多个终端，每个终端使用不同的端口通信。</description></item><item><title>Blockchain-Based Platform Architecture for Industrial IoT</title><link>https://NamiChen.github.io/2019/blockchain-based-platform-architecture-for-industrial-iot/</link><pubDate>Thu, 28 Feb 2019 10:50:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/blockchain-based-platform-architecture-for-industrial-iot/</guid><description>&lt;p>Author：Nikolay Teslya; Igor Ryabchikov&lt;/p>
&lt;p>Published in：2017 21st Conference of Open Innovations Association(FRUCT)&lt;/p>
&lt;p>Date of Conference: 6-10 Nov. &lt;strong>2017&lt;/strong>&lt;/p>
&lt;p>会议举办地：Helsinki, Finland&lt;/p>
&lt;p>被引量：11次&lt;/p>
&lt;h2 id="摘要">摘要&lt;/h2>
&lt;p>机器人技术，物联网概念，大数据处理技术，自动化和分布式数字分类账技术的发展引发了第四次工业革命。新工业的主要问题之一是基于物联网的智能工厂内部组件以及工厂之间的互操作。这种互操作应该提供物联网参与者之间的信任;控制资源的分配（如维护时间，能源等）和成品。本文描述了集成物联网和区块链技术以解决这些问题的可能方法之一。为此，开发了一种结合了Smart-M3信息共享平台和区块链平台的架构。所提出的体系结构的一个主要特征是使用智能合约来处理和存储与智能空间组件之间的交互相关的信息。&lt;/p></description></item><item><title>Blockchain Platforms Overview for Industrial IoT Purpose</title><link>https://NamiChen.github.io/2019/blockchain-platforms-overview-for-industrial-iot-purpose/</link><pubDate>Wed, 27 Feb 2019 11:11:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/blockchain-platforms-overview-for-industrial-iot-purpose/</guid><description>&lt;p>Author：Nikolay Teslya; Igor Ryabchikov&lt;/p>
&lt;p>Published in：2018 22nd Conference of Open Innovations Association(FRUCT)&lt;/p>
&lt;p>Date of Conference: 15-18 May &lt;strong>2018&lt;/strong>&lt;/p>
&lt;p>会议举办地：Jyvaskyla, Finland&lt;/p>
&lt;p>被引量：1次&lt;/p>
&lt;h2 id="abstract">Abstract&lt;/h2>
&lt;p>如今已有很多可用区块链平台存在。但要集成到工业物联网的智能空间中，区块链平台不仅应支持代币交易，还应支持智能合约、容错共识机制，以及参与者创建和实施新区块和智能合约的地位的平等。本文分析了最常用的共识机制，公共（无权限）和私有（有权限）区块链的具体特征。还描述了满足IIoT平台开发要求的区块链平台。通过分析所得结果，可选择平台和特定模块来实现用于IIoT平台的区块链。&lt;/p></description></item><item><title>Decentralizing Privacy：Using Blockchain to Protect Personal Data</title><link>https://NamiChen.github.io/2019/decentralizing-privacyusing-blockchain-to-protect-personal-data/</link><pubDate>Thu, 14 Feb 2019 09:50:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/decentralizing-privacyusing-blockchain-to-protect-personal-data/</guid><description>&lt;p>Zyskind G, Nathan O, Pentland A, et al. Decentralizing Privacy: Using Blockchain to Protect Personal Data[C]. ieee symposium on security and privacy, 2015: 180-184.&lt;/p>
&lt;p>DOI: &lt;a href="https://doi.org/10.1109/SPW.2015.27" target="_blank">10.1109/SPW.2015.27&lt;/a>&lt;/p>
&lt;p>KeyWord: Protocols, Privacy, Data privacy, Online banking, Encryption, Compounds.&lt;/p>
&lt;p>注：部分插图经过重新绘制，部分来自原论文截图。&lt;/p>
&lt;h2 id="摘要">摘要&lt;/h2>
&lt;p>当前的商业模式下，第三方收集和控制了大量的个人隐私，损害了用户权益，越来愈多的安全事件使得这一模式开始受到质疑。比特币证明了通过一个分布式的公有分类账在金融领域进行可信和可审计的计算是可行的。因此，本文提出了一种基于区块链的分布式个人数据管理系统，用于保证用户对个人数据的所有权和控制权。与比特币不同的是，本文提出的系统中，区块链交易不是金融交易，而是用于携带指令，如存储、查询和共享数据等，在文章的最后也会讨论区块链未来可能的发展。&lt;/p></description></item><item><title>文献综述-区块链用于 IoT/IIoT：智能工厂案例</title><link>https://NamiChen.github.io/2019/blockchain-for-iot/iiota-smart-factory-case-study/</link><pubDate>Tue, 05 Feb 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/blockchain-for-iot/iiota-smart-factory-case-study/</guid><description>随着物联网的高速发展，越来越多的智能设备接入到了人们的日常生活和工业生产当中。尤其在智能工厂领域，物联网设备的使用大幅提高了工厂自动化程度，</description></item><item><title>Internet of Smart Things-IoST</title><link>https://NamiChen.github.io/2019/internet-of-smart-things-iost/</link><pubDate>Thu, 17 Jan 2019 10:06:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/internet-of-smart-things-iost/</guid><description>&lt;p>Author：Mayra Samaniego, Ralph Deters&lt;/p>
&lt;p>Published in：2017 IEEE International Conference on Cognitive Computing (ICCC)&lt;/p>
&lt;p>Date of Conference: 25-30 June 2017&lt;/p>
&lt;p>会议级别：不知道&lt;/p>
&lt;p>被引量：11次&lt;/p>
&lt;p>keywords：IoT; Management; Blockchain; Multichain;Smart Things; Autonomy;Self-inferencing; Self-monitoring;Fog; Edge.&lt;/p>
&lt;br/>
&lt;h3 id="摘要">摘要&lt;/h3>
&lt;p>构成物联网的大量异构设备需要有效的资源管理。随着雾计算的出现，一些管理任务可以下移到物联网的边缘，更靠近物理设备。建立在雾网络上的区块链可以处理一些物联网的管理任务，如通信、存储和身份验证。这种情况下，以及超越了原来对物联网中Things的定义，可以称之为“Smart Things&amp;rdquo;。Smart Things提供基于CLIPS编程语言的人工智能（AI）功能，以实现自我推理和自我监控。这项工作使用私链构建工具Multichain通过读写块中信息来达成Smart Things之间的通信。本文评估了Edison Arduino板上部署的Smart Things以及雾网络上部署的的Multichain网络。&lt;/p></description></item><item><title>区块链学习5-ETC和ETH</title><link>https://NamiChen.github.io/2019/ethereum-and-ethereum-classic/</link><pubDate>Wed, 16 Jan 2019 10:48:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/ethereum-and-ethereum-classic/</guid><description>最近ETC遭受疑似51%攻击的影响很大，虽然最后的结果还没出来，仍不确定是真的遭受了51%攻击，还是之前官方所称的ASIC矿机测试带来的问题</description></item><item><title>BlockChain：A Distributed Solution to Automotive Security and Privacy</title><link>https://NamiChen.github.io/2019/blockchaina-distributed-solution-to-automotive-security-and-privacy/</link><pubDate>Tue, 15 Jan 2019 19:40:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/blockchaina-distributed-solution-to-automotive-security-and-privacy/</guid><description>Abstract 智能车辆互联提供了一系列先进的服务，这有益于车主、运输当局、车辆制造商和其它服务提供者。但这也可能把智能汽车暴露在一系列安全和隐私威胁之下</description></item><item><title>背景调查4-区块链与智能工厂</title><link>https://NamiChen.github.io/2019/blockchain-for-smart-factory/</link><pubDate>Tue, 15 Jan 2019 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2019/blockchain-for-smart-factory/</guid><description>1. 背景 传统工厂向智能工厂转变是为了提高生产和管理效率，并高度灵活地适应不断变化的生产要求1。这一目的的达成部分依赖于大量来自于制造设备，工业</description></item><item><title>Blockchain in Internet of Things:Challenges and Solutions</title><link>https://NamiChen.github.io/2019/blockchain-in-internet-of-thingschallenges-and-solutions/</link><pubDate>Wed, 09 Jan 2019 09:50:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/blockchain-in-internet-of-thingschallenges-and-solutions/</guid><description>&lt;p>Author：Ali Dorri, Salil S. Kanhere, and Raja Jurdak&lt;/p>
&lt;p>arXiv预印（非正式发表）&lt;/p>
&lt;p>2016.08&lt;/p>
&lt;h3 id="abstract">Abstract&lt;/h3>
&lt;p>物联网产业在快速发展，但安全和隐私的问题始终没有解决。由于物联网分布式的拓扑结构和资源有限的设备，传统的安全和隐私方法不适用于物联网。区块链能用于保证和物联网具有相同拓扑的P2P网络的安全与隐私，因此应也能用于物联网，然后，BC是计算密集型的，需要较高带宽且延迟较高，并不适合物联网。本文提出一种基于BC技术的安全、私有和轻量级的架构，去除了BC的缺点，同时保留了其安全和隐私特性，使其适用于物联网。利用智能家居场景为例做了描述，整个架构分为智能家居层、覆盖网络层、云存储层三层。在各层使用了不同类型的BC，并对常见的安全威胁做了定性分析，证明了其保证物联网安全与隐私的有效性。&lt;/p></description></item><item><title>Blockchain for IoT Security and Privacy:The Case Study of a Smart Home</title><link>https://NamiChen.github.io/2019/blockchain-for-iot-security-and-privacythe-case-study-of-a-smart-home/</link><pubDate>Mon, 07 Jan 2019 14:55:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/blockchain-for-iot-security-and-privacythe-case-study-of-a-smart-home/</guid><description>&lt;p>Dorri, Ali &amp;amp; Kanhere, Salil &amp;amp; Jurdak, Raja &amp;amp; Gauravaram, Praveen. (2017). Blockchain for IoT Security and Privacy: The Case Study of a Smart Home. 10.1109/PERCOMW.2017.7917634.&lt;/p>
&lt;h3 id="abstract">Abstract&lt;/h3>
&lt;p>由于物联网网络大规模和分布式的特性，物联网（IoT）安全和隐私仍然是一个主要的挑战。基于区块链的方法可以提供分布式的安全性和隐私性，但会带来显著的能量、延迟和计算开销，不适合大多数资源受限的IoT设备。在我们之前的工作中，我们通过去除PoW（Proof of Work, 工作量证明）和货币（coins）的概念，提出了一个适用于物联网的BC（Blockchain, 区块链）的轻量级实例。我们的方法在智能家居环境中进行了验证，主要包括三层：云存储，overlay和智能家居。在本文中，我们深入研究并概述了智能家居层的各种核心组件和功能。每个智能家居都配备了一个永远在线的高资源设备，称为“miner”，负责处理家庭内外的所有通信。该miner还维护一个私有BC，用于控制和审计通信。我们通过彻底分析其在机密性，完整性和可用性的基本安全目标，表明我们提出的基于BC的智能家居框架是安全的。最后，我们利用仿真结果证明我们的方法引入的开销（在流量，处理时间和能耗方面）相对于其安全性和隐私性增益而言是微不足道的。&lt;/p></description></item><item><title>Bubbles of Trust：a decentralized Blockchain-based authentication system for IoT</title><link>https://NamiChen.github.io/2019/bubbles-of-trusta-decentralized-blockchain-based-authentication-system-for-iot/</link><pubDate>Thu, 03 Jan 2019 19:26:00 +0800</pubDate><guid>https://NamiChen.github.io/2019/bubbles-of-trusta-decentralized-blockchain-based-authentication-system-for-iot/</guid><description>Author：Mohamed Tahar Hammi, Badis Hammi, Patrick Bellot, Ahmed Serhrouchni Published in: Computers &amp;amp; Security(2018.6) SCI期刊分区：3区 Abstract 我们使用的许多东西都配备了电子设备和协议，以使它们互连和连接到互</description></item><item><title>Blockchain Meets IoT：An Architecture for Scalable Access Management in IoT</title><link>https://NamiChen.github.io/2018/blockchain-meets-iotan-architecture-for-scalable-access-management-in-iot/</link><pubDate>Fri, 28 Dec 2018 15:42:00 +0800</pubDate><guid>https://NamiChen.github.io/2018/blockchain-meets-iotan-architecture-for-scalable-access-management-in-iot/</guid><description>Novo O. Blockchain Meets IoT: An Architecture for Scalable Access Management in IoT[J]. IEEE Internet of Things Journal, 2018, 5(2): 1184-1195. DOI: 10.1109/JIOT.2018.2812239 keywords: Access control, Blockchain, IoT, smart contracts 摘要 物联网所面临的一个问题是部署在全球的数十亿的设备如何去管理，现有的访问管理技</description></item><item><title>Block Chain based Intelligent Industrial Network (DSDIN)</title><link>https://NamiChen.github.io/2018/block-chain-based-intelligent-industrial-network-dsdin/</link><pubDate>Fri, 14 Dec 2018 08:37:00 +0800</pubDate><guid>https://NamiChen.github.io/2018/block-chain-based-intelligent-industrial-network-dsdin/</guid><description>&lt;p>Author：Barco You, Matthias Hub, Mengzhe You, Bo Xu, Mingzhi Yu and Ican Uemlianin&lt;/p>
&lt;p>Published in：eprint arXiv:1809.06551(1809意为18年9月)&lt;/p>
&lt;p>SCI期刊分区：在arXic上，不算正式发表&lt;/p>
&lt;p>keywords：IIoT, BC, Artificial Intelligence, Industry 4.0, Intelligent Manufacturing, Edge Computing.&lt;/p>
&lt;p>&lt;strong>主题&lt;/strong>：如何为IIoT构建一个全球范围的分布式工业网络&lt;/p>
&lt;p>&lt;strong>主要工作&lt;/strong>：&lt;/p>
&lt;ol>
&lt;li>综述。从工业互联网讲到工业物联网，最后讲到基于区块链的工业物联网&lt;/li>
&lt;li>详细描述了所构建的基于区块链的智能工业网络DSDIN的各部分组成&lt;/li>
&lt;li>介绍了一些可以高效的运行在DSDIN上的应用&lt;/li>
&lt;li>介绍了维持整个体系健康运行的激励机制&lt;/li>
&lt;/ol>
&lt;p>&lt;strong>Abstract&lt;/strong>：过去由于技术限制，制造业是“中央集权”的，工厂（特别是大型制造商）垄断了几乎所有的制造资源，包括：技术，原材料，设备，工人，市场信息等。但是，这种集中生产成本高、效率低并且不灵活，难以应对快速变化，多样化和个性化的用户需求。本文介绍了一个智能工业网络（DSDIN），它提供了一个完全分布式的制造网络，每个人都可以参与制造，因为权力下放而没有中间环节，人们能够快速获得他们想要的产品或服务，获得授权并通过努力（例如提供创意，设计或设备，原材料等）以一种低成本的方式获得回报。DSDIN实际上是一个平台，由DSDIN形成的智能网络，制造中心不再是工厂，实际上没有制造中心。DSDIN为人和物（包括原材料，设备，成品/半成品等）提供多参与的点对点网络。通过网络传输的信息称为智能服务算法（ISA）。用户可以通过ISA将过程模型，公式或控制参数发送到设备，DSDIN中的每个事务都是由ISA定义的智能服务。&lt;/p>
&lt;p>&lt;em>&lt;font size = 2>注：要构建一个全球范围的分布式工业网络，做的是基于区块链技术的工业物联网平台，和以太坊很相似，从文中也可以看到，大量借鉴了以太坊的思路，但是根据工业物联网的特性做了调整。&lt;/font>&lt;/em>&lt;/p></description></item><item><title>Consortium Blockchain for Secure Energy Trading in Industrial Internet of Things</title><link>https://NamiChen.github.io/2018/consortium-blockchain-for-secure-energy-trading-in-industrial-internet-of-things/</link><pubDate>Thu, 13 Dec 2018 17:14:00 +0800</pubDate><guid>https://NamiChen.github.io/2018/consortium-blockchain-for-secure-energy-trading-in-industrial-internet-of-things/</guid><description>&lt;p>&lt;strong>主题&lt;/strong>：用联盟链解决工业物联网的能量交易问题&lt;/p>
&lt;p>&lt;strong>主要工作&lt;/strong>：&lt;/p>
&lt;ol>
&lt;li>针对工业物联网(IIoT)里能量交易的安全与隐私问题，提出能量区块链(energy blockchain)&lt;/li>
&lt;li>为了减少由交易确认的延迟造成的交易限制，提出一个基于信用的支付方案，以支持快速和频繁的能源限制&lt;/li>
&lt;li>在体系里构建了一个能量银行，并使用Stackelberg 博弈进行基于信用贷款的最优定价&lt;/li>
&lt;li>对能量区块链解决的安全问题，能量区块链的性能，基于信用的支付方案的性能做分析&lt;/li>
&lt;/ol></description></item><item><title>区块链学习4-以太坊基础知识</title><link>https://NamiChen.github.io/2018/ethereum-instruction/</link><pubDate>Tue, 11 Dec 2018 20:34:00 +0800</pubDate><guid>https://NamiChen.github.io/2018/ethereum-instruction/</guid><description>1. 基本知识 基本知识需要了解两部分 第一部分是以太坊版本演进过程：白皮书——&amp;gt;黄皮书——&amp;gt;Frontier版本——&amp;gt;Homes</description></item><item><title>背景调查3-区块链与物联网</title><link>https://NamiChen.github.io/2018/blockchain-for-iot/</link><pubDate>Tue, 11 Dec 2018 14:55:00 +0800</pubDate><guid>https://NamiChen.github.io/2018/blockchain-for-iot/</guid><description>&lt;p>和老师商量着定了大方向是物联网和区块链的结合，这篇文章是这段时间以来对该方向调查的总结。&lt;/p></description></item><item><title>区块链学习3-区块链领域概况</title><link>https://NamiChen.github.io/2018/overview-of-blockchain/</link><pubDate>Tue, 20 Nov 2018 14:25:00 +0800</pubDate><guid>https://NamiChen.github.io/2018/overview-of-blockchain/</guid><description>&lt;p>本篇结束区块链领域概况，包括一些常见名词、核心技术、应用场景和学习区块链需要掌握的基础知识。&lt;/p></description></item><item><title>背景调查2-近三年区块链方向论文发表情况总结</title><link>https://NamiChen.github.io/2018/analysis-of-papers-published-in-blockchain-field/</link><pubDate>Sat, 17 Nov 2018 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2018/analysis-of-papers-published-in-blockchain-field/</guid><description>原始的目的是统计一下国内区块链研究现状，但开始这一工作时决定顺便把其它的统计数据也一并记录下来。数据来自 Web of Science核心合集，即SCI</description></item><item><title>背景调查1-区块链方向的期刊、会议和基金收集</title><link>https://NamiChen.github.io/2018/conference-journal-and-foundation-information-in-blockchain-field/</link><pubDate>Wed, 14 Nov 2018 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2018/conference-journal-and-foundation-information-in-blockchain-field/</guid><description>如题，本文只关注重点的几方面 收录区块链的期刊、会议列表（将中国的单独分离） 期刊专题和会议的征稿通知，从中发现当前热点研究领域 基金项目信息中的</description></item><item><title>区块链学习2-比特币基本原理</title><link>https://NamiChen.github.io/2018/bitcoin-fundamentals/</link><pubDate>Mon, 12 Nov 2018 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2018/bitcoin-fundamentals/</guid><description>&lt;p>区块链里最基本也是最重要的几个概念是&lt;strong>地址&lt;/strong>、&lt;strong>交易&lt;/strong>、&lt;strong>区块&lt;/strong>、&lt;strong>网络&lt;/strong>。比特币用地址来标识一笔交易的支出方和接收方。所有的交易最终需要被记到统一的账本（也就是区块链）上，而这个账本是通过区块确认并完成的。每一个新区块的产生，都会被打上时间戳（区块头里的一个字段，是真的时间，后面详细介绍），最终生成按照时间前后排列并加以记录的电子交易证明。每个独立节点之间又通过比特币网络来建立联系，这样就组成了一个去中心化、分布式的电子交易记录时间戳服务器系统。比特币通过构造这个分布式时间戳服务器来解决&lt;a href="https://baike.baidu.com/item/%E5%8F%8C%E9%87%8D%E6%94%AF%E4%BB%98/7046722?fr=aladdin" target="_blank">双重支付&lt;/a>问题。&lt;/p></description></item><item><title>科研基础2-文献管理工具 Zotero 学习指南</title><link>https://NamiChen.github.io/2018/introduction-to-zotero/</link><pubDate>Sun, 11 Nov 2018 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2018/introduction-to-zotero/</guid><description>在文献管理方面的需求包括： 文献可以方便地导入工具中并提取准确丰富地文献信息 工作和学习时，可以快速在工具中找到自己想要的文献 在写作时，可以方便</description></item><item><title>科研基础1-文献检索常识</title><link>https://NamiChen.github.io/2018/academic-basic-knowledge/</link><pubDate>Fri, 09 Nov 2018 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2018/academic-basic-knowledge/</guid><description>1. 常用名词 与学术研究和论文相关的，有许多常用的名词，本节对这些名词作解释和区分。 会议组织者：可能是某个学校或某个组织，为了学术或经济利益举办</description></item><item><title>区块链学习1-比特币的诞生</title><link>https://NamiChen.github.io/2018/the-birth-of-bitcoin/</link><pubDate>Fri, 02 Nov 2018 14:02:00 +0800</pubDate><guid>https://NamiChen.github.io/2018/the-birth-of-bitcoin/</guid><description>&lt;p>区块链作为比特币背后的技术架构，是随着比特币的出现而诞生的。因此，要讲区块链的诞生，我们就不得不从比特币的历史说起。&lt;/p></description></item><item><title>Blockchain and the Internet of Things in the Industrial Sector</title><link>https://NamiChen.github.io/2018/blockchain-and-the-internet-of-things-in-the-industrial-sector/</link><pubDate>Wed, 24 Oct 2018 12:25:00 +0800</pubDate><guid>https://NamiChen.github.io/2018/blockchain-and-the-internet-of-things-in-the-industrial-sector/</guid><description>说明：三个工业物联网和区块链结合的场景 供应链 货物在供应链各环节流通时，装运信息缺乏可见性，并且拥有装运延迟，这种延迟通常是由于一个流通的批准</description></item><item><title>Work-in-Progress Integrating Low-Power IoT devices to</title><link>https://NamiChen.github.io/2018/work-in-progress-integrating-low-power-iot-devices-to/</link><pubDate>Tue, 23 Oct 2018 11:22:00 +0800</pubDate><guid>https://NamiChen.github.io/2018/work-in-progress-integrating-low-power-iot-devices-to/</guid><description>Özyılmaz, Kazım Rıfat, and Arda Yurdakul. &amp;ldquo;Work-in-Progress: Integrating low-power IoT devices to a blockchain-based infrastructure.&amp;rdquo; 2017 International Conference on Embedded Software (EMSOFT). IEEE, 2017. 说明：关于物联网和区块链结合，节点资源有限的一种解决方案 Introduction</description></item><item><title>Blockchains and Smart Contracts for the Internet of Things</title><link>https://NamiChen.github.io/2018/blockchains-and-smart-contracts-for-the-internet-of-things/</link><pubDate>Mon, 22 Oct 2018 10:19:00 +0800</pubDate><guid>https://NamiChen.github.io/2018/blockchains-and-smart-contracts-for-the-internet-of-things/</guid><description>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>缺失可信中介使交易双方之间的协调更快&lt;/p>
&lt;p>密码学的大量使用为网络中的所有交互带来了权威性&lt;/p>
&lt;p>智能合约允许分布式的，高度自动化的工作流程&lt;/p>
&lt;h2 id="blockchains-and-iot">Blockchains and IoT&lt;/h2>
&lt;p>目前的中心化模型中，制造商维护以百万计的设备的软件更新代价是高昂的&lt;/p>
&lt;p>用户缺乏对应用从后台是否私自获取数据的信任，需要一个透明度保障的方法&lt;/p>
&lt;p>区块链技术可以解决这些问题&lt;/p>
&lt;p>制造商的所有物联网设备都在同一个区块链网络上运行，制造商部署智能合约并允许它们在区块链网络上存储最新固件更新的哈希值，这些设备要么将智能合约的地址附加到它们的区块链客户端，要么通过发现服务找到它。然后，它们可以查询合约，了解新的固件更新，并通过分式对等文件系统请求更新并通过哈希验证更新正确性，对该文件的第一次请求由制造商自己的节点（该节点也加入区块链网络）提供服务，但更新文件传播到足够的节点后，制造商的节点可以停止提供服务，由已获得更新的设备向未获得更新的设备提供服务，一切自动进行，没有用户交互。&lt;/p></description></item><item><title>如果度过研究生阶段</title><link>https://NamiChen.github.io/2018/what-should-be-done-in-master-three-years/</link><pubDate>Wed, 05 Sep 2018 00:00:00 +0000</pubDate><guid>https://NamiChen.github.io/2018/what-should-be-done-in-master-three-years/</guid><description>&lt;p>研三重新来写这篇文章，感触更多，也许当初明白这些，会有不同的选择，可惜，世上没有如果。&lt;/p></description></item></channel></rss>