neoneo-go/README.md

174 lines
4.6 KiB
Markdown
Raw Normal View History

2018-01-28 18:05:06 +00:00
<p align="center">
2018-02-24 07:23:02 +00:00
<img
src="http://res.cloudinary.com/vidsy/image/upload/v1503160820/CoZ_Icon_DARKBLUE_200x178px_oq0gxm.png"
width="125px"
>
2018-01-28 18:05:06 +00:00
</p>
2018-02-01 17:40:04 +00:00
<h1 align="center">neo-go</h1>
2018-01-28 18:05:06 +00:00
<p align="center">
2018-02-01 17:40:04 +00:00
<b>Go</b> Node and SDK for the <a href="https://neo.org">NEO</a> blockchain.
2018-01-28 18:05:06 +00:00
</p>
<p align="center">
2018-02-02 19:04:56 +00:00
<a href="https://github.com/CityOfZion/neo-go/releases">
<img src="https://img.shields.io/github/tag/CityOfZion/neo-go.svg?style=flat">
</a>
<a href="https://circleci.com/gh/CityOfZion/neo-go/tree/master">
<img src="https://circleci.com/gh/CityOfZion/neo-go/tree/master.svg?style=shield">
</a>
<a href="https://goreportcard.com/report/github.com/CityOfZion/neo-go">
<img src="https://goreportcard.com/badge/github.com/CityOfZion/neo-go">
</a>
</p>
2018-01-28 18:05:06 +00:00
# Overview
2018-02-01 17:40:04 +00:00
> This project is currently in **alpha** and under active development.
2018-01-28 18:05:06 +00:00
2018-02-01 17:40:04 +00:00
## Project Goals
2018-02-24 07:23:02 +00:00
Full port of the original C# [NEO project](https://github.com/neo-project).
2018-02-01 17:40:04 +00:00
A complete toolkit for the NEO blockchain, including:
- Full consensus node
- Full RPC node
2018-01-28 18:05:06 +00:00
- RPC client
2018-02-01 18:08:54 +00:00
- CLI tool
2018-02-01 17:40:04 +00:00
- Smart contract compiler
## Current State
2018-01-28 18:05:06 +00:00
2018-02-01 17:40:04 +00:00
The project will exist out of the following packages:
2018-01-31 11:51:02 +00:00
2018-02-01 17:40:04 +00:00
| Package | State | Developer |
|---------------|---------|--------------------------------------|
| core | started | [@anthdm](https://github.com/anthdm) |
| network | started | [@anthdm](https://github.com/anthdm) |
| vm | started | [@anthdm](https://github.com/anthdm) |
| compiler | started | [@anthdm](https://github.com/anthdm) |
| client | started | [@revett](https://github.com/revett) |
| cli | started | [@revett](https://github.com/revett) |
| wallet | started | [@pawanrawal](https://github.com/pawanrawal) |
2018-01-31 11:51:02 +00:00
2018-02-24 07:23:02 +00:00
# Getting Started
2018-01-28 18:37:03 +00:00
## Node
2018-01-28 18:37:03 +00:00
2018-02-24 07:23:02 +00:00
Install dependencies, this requires [dep](https://github.com/golang/dep):
2018-02-01 17:40:04 +00:00
2018-02-01 18:06:17 +00:00
```
make deps
```
Build the **neo-go** CLI:
```
make build
```
2018-02-01 17:40:04 +00:00
2018-02-24 07:23:02 +00:00
Currently, there is a minimal subset of the NEO protocol implemented.
To start experimenting make sure you a have a private net running on your machine.
If you dont, take a look at [docker-privnet-with-gas](https://hub.docker.com/r/metachris/neo-privnet-with-gas/).
2018-01-31 11:51:02 +00:00
Start a NEO node:
2018-01-28 18:37:03 +00:00
2018-02-01 17:40:04 +00:00
```
make run
2018-02-01 17:40:04 +00:00
```
2018-01-28 18:37:03 +00:00
2018-01-31 11:51:02 +00:00
You can add multiple seeds if you want:
2018-02-01 17:40:04 +00:00
```
make run -e SEEDS="127.0.0.1:20333,127.0.01:20334"
2018-02-01 17:40:04 +00:00
```
2018-02-24 07:23:02 +00:00
By default the server will currently run on port 3000, for testing purposes.
2018-02-01 17:40:04 +00:00
You can change that by setting the tcp flag:
2018-01-31 11:51:02 +00:00
```
make run -e PORT="1337"
```
To run the binary directly:
2018-02-01 17:40:04 +00:00
```
./bin/neo-go node -seed 127.0.0.1:20333 -tcp 1337
2018-02-01 17:40:04 +00:00
```
2018-02-01 17:40:04 +00:00
## RPC
If you want your node to also serve JSON-RPC, you can do that by setting the following flag:
2018-02-01 17:40:04 +00:00
```
./bin/neo-go node -rpc 4000
2018-02-01 17:40:04 +00:00
```
2018-02-24 07:23:02 +00:00
In this case the server will accept and respond JSON-RPC on port 4000.
Keep in mind that currently there is only a small subset of the JSON-RPC implemented.
2018-02-01 17:40:04 +00:00
Feel free to make a PR with more functionality.
2018-01-31 11:51:02 +00:00
2018-02-01 17:40:04 +00:00
## VM
2018-01-31 11:51:02 +00:00
2018-02-01 17:40:04 +00:00
```
TODO
```
## Smart Contracts
> In depth documentation about the neo-go compiler and smart contract examples can be found inside the [compiler package](https://github.com/CityOfZion/neo-go/tree/master/pkg/vm/compiler).
### Compile a smart contract
2018-02-01 17:40:04 +00:00
```
./bin/neo-go contract compile -i mycontract.go
```
By default the filename will be the name of your .go file with the .avm extension, the file will be located in the same directory where you called the command from. If you want another location for your compiled contract:
```
./bin/neo-go contract compile -i mycontract.go --out /Users/foo/bar/contract.avm
```
### Debugging your smart contract
You can dump the opcodes generated by the compiler with the following command:
```
./bin/neo-go contract opdump -i mycontract.go
```
This will result in something like this:
```
INDEX OPCODE DESC
0 0x52 OpPush2
1 0xc5 OpNewArray
2 0x6b OpToAltStack
3 0x 0 OpPush0
4 0x6c OpFromAltStack
5 0x76 OpDup
6 0x6b OpToAltStack
7 0x 0 OpPush0
8 0x52 OpPush2
9 0x7a OpRoll
10 0xc4 OpSetItem
2018-02-01 17:40:04 +00:00
```
2018-01-28 18:37:03 +00:00
2018-01-29 07:11:08 +00:00
# Contributing
2018-01-31 11:51:02 +00:00
2018-02-24 07:23:02 +00:00
Feel free to contribute to this project after reading the
[contributing guidelines](https://github.com/CityOfZion/neo-go/blob/master/CONTRIBUTING.md).
2018-02-01 17:40:04 +00:00
2018-02-24 07:23:02 +00:00
Before starting to work on a certain topic, create an new issue first,
2018-02-01 17:40:04 +00:00
describing the feauture/topic you are going to implement.
2018-01-29 07:11:08 +00:00
2018-01-31 10:58:19 +00:00
# Contact
2018-02-01 17:40:04 +00:00
2018-01-31 10:58:19 +00:00
- [@anthdm](https://github.com/anthdm) on Github
- [@anthdm](https://twitter.com/anthdm) on Twitter
- Send me an email anthony@cityofzion.io
# License
2018-02-01 17:40:04 +00:00
- Open-source [MIT](https://github.com/anthdm/neo-go/blob/master/LICENCE.md)