scala-tron
Scala implementation of the Tron Protocol
Quick Start • How To Use • Cluster • Wiki • Contact
What’s TRON?
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.
Quick Start
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/rovak/scala-tron
cd scala-tron
sbt "project cli" run
How To Use
The application can be interfaced in 2 ways:
- Web Interface (API based)
- Command Line Interface (CLI)
Command Line
To launch the project on a command line, First run:
sbt "project cli" run
After that the following commands are available:
account
Show account key
balance
Show account balance
send --to <address> --amount <amount>
Sends the given amount to the given address
In order to execute the following commands, the cluster has to be up and running properly
cluster
Start cluster as leader
cluster --join <address>
Join cluster as client
Cluster
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://TronCluster@127.0.0.1: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
Web API
Start the server using sbt "project api" run
The API will then be available on http://localhost:9000
/wallet/<public key>
Shows the balance of the wallet for the given public key
Response
{
"address": "a9c030dfbfb83f6c9454b5e1da5cecdb8737d4af",
"balance": 10
}