github.com/bcskill/bcschain/v3@v3.4.9-beta2/README.md (about) 1 ![GoChain Logo](https://user-images.githubusercontent.com/75826/110122817-18cf5100-7d8e-11eb-8094-5fd189516f3d.png) 2 3 ## GoChain 4 5 Official golang implementation of the GoChain protocol. 6 7 [![API Reference]( 8 https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667 9 )](https://godoc.org/github.com/gochain/gochain) 10 11 Mainnet: [Live Stats](https://stats.gochain.io/) | [Block Explorer](https://explorer.gochain.io/) | [Public RPC Endpoint](https://rpc.gochain.io/) 12 13 Testnet: [Live Stats](https://testnet-stats.gochain.io/) | [Block Explorer](https://testnet-explorer.gochain.io/) | [Public RPC Endpoint](https://testnet-rpc.gochain.io/) 14 15 ## General Documentation 16 17 If you are looking to build DApps, deploy smart contracts, setup a private network or run a node, please see 18 our [Documentation Repository](https://github.com/gochain/docs), it will be much more useful to you. 19 20 If you plan on working on the GoChain core code, then read on. 21 22 ## Building the source 23 24 Building gochain requires both a Go (version 1.12 or later) and a C compiler. 25 You can install them using your favourite package manager. 26 Once the dependencies are installed, run: 27 28 ```sh 29 # build gochain 30 make gochain 31 ``` 32 33 or, to build the full suite of utilities: 34 35 ```sh 36 make all 37 ``` 38 39 ## Executables 40 41 The GoChain project comes with several wrappers/executables found in the `cmd` directory. 42 43 | Command | Description | 44 |:----------:|-------------| 45 | **`gochain`** | Our main GoChain CLI client. It is the entry point into the GoChain 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 GoChain network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `gochain --help` and the [CLI Wiki page](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options) for command line options. | 46 | `abigen` | Source code generator to convert GoChain contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain [Ethereum contract ABIs](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) 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://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) wiki page for details. | 47 | `bootnode` | Stripped down version of our GoChain client implementation that only takes part in the network node discovery protocol, but 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. | 48 | `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`). | 49 | `gethrpctest` | Developer utility tool to support our [ethereum/rpc-test](https://github.com/ethereum/rpc-tests) test suite which validates baseline conformity to the [Ethereum JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) specs. Please see the [test suite's readme](https://github.com/ethereum/rpc-tests/blob/master/README.md) for details. | 50 | `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://github.com/ethereum/wiki/wiki/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`). | 51 | `swarm` | swarm daemon and tools. This is the entrypoint for the swarm network. `swarm --help` for command line options and subcommands. See https://swarm-guide.readthedocs.io for swarm documentation. | 52 53 ## Running GoChain 54 55 ### Full node on the main GoChain network 56 57 By far the most common scenario is people wanting to simply interact with the GoChain network: 58 create accounts; transfer funds; deploy and interact with contracts. For this particular use-case 59 the user doesn't care about years-old historical data, so we can fast-sync quickly to the current 60 state of the network. To do so: 61 62 ``` 63 $ gochain console 64 ``` 65 66 This command will: 67 68 * Start GoChain in fast sync mode (default, can be changed with the `--syncmode` flag), causing it to 69 download more data in exchange for avoiding processing the entire history of the GoChain network, 70 which is very CPU intensive. 71 * Start up GoChain's built-in interactive [JavaScript console](https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console), 72 (via the trailing `console` subcommand) through which you can invoke all official [`web3` methods](https://github.com/ethereum/wiki/wiki/JavaScript-API) 73 as well as GoChain's own [management APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs). 74 This too is optional and if you leave it out you can always attach to an already running GoChain instance 75 with `gochain attach`. 76 77 ### Full node on the GoChain test network 78 79 Transitioning towards developers, if you'd like to play around with creating GoChain contracts, you 80 almost certainly would like to do that without any real money involved until you get the hang of the 81 entire system. In other words, instead of attaching to the main network, you want to join the **test** 82 network with your node, which is fully equivalent to the main network, but with play-GOC only. 83 84 ``` 85 $ gochain --testnet console 86 ``` 87 88 The `console` subcommand have the exact same meaning as above and they are equally useful on the 89 testnet too. Please see above for their explanations if you've skipped to here. 90 91 Specifying the `--testnet` flag however will reconfigure your GoChain instance a bit: 92 93 * Instead of using the default data directory (`~/.gochain` on Linux for example), GoChain will nest 94 itself one level deeper into a `testnet` subfolder (`~/.gochain/testnet` on Linux). Note, on OSX 95 and Linux this also means that attaching to a running testnet node requires the use of a custom 96 endpoint since `gochain attach` will try to attach to a production node endpoint by default. E.g. 97 `gochain attach <datadir>/testnet/gochain.ipc`. Windows users are not affected by this. 98 * Instead of connecting the main GoChain network, the client will connect to the test network, 99 which uses different P2P bootnodes, different network IDs and genesis states. 100 101 *Note: Although there are some internal protective measures to prevent transactions from crossing 102 over between the main network and test network, you should make sure to always use separate accounts 103 for play-money and real-money. Unless you manually move accounts, GoChain will by default correctly 104 separate the two networks and will not make any accounts available between them.* 105 106 ### Configuration 107 108 As an alternative to passing the numerous flags to the `gochain` binary, you can also pass a configuration file via: 109 110 ```sh 111 $ gochain --config /path/to/your_config.toml 112 ``` 113 114 To get an idea how the file should look like you can use the `dumpconfig` subcommand to export your existing configuration: 115 116 ```sh 117 $ gochain --your-favourite-flags dumpconfig 118 ``` 119 120 #### Docker quick start 121 122 One of the quickest ways to get GoChain up and running on your machine is by using Docker: 123 124 ```sh 125 docker run -d --name gochain-node -v /Users/alice/GoChain:/root \ 126 -p 8545:8545 -p 30303:30303 \ 127 gochain/gochain 128 ``` 129 130 This will start GoChain in fast-sync mode with a DB memory allowance of 1GB just as the above command does. It will also create a persistent volume in your home directory for saving your blockchain as well as map the default ports. 131 132 Do not forget `--rpcaddr 0.0.0.0`, if you want to access RPC from other containers and/or hosts. By default, `gochain` binds to the local interface and RPC endpoints is not accessible from the outside. 133 134 ### Programatically interfacing GoChain nodes 135 136 As a developer, sooner rather than later you'll want to start interacting with GoChain network via your 137 own programs and not manually through the console. To aid this, GoChain has built in 138 support for a JSON-RPC based APIs ([standard APIs](https://github.com/ethereum/wiki/wiki/JSON-RPC) and 139 [GoChain specific APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs)). These can be 140 exposed via HTTP, WebSockets and IPC (unix sockets on unix based platforms, and named pipes on Windows). 141 142 The IPC interface is enabled by default and exposes all the APIs supported by GoChain, whereas the HTTP 143 and WS interfaces need to manually be enabled and only expose a subset of APIs due to security reasons. 144 These can be turned on/off and configured as you'd expect. 145 146 HTTP based JSON-RPC API options: 147 148 * `--rpc` Enable the HTTP-RPC server 149 * `--rpcaddr` HTTP-RPC server listening interface (default: "localhost") 150 * `--rpcport` HTTP-RPC server listening port (default: 8545) 151 * `--rpcapi` API's offered over the HTTP-RPC interface (default: "eth,net,web3") 152 * `--rpccorsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced) 153 * `--ws` Enable the WS-RPC server 154 * `--wsaddr` WS-RPC server listening interface (default: "localhost") 155 * `--wsport` WS-RPC server listening port (default: 8546) 156 * `--wsapi` API's offered over the WS-RPC interface (default: "eth,net,web3") 157 * `--wsorigins` Origins from which to accept websockets requests 158 * `--ipcdisable` Disable the IPC-RPC server 159 * `--ipcapi` API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,web3") 160 * `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it) 161 162 You'll need to use your own programming environments' capabilities (libraries, tools, etc) to connect 163 via HTTP, WS or IPC to a GoChain node configured with the above flags and you'll need to speak [JSON-RPC](http://www.jsonrpc.org/specification) 164 on all transports. You can reuse the same connection for multiple requests! 165 166 **Note: Please understand the security implications of opening up an HTTP/WS based transport before 167 doing so! Hackers on the internet are actively trying to subvert GoChain nodes with exposed APIs! 168 Further, all browser tabs can access locally running webservers, so malicious webpages could try to 169 subvert locally available APIs!** 170 171 ### Operating a private network 172 173 See: https://github.com/gochain/docs/tree/master/nodes/custom 174 175 ## Contribution 176 177 Thank you for considering to help out with the source code! We welcome contributions from 178 anyone on the internet, and are grateful for even the smallest of fixes! 179 180 If you'd like to contribute to GoChain, please fork, fix, commit and send a pull request 181 for the maintainers to review and merge into the main code base. 182 183 Please make sure your contributions adhere to our coding guidelines: 184 185 * Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)). 186 * Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines. 187 * Pull requests need to be based on and opened against the `master` branch. 188 * Commit messages should be prefixed with the package(s) they modify. 189 * E.g. "gochain, rpc: make trace configs optional" 190 191 ## License 192 193 The gochain library (i.e. all code outside of the `cmd` directory) is licensed under the 194 [GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html), also 195 included in our repository in the `COPYING.LESSER` file. 196 197 The gochain binaries (i.e. all code inside of the `cmd` directory) is licensed under the 198 [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also included 199 in our repository in the `COPYING` file.