github.com/m3shine/gochain@v2.2.26+incompatible/README.md (about)

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