github.com/abschain-develop/go-abs@v2.0.3+incompatible/README.md (about) 1 ## Go ABS 2 3 Official Golang implementation of the ABS protocol. 4 5 [![API Reference]( 6 https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667 7 )](https://godoc.org/github.com/abschain-develop/go-abs) 8 [![Go Report Card](https://goreportcard.com/badge/github.com/abschain-develop/go-abs)](https://goreportcard.com/report/github.com/abschain-develop/go-abs) 9 [![Travis](https://travis-ci.org/abschain-develop/go-abs.svg?branch=master)](https://travis-ci.org/abschain-develop/go-abs) 10 [![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](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://github.com/abschain-develop/go-abs/releases. 14 15 ## Building the source 16 17 For prerequisites and detailed build instructions please read the [Installation Instructions](https://github.com/abschain-develop/go-abs/wiki/Building-ABS) on the wiki. 18 19 Building `gabs` requires both a Go (version 1.10 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 gabs 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-abs project comes with several wrappers/executables found in the `cmd` 35 directory. 36 37 | Command | Description | 38 | :-----------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 39 | **`gabs`** | Our main ABS CLI client. It is the entry point into the ABS 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 ABS network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `gabs --help` and the [CLI Wiki page](https://github.com/abschain-develop/go-abs/wiki/Command-Line-Options) for command line options. | 40 | `abigen` | Source code generator to convert ABS contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain [ABS contract ABIs](https://github.com/abschain-develop/wiki/wiki/ABS-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/abschain-develop/go-abs/wiki/Native-DApps:-Go-bindings-to-ABS-contracts) wiki page for details. | 41 | `bootnode` | Stripped down version of our ABS 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. | 42 | `evm` | Developer utility version of the EVM (ABS 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`). | 43 | `gabsrpctest` | Developer utility tool to support our [abs/rpc-test](https://github.com/abschain-develop/rpc-tests) test suite which validates baseline conformity to the [ABS JSON RPC](https://github.com/abschain-develop/wiki/wiki/JSON-RPC) specs. Please see the [test suite's readme](https://github.com/abschain-develop/rpc-tests/blob/master/README.md) for details. | 44 | `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://github.com/abschain-develop/wiki/wiki/RLP)) dumps (data encoding used by the ABS protocol both network as well as consensus wise) to user-friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). | 45 | `puppeth` | a CLI wizard that aids in creating a new ABS network. | 46 47 ## Running `gabs` 48 49 Going through all the possible command line flags is out of scope here (please consult our 50 [CLI Wiki page](https://github.com/abschain-develop/go-abs/wiki/Command-Line-Options)), 51 but we've enumerated a few common parameter combos to get you up to speed quickly 52 on how you can run your own `gabs` instance. 53 54 ### Full node on the main ABS network 55 56 By far the most common scenario is people wanting to simply interact with the ABS 57 network: create accounts; transfer funds; deploy and interact with contracts. For this 58 particular use-case the user doesn't care about years-old historical data, so we can 59 fast-sync quickly to the current state of the network. To do so: 60 61 ```shell 62 $ gabs console 63 ``` 64 65 This command will: 66 * Start `gabs` in fast sync mode (default, can be changed with the `--syncmode` flag), 67 causing it to download more data in exchange for avoiding processing the entire history 68 of the ABS network, which is very CPU intensive. 69 * Start up `gabs`'s built-in interactive [JavaScript console](https://github.com/abschain-develop/go-abs/wiki/JavaScript-Console), 70 (via the trailing `console` subcommand) through which you can invoke all official [`web3` methods](https://github.com/abschain-develop/wiki/wiki/JavaScript-API) 71 as well as `gabs`'s own [management APIs](https://github.com/abschain-develop/go-abs/wiki/Management-APIs). 72 This tool is optional and if you leave it out you can always attach to an already running 73 `gabs` instance with `gabs attach`. 74 ABS 75 ### A Full node on the ABS test network 76 77 Transitioning towards developers, if you'd like to play around with creating ABS 78 contracts, you almost certainly would like to do that without any real money involved until 79 you get the hang of the entire system. In other words, instead of attaching to the main 80 network, you want to join the **test** network with your node, which is fully equivalent to 81 the main network. 82 83 ```shell 84 $ gabs --testnet console 85 ``` 86 87 The `console` subcommand has the exact same meaning as above and they are equally 88 useful on the testnet too. Please see above for their explanations if you've skipped here. 89 90 Specifying the `--testnet` flag, however, will reconfigure your `gabs` instance a bit: 91 92 * Instead of using the default data directory (`~/.abs` on Linux for example), `gabs` 93 will nest itself one level deeper into a `testnet` subfolder (`~/.abs/testnet` on 94 Linux). Note, on OSX and Linux this also means that attaching to a running testnet node 95 requires the use of a custom endpoint since `gabs attach` will try to attach to a 96 production node endpoint by default. E.g. 97 `gabs attach <datadir>/testnet/gabs.ipc`. Windows users are not affected by 98 this. 99 * Instead of connecting the main ABS network, the client will connect to the test 100 network, which uses different P2P bootnodes, different network IDs and genesis states. 101 102 *Note: Although there are some internal protective measures to prevent transactions from 103 crossing over between the main network and test network, you should make sure to always 104 use separate accounts for play-money and real-money. Unless you manually move 105 accounts, `gabs` will by default correctly separate the two networks and will not make any 106 accounts available between them.* 107 108 ### Configuration 109 110 As an alternative to passing the numerous flags to the `gabs` binary, you can also pass a 111 configuration file via: 112 113 ```shell 114 $ gabs --config /path/to/your_config.toml 115 ``` 116 117 To get an idea how the file should look like you can use the `dumpconfig` subcommand to 118 export your existing configuration: 119 120 ```shell 121 $ gabs --your-favourite-flags dumpconfig 122 ``` 123 124 *Note: This works only with `gabs` v1.6.0 and above.* 125 126 127 ### Programmatically interfacing `gabs` nodes 128 129 As a developer, sooner rather than later you'll want to start interacting with `gabs` and the 130 ABS network via your own programs and not manually through the console. To aid 131 this, `gabs` has built-in support for a JSON-RPC based APIs ([standard APIs](https://github.com/abschain-develop/wiki/wiki/JSON-RPC) 132 and [`gabs` specific APIs](https://github.com/abschain-develop/go-abs/wiki/Management-APIs)). 133 These can be exposed via HTTP, WebSockets and IPC (UNIX sockets on UNIX based 134 platforms, and named pipes on Windows). 135 136 The IPC interface is enabled by default and exposes all the APIs supported by `gabs`, 137 whereas the HTTP and WS interfaces need to manually be enabled and only expose a 138 subset of APIs due to security reasons. These can be turned on/off and configured as 139 you'd expect. 140 141 HTTP based JSON-RPC API options: 142 143 * `--rpc` Enable the HTTP-RPC server 144 * `--rpcaddr` HTTP-RPC server listening interface (default: `localhost`) 145 * `--rpcport` HTTP-RPC server listening port (default: `8545`) 146 * `--rpcapi` API's offered over the HTTP-RPC interface (default: `net,web3`) 147 * `--rpccorsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced) 148 * `--ws` Enable the WS-RPC server 149 * `--wsaddr` WS-RPC server listening interface (default: `localhost`) 150 * `--wsport` WS-RPC server listening port (default: `8546`) 151 * `--wsapi` API's offered over the WS-RPC interface (default: `net,web3`) 152 * `--wsorigins` Origins from which to accept websockets requests 153 * `--ipcdisable` Disable the IPC-RPC server 154 * `--ipcapi` API's offered over the IPC-RPC interface (default: `admin,debug,miner,net,personal,shh,txpool,web3`) 155 * `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it) 156 157 You'll need to use your own programming environments' capabilities (libraries, tools, etc) to 158 connect via HTTP, WS or IPC to a `gabs` node configured with the above flags and you'll 159 need to speak [JSON-RPC](https://www.jsonrpc.org/specification) on all transports. You 160 can reuse the same connection for multiple requests! 161 162 **Note: Please understand the security implications of opening up an HTTP/WS based 163 transport before doing so! Hackers on the internet are actively trying to subvert 164 ABS nodes with exposed APIs! Further, all browser tabs can access locally 165 running web servers, so malicious web pages could try to subvert locally available 166 APIs!** 167 168 ### Operating a private network 169 170 Maintaining your own private network is more involved as a lot of configurations taken for 171 granted in the official networks need to be manually set up. 172 173 #### Defining the private genesis state 174 175 First, you'll need to create the genesis state of your networks, which all nodes need to be 176 aware of and agree upon. This consists of a small JSON file (e.g. call it `genesis.json`): 177 178 ```json 179 { 180 "config": { 181 "chainId": <arbitrary positive integer>, 182 "homesteadBlock": 0, 183 "eip150Block": 0, 184 "eip155Block": 0, 185 "eip158Block": 0, 186 "byzantiumBlock": 0, 187 "constantinopleBlock": 0, 188 "petersburgBlock": 0 189 }, 190 "alloc": {}, 191 "coinbase": "0x0000000000000000000000000000000000000000", 192 "difficulty": "0x20000", 193 "extraData": "", 194 "gasLimit": "0x2fefd8", 195 "nonce": "0x0000000000000042", 196 "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", 197 "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 198 "timestamp": "0x00" 199 } 200 ``` 201 202 The above fields should be fine for most purposes, although we'd recommend changing 203 the `nonce` to some random value so you prevent unknown remote nodes from being able 204 to connect to you. If you'd like to pre-fund some accounts for easier testing, create 205 the accounts and populate the `alloc` field with their addresses. 206 207 ```json 208 "alloc": { 209 "0x0000000000000000000000000000000000000001": { 210 "balance": "111111111" 211 }, 212 "0x0000000000000000000000000000000000000002": { 213 "balance": "222222222" 214 } 215 } 216 ``` 217 218 With the genesis state defined in the above JSON file, you'll need to initialize **every** 219 `gabs` node with it prior to starting it up to ensure all blockchain parameters are correctly 220 set: 221 222 ```shell 223 $ gabs init path/to/genesis.json 224 ``` 225 226 #### Creating the rendezvous point 227 228 With all nodes that you want to run initialized to the desired genesis state, you'll need to 229 start a bootstrap node that others can use to find each other in your network and/or over 230 the internet. The clean way is to configure and run a dedicated bootnode: 231 232 ```shell 233 $ bootnode --genkey=boot.key 234 $ bootnode --nodekey=boot.key 235 ``` 236 237 With the bootnode online, it will display an [`enode` URL](https://github.com/abschain-develop/wiki/wiki/enode-url-format) 238 that other nodes can use to connect to it and exchange peer information. Make sure to 239 replace the displayed IP address information (most probably `[::]`) with your externally 240 accessible IP to get the actual `enode` URL. 241 242 *Note: You could also use a full-fledged `gabs` node as a bootnode, but it's the less 243 recommended way.* 244 245 #### Starting up your member nodes 246 247 With the bootnode operational and externally reachable (you can try 248 `telnet <ip> <port>` to ensure it's indeed reachable), start every subsequent `gabs` 249 node pointed to the bootnode for peer discovery via the `--bootnodes` flag. It will 250 probably also be desirable to keep the data directory of your private network separated, so 251 do also specify a custom `--datadir` flag. 252 253 ```shell 254 $ gabs --datadir=path/to/custom/data/folder --bootnodes=<bootnode-enode-url-from-above> 255 ``` 256 257 *Note: Since your network will be completely cut off from the main and test networks, you'll 258 also need to configure a miner to process transactions and create new blocks for you.* 259 260 #### Running a miner 261 262 Please wait for the official mining pool to open 263 264 265 ## Contribution 266 267 Thank you for considering to help out with the source code! We welcome contributions 268 from anyone on the internet, and are grateful for even the smallest of fixes! 269 270 If you'd like to contribute to go-abs, please fork, fix, commit and send a pull request 271 for the maintainers to review and merge into the main code base. If you wish to submit 272 more complex changes though, please check up with the core devs first on [our gitter channel](https://gitter.im/abschain-develop/go-abs) 273 to ensure those changes are in line with the general philosophy of the project and/or get 274 some early feedback which can make both your efforts much lighter as well as our review 275 and merge procedures quick and simple. 276 277 Please make sure your contributions adhere to our coding guidelines: 278 279 * Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) 280 guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)). 281 * Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) 282 guidelines. 283 * Pull requests need to be based on and opened against the `master` branch. 284 * Commit messages should be prefixed with the package(s) they modify. 285 286 Please see the [Developers' Guide](https://github.com/abschain-develop/go-abs/wiki/Developers'-Guide) 287 for more details on configuring your environment, managing project dependencies, and 288 testing procedures. 289 290 ## License 291 292 The go-abs library (i.e. all code outside of the `cmd` directory) is licensed under the 293 [GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html), 294 also included in our repository in the `COPYING.LESSER` file. 295 296 The go-abs binaries (i.e. all code inside of the `cmd` directory) is licensed under the 297 [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also 298 included in our repository in the `COPYING` file.