Home

Awesome

《以太坊的指南针》

全书链接:http://ethbook.abyteahead.com/

这是给 程序员 读的入门书,更是一本面向 从未接触过以太坊人群 的书。

以太坊是什么?怎么了解相关知识?

这本书涵盖了你想要了解的以太坊的基本知识。

前半本文艺,后半本实践,附录深刻。

内容包括钱包、交易、数据结构。也包括了Solidity语法、虚拟机原理和实战合约编写。

市面上目前的大部分公链/联盟链都借鉴了以太坊的虚拟机。读完本书,你再去看其他项目,会感到成竹在胸。

书中的知识点都是作者在区块链工作中实践总结的。希望对你们有帮助。

鸣谢唯链核心开发组的队友们的指导。

参与本书

如有改进意见,请直接在Issue页面提出。我们会及时修改。

你的名字会出现在“鸣谢”里。^_^

homepage

目录

<ul> <li class="toctree-l1"><a class="reference internal" href="http://ethbook.abyteahead.com/howto.html">如何学习这本书</a></li> <li class="toctree-l1"><a class="reference internal" href="http://ethbook.abyteahead.com/ch1/index.html">第 1 章 以太坊:一台全球计算机</a><ul> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch1/born.html">简史</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch1/progress.html">发展阶段</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch1/highlight.html">以太坊的特色</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/index.html">第 2 章 账户是什么</a><ul> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/basic.html">小白基础知识问答</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/basic.html#id2">我的以太币记录在哪里?</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/basic.html#id3">我的以太币余额如何变化?</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/basic.html#id4">什么是区块?</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/basic.html#id5">区块和状态的关系</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/basic.html#id6">“巨大的账本”</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/basic.html#id7">我如何参与以太坊?</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/basic.html#id8">我如何与其他人同步账本?</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/account.html">账户探秘</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/account.html#id2">账户与账户状态</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/account.html#id3">账户状态的内涵</a><ul> <li class="toctree-l4"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/account.html#id4">已执行交易总数</a></li> <li class="toctree-l4"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/account.html#id5">持币数量</a></li> <li class="toctree-l4"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/account.html#id6">存储区的哈希值</a></li> <li class="toctree-l4"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/account.html#id7">代码区的哈希值</a></li> </ul> </li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/account.html#app">没有钱包App, 如何生成账户?</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/account.html#id11">智能合约地址的生成</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/interval.html">扩展阅读</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/keystore.html">资料篇:Keystore 与私钥保存</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/app.html">资料篇:常用钱包 App</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch2/eip55.html">资料篇:EIP-55 格式的账户地址</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="http://ethbook.abyteahead.com/ch3/index.html">第 3 章 交易是驱动力</a><ul> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch3/how.html">交易的发送</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch3/how.html#id2">交易与消息的区别</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch3/how.html#id3">交易的特性是什么?</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch3/what.html">交易的样子</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch3/life.html">交易的生命周期</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch3/interval.html">扩展阅读</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch3/pow.html">资料篇:共识与工作量证明</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch3/pow.html#pow">比特币的PoW机制(简单版)</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch3/pow.html#id2">比特币算力的中心化问题</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch3/pow.html#pow-pos">以太坊的Pow/Pos机制</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch3/dig.html">资料篇:矿工与挖矿奖励</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/index.html">第 4 章 数据结构</a><ul> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/radix.html">Radix树</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/merkle.html">Merkle树和 Merkle证明</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/mpt.html">Merkle Patricia树</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/rlp.html">RLP编码</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/rlp.html#id1">RLP字符/字符串编码</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/rlp.html#id2">RLP字符/字符串解码</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/rlp.html#id3">RLP数组编码</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/rlp.html#id4">RLP数组解码</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/interval.html">扩展阅读</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/stateroot.html">资料篇:状态树 (以及存储树)</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/transroot.html">资料篇:交易树</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/receiptroot.html">资料篇:收据树</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch4/block.html">资料篇:区块</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="http://ethbook.abyteahead.com/ch5/index.html">第 5 章 构建一条以太坊私链</a><ul> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch5/install.html">安装</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch5/geth.html">Geth客户端的结构</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch5/build.html">启动一条以太坊私链</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch5/coinbase.html">接收挖矿奖励</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch5/transfer.html">转账与收款</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="http://ethbook.abyteahead.com/ch6/index.html">第 6 章 手把手教你部署智能合约</a><ul> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch6/what.html">什么是智能合约?</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch6/install.html">安装编译器</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch6/compile.html">Solc编译智能合约</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch6/prepare.html">智能合约发布准备</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch6/deploy.html">部署智能合约</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch6/call.html">调用智能合约</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="http://ethbook.abyteahead.com/ch7/index.html">第 7 章 以太坊虚拟机探秘</a><ul> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch7/result.html">虚拟机的执行结果</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch7/resource.html">虚拟机的执行资源</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch7/call.html">合约调用合约?</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch7/io.html">虚拟机的输入输出</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch7/gas.html">Gas 花费与退回</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch7/instructions.html">虚拟机指令集</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/index.html">第 8 章 Solidity语法练习</a><ul> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/basic.html">基础概念</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/basic.html#id2">没有浮点数运算</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/basic.html#id3">合约基础</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/basic.html#id4">变量类型</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/basic.html#id5">运算符号</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/basic.html#struct">结构体 Struct</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/basic.html#array">数组array</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/basic.html#id6">函数申明</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/basic.html#id7">类型转换与内置函数</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/basic.html#id8">合约与事件</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/levelup.html">语法进阶</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/levelup.html#map">数据结构:map</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/levelup.html#msg-sender">环境变量:msg.sender</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/levelup.html#requireassert">require还是assert?</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/levelup.html#id2">继承和引入</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/levelup.html#id3">省钱妙招:内存变量</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/levelup.html#id4">接口与合约调用</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/levelup.html#id5">多返回值</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/advanced.html">高级语法和概念</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/advanced.html#contract">Contract 构造函数</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/advanced.html#ownable">Ownable控制</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/advanced.html#pausable">Pausable控制</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/advanced.html#struct">省钱妙招:struct 结构体</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/advanced.html#id2">时间单位表达</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/advanced.html#id3">带参数的函数修饰符</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/advanced.html#for">for 循环</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/advanced.html#payable">合约收款:payable修饰符</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/advanced.html#transfer">支付费用:transfer方法</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch8/summary.html">小结</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/index.html">第 9 章 Truffle合约开发实战</a><ul> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/install.html">编译、测试工具安装</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/install.html#truffle">Truffle的安装</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/install.html#ganache">Ganache的安装</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/sample.html">Truffle启动样例项目</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/sample.html#id1">下载样例</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/sample.html#id2">编译项目</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/sample.html#ganache">部署项目到 Ganache</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/sample.html#id3">测试项目</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/erc20.html">上手实践:ERC20合约</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/erc20.html#id1">新建项目目录</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/erc20.html#erc20-basic">ERC20 Basic合约接口</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/erc20.html#id2">ERC20 合约接口</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/erc20.html#safemath">SafeMath基础数学库</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/erc20.html#cat">猫币:CAT数字资产合约</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/test.html">上手实践:ERC20合约测试</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/test.html#id1">准备工作</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/test.html#id2">测试辅助函数与库</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/test.html#id3">测试代码分析</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch9/test.html#id4">测试运行与结果</a></li> </ul> </li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/index.html">附录 有意思的冷知识</a><ul> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/shortattack.html">短地址攻击</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/block.html">比特币的区块</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/utxo.html">以太坊与比特币账户的区别</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/utxo.html#id2">隐私与安全性的比较</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/utxo.html#id3">数据体积与并发能力</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/utxo.html#id4">发送交易时对双花的处理</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/triangle.html">“不可能的三角”问题</a></li> <li class="toctree-l2"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/ethash.html">ETHASH 挖矿算法</a><ul> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/ethash.html#ethashpow">ETHASH和比特币PoW的异同</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/ethash.html#id1">ETHASH的设计目标</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/ethash.html#id2">ETHASH的挖矿运行总流程</a></li> <li class="toctree-l3"><a class="reference internal" href="http://ethbook.abyteahead.com/ch10/ethash.html#id3">ETHASH算法源代码解读</a></li> </ul> </li> </ul> </li> </ul>