github.com/puffscoin/go-puffscoin@v0.0.0-20190701205704-e48ad5c90fa1/README.md (about) 1 ## go-PUFFScoin 2 3 Official Golang implementation of the PUFFScoin protocol. 4 5 [![API Reference]](https://godoc.org/github.com/puffscoin/go-puffscoin) 6 [![Go Report Card](https://goreportcard.com/badge/github.com/puffscoin/go-puffscoin)](https://goreportcard.com/report/github.com/puffscoin/go-puffscoin) 7 [![Travis](https://travis-ci.org/puffscoin/go-puffscoin.svg?branch=master)](https://travis-ci.org/puffscoin/go-puffscoin) 8 [![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.gg/A5nNsZF) 9 10 Automated builds are available for stable releases and the unstable master branch. 11 Links to binary archives are published at http://puffscoin.leafycauldronapothecary.com/downloads/. 12 13 ## Building the source 14 15 For prerequisites and detailed build instructions please read the 16 [Installation Instructions](http://puffscoin.leafycauldronapothecary.com/puffwiki/the-basics/building-puffscoin/) 17 on the puffswiki. 18 19 Building gpuffs requires both a Go (version 1.10 or later) and a C compiler. 20 You can install them using your favourite package manager. 21 Once the dependencies are installed, run 22 23 make gpuffs 24 25 or, to build the full suite of utilities: 26 27 make all 28 29 ## Executables 30 31 The go-puffscoin project comes with several wrappers/executables found in the `cmd` directory. 32 33 | Command | Description | 34 |:----------:|-------------| 35 | **`gpuffs`** | The main PUFFScoin CLI client. It is the entry point into the PUFFScoin network, 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 PUFFScoin network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `gpuffs --help` and the [CLI puffswiki page](http://puffscoin.leafycauldronapothecary.com/puffwiki/the-basics/command-line-options/) for command line options. | 36 | `abigen` | Source code generator to convert PUFFScoin contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain [Solidity contract ABIs](https://solidity.readthedocs.io/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](http://puffscoin.leafycauldronapothecary.com/native-dapps-go-bindings-to-puffscoin-contracts/) puffswiki entry for details. | 37 | `bootnode` | Stripped down version of our PUFFScoin 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. | 38 | `evm` | Developer utility version of the PUFFScoin 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`). | 39 | `gethrpctest` | Developer utility tool to support our [ethereum/rpc-test](https://github.com/puffscoin/rpc-tests) test suite which validates baseline conformity to the [Ethereum JSON RPC](http://puffscoin.leafycauldronapothecary.com/puffwiki/blockchain-protocols/json-rpc-api/) specs. | 40 | `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://github.com/ethereum/wiki/wiki/RLP)) dumps (data encoding used by the PUFFScoin protocol both network as well as consensus wise) to user-friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). | 41 | `swarm` | Swarm daemon and tools. This is the entry point for the Swarm network. `swarm --help` for command line options and subcommands. See [Swarm](http://puffscoin.leafycauldronapothecary.com/services/swarm/) for more information. | 42 | `puppeth` | a CLI wizard that aids in creating a new PUFFScoin-compliant network. | 43 44 ## Running gpuffs 45 46 Going through all the possible command line flags is out of scope here (please consult our 47 [CLI Wiki page](http://puffscoin.leafycauldronapothecary.com/puffwiki/the-basics/command-line-options/)), but we've 48 enumerated a few common parameter combos to get you up to speed quickly on how you can run your 49 own gpuffs instance. 50 51 ### Full node on the main PUFFScoin network 52 53 By far the most common scenario is people wanting to simply interact with the PUFFScoin network: 54 create accounts; transfer funds; deploy and interact with contracts. For this particular use-case 55 the user doesn't care about years-old historical data, so we can fast-sync quickly to the current 56 state of the network. To do so: 57 58 ``` 59 $ gpuffs console 60 ``` 61 62 This command will: 63 64 * Start gpuffs in fast sync mode (default, can be changed with the `--syncmode` flag), causing it to 65 download more data in exchange for avoiding processing the entire history of the PUFFScoin network, 66 which may become very CPU intensive as he blockchain grows, as evidenced form Ethereum, Bitcoin and 67 other projects with blockchains well in excess of 1GB. 68 * Start up gpuffs' built-in interactive [JavaScript console](http://puffscoin.leafycauldronapothecary.com/javascript-console/), 69 (via the trailing `console` subcommand) through which you can invoke all official [`web3` methods](http://puffscoin.leafycauldronapothecary.com/javascript-api/) 70 as well as gpuffs' own [management APIs](http://puffscoin.leafycauldronapothecary.com/puffwiki/blockchain-protocols/management-apis/). 71 This tool is optional and if you leave it out you can always attach to an already running gpuffs instance 72 with `gpuffs attach`. 73 74 75 76 ### Configuration 77 78 As an alternative to passing the numerous flags to the `gpuffs` binary, you can also pass a configuration file via: 79 80 ``` 81 $ gpuffs --config /path/to/your_config.toml 82 ``` 83 84 To get an idea how the file should look like you can use the `dumpconfig` subcommand to export your existing configuration: 85 86 ``` 87 $ gpuffs --your-favourite-flags dumpconfig 88 ``` 89 90 91 #### Docker quick start 92 93 One of the quickest ways to get PUFFScoin up and running on your machine is by using Docker: 94 95 ``` 96 docker run -d --name puffscoin-node -v /Users/alice/puffscoin:/root \ 97 -p 11363:11363 -p 31313:31313 \ 98 puffscoin/client-go 99 ``` 100 101 This will start gpuffs 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. There is also an `alpine` tag available for a slim version of the image. 102 103 Do not forget `--rpcaddr 0.0.0.0`, if you want to access RPC from other containers and/or hosts. By default, `gpuffs` binds to the local interface and RPC endpoints is not accessible from the outside. 104 105 ### Programmatically interfacing gpuffs nodes 106 107 As a developer, sooner rather than later you'll want to start interacting with gpuffs and the PUFFScoin 108 network via your own programs and not manually through the console. To aid this, gpuffs has built-in 109 support for a JSON-RPC based APIs ([standard APIs](http://puffscoin.leafycauldronapothecary.com/puffwiki/blockchain-protocols/json-rpc-api/) and 110 [Geth specific APIs](http://puffscoin.leafycauldronapothecary.com/puffwiki/blockchain-protocols/management-apis/)). These can be 111 exposed via HTTP, WebSockets and IPC (UNIX sockets on UNIX based platforms, and named pipes on Windows). 112 113 The IPC interface is enabled by default and exposes all the APIs supported by gpuffs, whereas the HTTP 114 and WS interfaces need to manually be enabled and only expose a subset of APIs due to security reasons. 115 These can be turned on/off and configured as you'd expect. 116 117 HTTP based JSON-RPC API options: 118 119 * `--rpc` Enable the HTTP-RPC server 120 * `--rpcaddr` HTTP-RPC server listening interface (default: "localhost") 121 * `--rpcport` HTTP-RPC server listening port (default: 8545) 122 * `--rpcapi` API's offered over the HTTP-RPC interface (default: "eth,net,web3") 123 * `--rpccorsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced) 124 * `--ws` Enable the WS-RPC server 125 * `--wsaddr` WS-RPC server listening interface (default: "localhost") 126 * `--wsport` WS-RPC server listening port (default: 11363) 127 * `--wsapi` API's offered over the WS-RPC interface (default: "eth,net,web3") 128 * `--wsorigins` Origins from which to accept websockets requests 129 * `--ipcdisable` Disable the IPC-RPC server 130 * `--ipcapi` API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,web3") 131 * `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it) 132 133 You'll need to use your own programming environments' capabilities (libraries, tools, etc) to connect 134 via HTTP, WS or IPC to a Geth node configured with the above flags and you'll need to speak [JSON-RPC](https://www.jsonrpc.org/specification) 135 on all transports. You can reuse the same connection for multiple requests! 136 137 **Note: Please understand the security implications of opening up an HTTP/WS based transport before 138 doing so! Hackers omay try to subvert PUFFScoin nodes with exposed APIs! 139 Further, all browser tabs can access locally running web servers, so malicious web pages could try to 140 subvert locally available APIs!** 141 142 ### Operating a private network 143 144 Maintaining your own private network is more involved as a lot of configurations taken for granted in 145 the official networks need to be manually set up. 146 147 #### Defining the private genesis state 148 149 First, you'll need to create the genesis state of your networks, which all nodes need to be aware of 150 and agree upon. This consists of a small JSON file (e.g. call it `genesis.json`): 151 152 ```json 153 { 154 "config": { 155 "chainId": 0, 156 "homesteadBlock": 0, 157 "eip155Block": 0, 158 "eip158Block": 0 159 }, 160 "alloc" : {}, 161 "coinbase" : "0x0000000000000000000000000000000000000000", 162 "difficulty" : "0x20000", 163 "extraData" : "", 164 "gasLimit" : "0x2fefd8", 165 "nonce" : "0x0000000000000042", 166 "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000", 167 "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", 168 "timestamp" : "0x00" 169 } 170 ``` 171 172 The above fields should be fine for most purposes, although we'd recommend changing the `nonce` to 173 some random value so you prevent unknown remote nodes from being able to connect to you. If you'd 174 like to pre-fund some accounts for easier testing, you can populate the `alloc` field with account 175 configs: 176 177 ```json 178 "alloc": { 179 "0x0000000000000000000000000000000000000001": {"balance": "111111111"}, 180 "0x0000000000000000000000000000000000000002": {"balance": "222222222"} 181 } 182 ``` 183 184 With the genesis state defined in the above JSON file, you'll need to initialize **every** Geth node 185 with it prior to starting it up to ensure all blockchain parameters are correctly set: 186 187 ``` 188 $ geth init path/to/genesis.json 189 ``` 190 191 #### Creating the rendezvous point 192 193 With all nodes that you want to run initialized to the desired genesis state, you'll need to start a 194 bootstrap node that others can use to find each other in your network and/or over the internet. The 195 clean way is to configure and run a dedicated bootnode: 196 197 ``` 198 $ bootnode --genkey=boot.key 199 $ bootnode --nodekey=boot.key 200 ``` 201 202 With the bootnode online, it will display an [`enode` URL](https://github.com/ethereum/wiki/wiki/enode-url-format) 203 that other nodes can use to connect to it and exchange peer information. Make sure to replace the 204 displayed IP address information (most probably `[::]`) with your externally accessible IP to get the 205 actual `enode` URL. 206 207 *Note: You could also use a full-fledged gpuffs node as a bootnode, but it's the less recommended way.* 208 209 #### Starting up your member nodes 210 211 With the bootnode operational and externally reachable (you can try `telnet <ip> <port>` to ensure 212 it's indeed reachable), start every subsequent gpuffs node pointed to the bootnode for peer discovery 213 via the `--bootnodes` flag. It will probably also be desirable to keep the data directory of your 214 private network separated, so do also specify a custom `--datadir` flag. 215 216 ``` 217 $ geth --datadir=path/to/custom/data/folder --bootnodes=<bootnode-enode-url-from-above> 218 ``` 219 220 *Note: Since your network will be completely cut off from the main and test networks, you'll also 221 need to configure a miner to process transactions and create new blocks for you.* 222 223 #### Running a private miner 224 225 Mining on the public PUFFScoin network is a complex task as it's only feasible using GPUs, requiring 226 an OpenCL or CUDA enabled `ethminer` instance. For information on such a setup, please consult the 227 [EtherMining subreddit](https://www.reddit.com/r/EtherMining/) and the [Genoil miner](https://github.com/Genoil/cpp-ethereum) 228 repository. 229 230 In a private network setting, however a single CPU miner instance is more than enough for practical 231 purposes as it can produce a stable stream of blocks at the correct intervals without needing heavy 232 resources (consider running on a single thread, no need for multiple ones either). To start a Geth 233 instance for mining, run it with all your usual flags, extended by: 234 235 ``` 236 $ geth <usual-flags> --mine --minerthreads=1 --etherbase=0x0000000000000000000000000000000000000000 237 ``` 238 239 Which will start mining blocks and transactions on a single CPU thread, crediting all proceedings to 240 the account specified by `--etherbase`. You can further tune the mining by changing the default gas 241 limit blocks converge to (`--targetgaslimit`) and the price transactions are accepted at (`--gasprice`). 242 243 244 245 Please see the [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide) 246 for more details on configuring your environment, managing project dependencies, and testing procedures. 247 248 ## License 249 250 The go-ethereum library (i.e. all code outside of the `cmd` directory) is licensed under the 251 [GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html), also 252 included in our repository in the `COPYING.LESSER` file. 253 254 The go-ethereum binaries (i.e. all code inside of the `cmd` directory) is licensed under the 255 [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also included 256 in our repository in the `COPYING` file. 257 258 go-puffsconi is a project initiated and maintained by the PUFFScoin Core Development Team. PUFFScoin is a subsidiary service of The Leafy Cauldron Apothecary, LLC. (Nova Scotia)