Packages

The go-ethereum project defines 242 packages. Only the top-level packages are discussed here. The godoc for the project contains some of the following documentation for the top-level packages. The rest of the information was taken from disparate sources, including the wiki and reading the source code.

Notes

  1. The build/ directory only contains one special Go command-line program package, for building the distribution. The build directory also contains scripts and configurations for building the package in various environments.

  2. Only the directories that map 1:1 with packages are shown in the following table. The exception is the ethereum package, which is defined in only one file: interfaces.go. There is a note in that file to migrate the contents to the event package.

  3. Go’s special treatment of the vendor/ directory defines dependencies which contain a minimal framework for creating and organizing command line Go applications, and a rich testing extension for Go’s testing package. Details are here.

Top-Level Packages

Directory Description
accounts Implements high-level Ethereum account management.
bmt Provides a binary Merkle tree implementation.
cmd Source for the command-line programs in the next table, below.
common Defines helper functions: bitutil, which implements fast bitwise operations; compiler, which wraps the Solidity compiler executable (solc); hexutil, which implements hex encoding with 0x prefix; math, which provides integer math functions; and mclock, a wrapper for a monotonic clock source.
consensus Implements different Ethereum consensus engines (which must conform to the Engine interface: clique, which implements proof-of-authority consensus, and ethash, which implements proof-of-work consensus. The original Ethash docs are here.
console Ethereum implements a JavaScript runtime environment (JSRE) that can be used in either interactive (console) or non-interactive (script) mode. Ethereum's JavaScript console exposes the full web3 JavaScript Dapp API and the admin API. More documentation is here. This package implements JSRE for the geth attach and geth console subcommands.
containers Currently just provides docker support.
contracts Supports the chequebook smart contract and the Ethereum Name Service (EIP 137).
core Implements the Ethereum consensus protocol, implements the Ethereum Virtual Machine, and other miscellaneous important bits.
crypto Cryptographic implementations.
dashboard Client-server data visualizer integrated into geth, that collects and visualizes information about an Ethereum node.
eth Implements the Ethereum protocol.
ethclient Provides a client for the Ethereum RPC API.
ethdb TODO leveldb code?
ethstats Implements the network stats reporting service.
event Deals with subscriptions to real-time events.
internal Debugging support, JavaScript dependencies, testing support.
les Implements the Light Ethereum Subprotocol.
light Implements on-demand retrieval capable state and chain objects for the Ethereum Light Client.
log Provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable.
metrics Port of Coda Hale's Metrics library. Suggestion: Why was this not implemented as a separate library, like this one?
miner Implements Ethereum block creation and mining.
mobile Contains the simplified mobile APIs to go-ethereum.
node Sets up multi-protocol Ethereum nodes.
p2p Implements the Ethereum p2p network protocols: Node Discovery Protocol, RLPx v5 Topic Discovery Protocol, Ethereum Node Records as defined in EIP-778, common network port mapping protocols, and p2p network simulation.
params TODO what is this?
rlp Implements the RLP serialization format.
rpc Provides access to the exported methods of an object across a network or other I/O connection.
signer Rule-based transaction signer.
swarm Swarm is a service that provides APIs to upload and download content to the cloud and through URL-based addressing offers virtual hosting of websites and decentralised applications (dapps) without web servers, using decentralised peer-to-peer distributed infrastructure.
tests Implements execution of Ethereum JSON tests.
trie Implements Merkle Patricia tries.
whisper Implements the Whisper protocol.

Command-Line Programs

The cmd directory contains source for the following command-line programs:

Directory Description
abigen Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain Ethereum contract ABIs with expanded functionality if the contract bytecode is also available. However it also accepts Solidity source files, making development much more streamlined. See the Native DApps wiki page for details.
bootnode Runs a bootstrap node for the Ethereum Discovery Protocol. This is a stripped-down version of geth that only takes part in the network node discovery protocol, and does not run any of the higher level application protocols. It can be used as a lightweight bootstrap node to aid in finding peers in private networks.
clef A standalone signer that manages keys across multiple Ethereum-aware apps such as geth, Metamask, and cpp-ethereum. This command-line program is currently only alpha quality, and has not been formally released yet.
ethkey A key/wallet management tool for Ethereum keys. Allows user to add, remove and change their keys, and supports cold wallet device-friendly transaction inspection and signing. This documentation was written for the C++ Ethereum client implementation, but it is probably suitable for the Go implementation as well.
evm A version of the EVM (Ethereum Virtual Machine) for running bytecode snippets within a configurable environment and execution mode. Allows isolated, fine-grained debugging of EVM opcodes.
evm --code 60ff60ff --debug
faucet An Ether faucet backed by a light client. TODO is this actually a subcommand of another command?
geth Official command-line client for Ethereum. It provides the entry point into the Ethereum network (main-, test- or private net), capable of running as a full node (default) archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as a gateway into the Ethereum network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. Command-line options are described on the CLI Wiki page.
p2psim A simulation HTTP API.
puppeth Assembles and maintains new private Ethereum networks, including genesis, bootnodes, signers, ethstats, faucet, and dashboard. Puppeth uses ssh to dial into remote servers, and builds its network components out of docker containers using docker-compose. The gitter room for puppeth is ethereum/puppeth.
rlpdump A pretty-printer for RLP data. RLP (Recursive Length Prefix) is the data encoding used by the Ethereum protocol. Sample usage:
rlpdump --hex CE0183FFFFFFC4C304050583616263
swarm Provides the bzzhash command, which computes a swarm tree hash, and implements the swarm daemon and tools. See the swarm documentation for more information.
wnode Whisper node, which could be used as a stand-alone bootstrap node and could also be used for test and diagnostics purposes.

Incantations

Counting Packages

The following incantation reports the number of packages in the go-ethereum project:

grep -rIhw --include \*.go "^\s*package\s*" | grep -v "not installed" | \
  tr -d ';' | sed 's^//.*^^' | awk '{$1=$1};1' | \
  sort | uniq | wc -l

Counting Top-Level Directories

The following incantation lists the top-level directories, most of which are package names:

find . -maxdepth 1 -type d | sed 's^\./^^' | sed '/\..*/d'

results matching ""

    No results matching ""