github.com/ethereum/go-ethereum@v1.16.1/README.md (about) 1 ## Go Ethereum 2 3 Golang execution layer implementation of the Ethereum protocol. 4 5 [](https://pkg.go.dev/github.com/ethereum/go-ethereum?tab=doc) 8 [](https://goreportcard.com/report/github.com/ethereum/go-ethereum) 9 [](https://app.travis-ci.com/github/ethereum/go-ethereum) 10 [](https://discord.gg/nthXNEv) 11 12 Automated builds are available for stable releases and the unstable master branch. Binary 13 archives are published at https://geth.ethereum.org/downloads/. 14 15 ## Building the source 16 17 For prerequisites and detailed build instructions please read the [Installation Instructions](https://geth.ethereum.org/docs/getting-started/installing-geth). 18 19 Building `geth` requires both a Go (version 1.23 or later) and a C compiler. You can install 20 them using your favourite package manager. Once the dependencies are installed, run 21 22 ```shell 23 make geth 24 ``` 25 26 or, to build the full suite of utilities: 27 28 ```shell 29 make all 30 ``` 31 32 ## Executables 33 34 The go-ethereum project comes with several wrappers/executables found in the `cmd` 35 directory. 36 37 | Command | Description | 38 | :--------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 39 | **`geth`** | Our main Ethereum CLI client. It is 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. `geth --help` and the [CLI page](https://geth.ethereum.org/docs/fundamentals/command-line-options) for command line options. | 40 | `clef` | Stand-alone signing tool, which can be used as a backend signer for `geth`. | 41 | `devp2p` | Utilities to interact with nodes on the networking layer, without running a full blockchain. | 42 | `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](https://docs.soliditylang.org/en/develop/abi-spec.html) with expanded functionality if the contract bytecode is also available. However, it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://geth.ethereum.org/docs/developers/dapp-developer/native-bindings) page for details. | 43 | `evm` | Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow isolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug run`). | 44 | `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp)) dumps (data encoding used by the Ethereum protocol both network as well as consensus wise) to user-friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). | 45 46 ## Running `geth` 47 48 Going through all the possible command line flags is out of scope here (please consult our 49 [CLI Wiki page](https://geth.ethereum.org/docs/fundamentals/command-line-options)), 50 but we've enumerated a few common parameter combos to get you up to speed quickly 51 on how you can run your own `geth` instance. 52 53 ### Hardware Requirements 54 55 Minimum: 56 57 * CPU with 4+ cores 58 * 8GB RAM 59 * 1TB free storage space to sync the Mainnet 60 * 8 MBit/sec download Internet service 61 62 Recommended: 63 64 * Fast CPU with 8+ cores 65 * 16GB+ RAM 66 * High-performance SSD with at least 1TB of free space 67 * 25+ MBit/sec download Internet service 68 69 ### Full node on the main Ethereum network 70 71 By far the most common scenario is people wanting to simply interact with the Ethereum 72 network: create accounts; transfer funds; deploy and interact with contracts. For this 73 particular use case, the user doesn't care about years-old historical data, so we can 74 sync quickly to the current state of the network. To do so: 75 76 ```shell 77 $ geth console 78 ``` 79 80 This command will: 81 * Start `geth` in snap sync mode (default, can be changed with the `--syncmode` flag), 82 causing it to download more data in exchange for avoiding processing the entire history 83 of the Ethereum network, which is very CPU intensive. 84 * Start the built-in interactive [JavaScript console](https://geth.ethereum.org/docs/interacting-with-geth/javascript-console), 85 (via the trailing `console` subcommand) through which you can interact using [`web3` methods](https://github.com/ChainSafe/web3.js/blob/0.20.7/DOCUMENTATION.md) 86 (note: the `web3` version bundled within `geth` is very old, and not up to date with official docs), 87 as well as `geth`'s own [management APIs](https://geth.ethereum.org/docs/interacting-with-geth/rpc). 88 This tool is optional and if you leave it out you can always attach it to an already running 89 `geth` instance with `geth attach`. 90 91 ### A Full node on the Holesky test network 92 93 Transitioning towards developers, if you'd like to play around with creating Ethereum 94 contracts, you almost certainly would like to do that without any real money involved until 95 you get the hang of the entire system. In other words, instead of attaching to the main 96 network, you want to join the **test** network with your node, which is fully equivalent to 97 the main network, but with play-Ether only. 98 99 ```shell 100 $ geth --holesky console 101 ``` 102 103 The `console` subcommand has the same meaning as above and is equally 104 useful on the testnet too. 105 106 Specifying the `--holesky` flag, however, will reconfigure your `geth` instance a bit: 107 108 * Instead of connecting to the main Ethereum network, the client will connect to the Holesky 109 test network, which uses different P2P bootnodes, different network IDs and genesis 110 states. 111 * Instead of using the default data directory (`~/.ethereum` on Linux for example), `geth` 112 will nest itself one level deeper into a `holesky` subfolder (`~/.ethereum/holesky` on 113 Linux). Note, on OSX and Linux this also means that attaching to a running testnet node 114 requires the use of a custom endpoint since `geth attach` will try to attach to a 115 production node endpoint by default, e.g., 116 `geth attach <datadir>/holesky/geth.ipc`. Windows users are not affected by 117 this. 118 119 *Note: Although some internal protective measures prevent transactions from 120 crossing over between the main network and test network, you should always 121 use separate accounts for play and real money. Unless you manually move 122 accounts, `geth` will by default correctly separate the two networks and will not make any 123 accounts available between them.* 124 125 ### Configuration 126 127 As an alternative to passing the numerous flags to the `geth` binary, you can also pass a 128 configuration file via: 129 130 ```shell 131 $ geth --config /path/to/your_config.toml 132 ``` 133 134 To get an idea of how the file should look like you can use the `dumpconfig` subcommand to 135 export your existing configuration: 136 137 ```shell 138 $ geth --your-favourite-flags dumpconfig 139 ``` 140 141 #### Docker quick start 142 143 One of the quickest ways to get Ethereum up and running on your machine is by using 144 Docker: 145 146 ```shell 147 docker run -d --name ethereum-node -v /Users/alice/ethereum:/root \ 148 -p 8545:8545 -p 30303:30303 \ 149 ethereum/client-go 150 ``` 151 152 This will start `geth` in snap-sync mode with a DB memory allowance of 1GB, as the 153 above command does. It will also create a persistent volume in your home directory for 154 saving your blockchain as well as map the default ports. There is also an `alpine` tag 155 available for a slim version of the image. 156 157 Do not forget `--http.addr 0.0.0.0`, if you want to access RPC from other containers 158 and/or hosts. By default, `geth` binds to the local interface and RPC endpoints are not 159 accessible from the outside. 160 161 ### Programmatically interfacing `geth` nodes 162 163 As a developer, sooner rather than later you'll want to start interacting with `geth` and the 164 Ethereum network via your own programs and not manually through the console. To aid 165 this, `geth` has built-in support for a JSON-RPC based APIs ([standard APIs](https://ethereum.org/en/developers/docs/apis/json-rpc/) 166 and [`geth` specific APIs](https://geth.ethereum.org/docs/interacting-with-geth/rpc)). 167 These can be exposed via HTTP, WebSockets and IPC (UNIX sockets on UNIX based 168 platforms, and named pipes on Windows). 169 170 The IPC interface is enabled by default and exposes all the APIs supported by `geth`, 171 whereas the HTTP and WS interfaces need to manually be enabled and only expose a 172 subset of APIs due to security reasons. These can be turned on/off and configured as 173 you'd expect. 174 175 HTTP based JSON-RPC API options: 176 177 * `--http` Enable the HTTP-RPC server 178 * `--http.addr` HTTP-RPC server listening interface (default: `localhost`) 179 * `--http.port` HTTP-RPC server listening port (default: `8545`) 180 * `--http.api` API's offered over the HTTP-RPC interface (default: `eth,net,web3`) 181 * `--http.corsdomain` Comma separated list of domains from which to accept cross-origin requests (browser enforced) 182 * `--ws` Enable the WS-RPC server 183 * `--ws.addr` WS-RPC server listening interface (default: `localhost`) 184 * `--ws.port` WS-RPC server listening port (default: `8546`) 185 * `--ws.api` API's offered over the WS-RPC interface (default: `eth,net,web3`) 186 * `--ws.origins` Origins from which to accept WebSocket requests 187 * `--ipcdisable` Disable the IPC-RPC server 188 * `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it) 189 190 You'll need to use your own programming environments' capabilities (libraries, tools, etc) to 191 connect via HTTP, WS or IPC to a `geth` node configured with the above flags and you'll 192 need to speak [JSON-RPC](https://www.jsonrpc.org/specification) on all transports. You 193 can reuse the same connection for multiple requests! 194 195 **Note: Please understand the security implications of opening up an HTTP/WS based 196 transport before doing so! Hackers on the internet are actively trying to subvert 197 Ethereum nodes with exposed APIs! Further, all browser tabs can access locally 198 running web servers, so malicious web pages could try to subvert locally available 199 APIs!** 200 201 ### Operating a private network 202 203 Maintaining your own private network is more involved as a lot of configurations taken for 204 granted in the official networks need to be manually set up. 205 206 Unfortunately since [the Merge](https://ethereum.org/en/roadmap/merge/) it is no longer possible 207 to easily set up a network of geth nodes without also setting up a corresponding beacon chain. 208 209 There are three different solutions depending on your use case: 210 211 * If you are looking for a simple way to test smart contracts from go in your CI, you can use the [Simulated Backend](https://geth.ethereum.org/docs/developers/dapp-developer/native-bindings#blockchain-simulator). 212 * If you want a convenient single node environment for testing, you can use our [Dev Mode](https://geth.ethereum.org/docs/developers/dapp-developer/dev-mode). 213 * If you are looking for a multiple node test network, you can set one up quite easily with [Kurtosis](https://geth.ethereum.org/docs/fundamentals/kurtosis). 214 215 ## Contribution 216 217 Thank you for considering helping out with the source code! We welcome contributions 218 from anyone on the internet, and are grateful for even the smallest of fixes! 219 220 If you'd like to contribute to go-ethereum, please fork, fix, commit and send a pull request 221 for the maintainers to review and merge into the main code base. If you wish to submit 222 more complex changes though, please check up with the core devs first on [our Discord Server](https://discord.gg/invite/nthXNEv) 223 to ensure those changes are in line with the general philosophy of the project and/or get 224 some early feedback which can make both your efforts much lighter as well as our review 225 and merge procedures quick and simple. 226 227 Please make sure your contributions adhere to our coding guidelines: 228 229 * Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) 230 guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)). 231 * Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) 232 guidelines. 233 * Pull requests need to be based on and opened against the `master` branch. 234 * Commit messages should be prefixed with the package(s) they modify. 235 * E.g. "eth, rpc: make trace configs optional" 236 237 Please see the [Developers' Guide](https://geth.ethereum.org/docs/developers/geth-developer/dev-guide) 238 for more details on configuring your environment, managing project dependencies, and 239 testing procedures. 240 241 ### Contributing to geth.ethereum.org 242 243 For contributions to the [go-ethereum website](https://geth.ethereum.org), please checkout and raise pull requests against the `website` branch. 244 For more detailed instructions please see the `website` branch [README](https://github.com/ethereum/go-ethereum/tree/website#readme) or the 245 [contributing](https://geth.ethereum.org/docs/developers/geth-developer/contributing) page of the website. 246 247 ## License 248 249 The go-ethereum library (i.e. all code outside of the `cmd` directory) is licensed under the 250 [GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html), 251 also included in our repository in the `COPYING.LESSER` file. 252 253 The go-ethereum binaries (i.e. all code inside of the `cmd` directory) are licensed under the 254 [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also 255 included in our repository in the `COPYING` file.