The Ethereum blockchain along with its two extension protocols Whisper and Swarm was originally conceptualized to become the supporting pillar of web3, providing the consensus, messaging and storage backbone for a new generation of distributed (actually, decentralized) applications called DApps.


The first incarnation towards this dream of web3 was a command line client providing an RPC interface into the peer-to-peer protocols. The client was soon enough extended with a web-browser-like graphical user interface, permitting developers to write DApps based on the tried and proven HTML/CSS/JS technologies.

Web3梦想的第一个体现是一个命令行客户端,它提供了一个对等协议的RPC接口。很快,该客户端通过类似于Web浏览器的图形用户界面进行了扩展,从而允许开发人员基于久经考验的HTML / CSS / JS技术编写DApp。

As many DApps have more complex requirements than what a browser environment can handle, it became apparent that providing programmatic access to the web3 pillars would open the door towards a new class of applications. As such, the second incarnation of the web3 dream is to open up all our technologies for other projects as reusable components.


Starting with the 1.5 release family of go-ethereum, we transitioned away from providing only a full blown Ethereum client and started shipping official Go packages that could be embedded into third party desktop and server applications.


Note, this guide will assume you are familiar with Go development. It will make no attempts to cover general topics about Go project layouts, import paths or any other standard methodologies. If you are new to Go, consider reading its getting started guides first.


Quick overview

Our reusable Go libraries focus on four main usage areas:


  • Simplified client side account management 简化的客户账户管理
  • Remote node interfacing via different transports 通过不同的传输方式进行远程节点接口
  • Contract interactions through auto-generated bindings 通过自动生成的绑定进行合同交互
  • In-process Ethereum, Whisper and Swarm peer-to-peer node 进程内以太坊,耳语和Swarm对等节点

You can watch a quick overview about these in Peter’s (@karalabe) talk titled “Import Geth: Ethereum from Go and beyond”, presented at the Ethereum Devcon2 developer conference in September, 2016 (Shanghai). Slides are available here.

Peter's Devcon2 talk

Go packages

The go-ethereum library is distributed as a collection of standard Go packages straight from our GitHub repository. The packages can be used directly via the official Go toolkit, without needing any third party tools. External dependencies are vendored locally into vendor, ensuring both self-containment as well as code stability. If you reuse go-ethereum in your own project, please follow these best practices and vendor it yourself too to avoid any accidental API breakages!


The canonical import path for go-ethereum is github.com/ethereum/go-ethereum, with all packages residing underneath. Although there are quite a number of them, you’ll only need to care about a limited subset, each of which will be properly introduced in their relevant section.

go-ethereum的规范导入路径是 github.com/ethereum/go-ethereum,所有软件包都位于其下方。尽管它们很多,但是您只需要关心一个有限的子集,每个子​​集都会在其相关部分中正确介绍。

You can download all our packages via:

$ go get -d github.com/ethereum/go-ethereum/...

You may also need Go’s original context package. Although this was moved into the official Go SDK in Go 1.7, go-ethereum will depend on the original golang.org/x/net/context package until we officially drop support for Go 1.5 and Go 1.6.

您可能还需要Go的原始上下文包。尽管已将其移至Go 1.7中的官方Go SDK中,但在我们正式放弃对Go 1.5和Go 1.6的支持之前,go-ethereum将取决于原始的golang.org/x/net/context包。

$ go get -u golang.org/x/net/context