| Actions CI | Go Report Card |
|---|---|
ELA is the digital currency solution within the Elastos ecosystem. It is merged mined with Bitcoin which means the existing bitcoin miners are able to merge mine both BTC and ELA at the same time without expending any additional resources or energy while also providing the enormous hashpower that comes with the bitcoin network.
This project is the source code that can build a full node of ELA blockchain(main chain).
Make sure the macOS version Mojave or later 64-bit Intel.
$ uname -srm
Darwin 18.7.0 x86_64Use Homebrew to install Golang 1.16
$ brew install go@1.16Check the golang version. Make sure they are the following version number or above.
$ go version
go version go1.16.5 darwin/amd64Make sure your ubuntu version is 18.04 or later.
$ cat /etc/issue
Ubuntu 18.04.5 LTS \n \lInstall Git.
$ sudo apt-get install -y gitInstall Go distribution.
$ curl -O https://golang.org/dl/go1.13.15.linux-amd64.tar.gz
$ tar -xvf go1.13.15.linux-amd64.tar.gz
$ sudo chown -R root:root ./go
$ sudo mv go /usr/local
$ export GOPATH=$HOME/go
$ export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
$ source ~/.profileMake sure you are in the working folder.
$ git clone https://github.com/elastos/Elastos.ELA.gitIf clone works successfully, you should see folder structure like Elastos.ELA/Makefile
Build the node.
$ cd Elastos.ELA
$ go get .
$ go mod tidy
$ makeIf you did not see any error message, congratulations, you have made the ELA full node.
You can just run a ela node without a config.json file, the ela node will use the main net configuration by default, and provide a JSON-RPC service on http://localhost:20336.
If you want to customize the node configuration, see the config.json to understand what each parameter means on the configuration file.
If you would like to connect to testnet, do the following:
$ cp -v docs/testnet_config.json.sample config.jsonIf you would like a simple config template, do the following:
$ cp -v docs/mainnet_config.json.sample config.jsonMake sure to modify the parameters to what your own specification.
Run the node.
$ ./elaAlternatively, if don't want to build it manually on Mac or Linux, we also provide a Dockerfile to help you (You need to have Docker installed).
$ cd docker
$ docker build -t ela_node_run .$ docker run -p 20334:20334 -p 20335:20335 -p 20336:20336 -p 20338:20338 ela_node_runNote: Don't hit Ctrl-C to terminate the output; instead close this terminal and open another.
Please note the dockerfile uses the default 'config.json' in the repository. If you're familiar with Docker, you can change the dockerfile to make it use your own ELA Node configuration file.
If you would like to access the Web UI of the node to get different stats about the node, go to the following URL on your browser: http://localhost:21333/info
Once the node is running successfully, you can access ELA Node's REST APIs:
Example 1: Get the number of nodes to which the node is connected
$ curl http://localhost:21334/api/v1/node/connectioncount{
"Desc": "Success",
"Error": 0,
"Result": 5
}Example 2: Get the block height of the node
$ curl http://localhost:21334/api/v1/block/height{
"Desc": "Success",
"Error": 0,
"Result": 1000
}If you would like to learn more about what other REST APIs are available for the node, please check out the Restful API
Once the node is running successfully, you can access ELA Node's JSON-RPC APIs:
Example 1: Get the hash of the most recent block
$ curl -H 'Content-Type: application/json' -H 'Accept:application/json' \
--data '{"method":"getbestblockhash"}' http://localhost:21336{
"error": null,
"id": null,
"jsonrpc": "2.0",
"result": "c4e72359cbb128bca244a800fb36d71f64b834e20d437c25de6c62edc46196c7"
}Example 2: Get the hash of the specific blockchain height
$ curl -H 'Content-Type: application/json' -H 'Accept:application/json' \
--data '{"method":"getblockhash","params":{"height":1}}' http://localhost:21336{
"error": null,
"id": null,
"jsonrpc": "2.0",
"result": "71b422e09dcd2f749d2adc0086735c210084cdb6b59bd4cd42e50455d024a662"
}If you would like to learn more about what other JSON-RPC APIs are available for the node, please check out the JSON-RPC API
We welcome contributions to the Elastos ELA Project.
A sincere thank you to all teams and projects that we rely on directly or indirectly.
This project is licensed under the terms of the MIT license.