Scala implementation of the Tron Protocol
Quick Start • Goals • How To Use • Cluster • Wiki • Contributing • Contact
TRON is a block chain-based decentralized smart protocol and an application development platform. It allows each user to freely publish, store and own contents and data, and in the decentralized autonomous form, decides an incentive mechanism and enables application developers and content creators through digital asset distribution, circulation and transaction, thus forming a decentralized content entertainment ecosystem.
TRON is a product of Web 4.0 and the decentralized internet of next generation.
- Compatible with java-tron
- Non-blocking
- Functional programming approach
- Reactive
- User-friendly interface
This project requires SBT
SBT (Simple Build Tool) is an open-source build tool for Scala and Java projects, similar to Java's Maven and Ant.
Follow the instructions installing SBT to install SBT
git clone http://github.com/tronprotocol-scala/scala-tron
cd scala-tron
sbt "project cli" run
The application can be interfaced in 2 ways:
- Web Interface (API based)
- Command Line Interface (CLI)
To launch the project on a command line, First run:
sbt "project cli" run
After that the following commands are available:
Opens a address
Example
> address --open BW4kf1Pyoi3XkKGF9FTMPFk8QBTezcb6QzD6EeYSXP73
Opened address 25ace46c656fb98027caee704a7790c7ec0b32fe
Generates a new address
Example
> address --create
Address Generated!
Address: c93a9fe9a04524d7cb1f1413ac5e75f77b179e27
Private Key 67dsochCai4PdoLnzevHwXQWLeHiMKcEfoHEzLCDBu2X
Show account key
Show account balance
Sends the given amount to the given address
In order to execute the following commands, the cluster has to be up and running properly
Start cluster as leader
Join cluster as client
Starts the Web API server. After starting the API it can be reached at http://localhost:9000
Starts the GRPC server
Cluster is based on Akka.
Akka is a toolkit for building highly concurrent, distributed, and resilient message-driven applications for Java and Scala
To start a cluster follow the following steps:
- Start tron-cli
sbt "project cli" run
- Run
cluster
which starts the node as leader - The console will show the following logs
[INFO] [01/18/2018 22:59:28.399] [main] [akka.remote.Remoting] Starting remoting
[INFO] [01/18/2018 22:59:28.553] [main] [akka.remote.Remoting] Remoting started; listening on addresses :[akka.tcp://[email protected]:41795]
- Copy the address (
127.0.0.1:41795
) - Start a second instance which will join the cluster. The second client has to have a different database directory to prevent conflicts.
- Run
sbt -J-Ddatabase.directory=tron-data-client1 "project cli" run
.
-J-Ddatabase.directory=tron-data-client1
specifies the database directory - Run
cluster --join <address>
(example:cluster --join 127.0.0.1:41795
) - The client will now be joining the cluster
Start the server using sbt "project api" run
The API will then be available on http://localhost:9000
Shows the balance of the address for the given public key
Response
{
"address": "a9c030dfbfb83f6c9454b5e1da5cecdb8737d4af",
"balance": 10
}
Generates a new address
Response
{
"address": "fa7c845598653c11f01edda16d923b5ba7942e1e",
"private_key": "GWCuQQCz7v9vXkn3BJMTmA86kj58UCdHmSw1tBu4DLe1"
}