The Scala SDK for the Stellar network provides an API to:
- Create accounts
- Build and submit transactions
- Query network state from Horizon
- Stream network updates from Horizon [Pending]
- Query federation servers [Pending]
A Scala developer would choose to use this SDK because it aims to provide:
-
Convenience
- Asynchronous by default
- Encapsulation of paged responses into
Stream
s - Case classes instead of builder patterns
- Perform network operations on the terminal through the scala REPL
-
Correctness
- Generative testing using scalacheck with the goal of 100% test coverage
Option
s, not nullsTry
s, not exceptions- Explicit type hierarchies instead of meaningful primitives
At this stage, some classes and interfaces are likely to be refined. Minor releases may break backwards compatibility with minimal notice until v1.0.0.
In your build.sbt
resolvers += "scala-stellar-sdk-repo" at "https://dl.bintray.com/synesso/mvn"
libraryDependencies += "stellar.scala.sdk" %% "scala-stellar-sdk" % "0.1.2.1"
The following examples use the Ammonite REPL. After launching amm
, fetch and import the
Stellar SDK for Scala.
interp.repositories() ++= Seq(coursier.MavenRepository("https://dl.bintray.com/synesso/mvn/"))
import $ivy.`stellar.scala.sdk::scala-stellar-sdk:0.1.2.1`
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent._
import stellar.sdk._
import stellar.sdk.op._
import stellar.sdk.resp._
val kp = KeyPair.random
TestNetwork.fund(kp)
import scala.util.Success
TestNetwork.account(kp) onSuccess { case resp =>
println(s"""
|Account ${resp.id}
| Last sequence was ${resp.lastSequence}.
| Balances: ${resp.balances.mkString(",")}
""".stripMargin)
}
implicit val network = TestNetwork
val funder: KeyPair = kp // funded account from first example
val toCreate = KeyPair.random
for {
account <- TestNetwork.account(funder)
txn <- Future.fromTry {
Transaction(Account(funder, account.lastSequence + 1))
.add(CreateAccountOperation(toCreate, Amount.lumens(1)))
.sign(funder)
}
} yield txn.submit
Additional examples can be found in the /examples
folder.
Project progress & roadmap can be viewed in the projects tab.
Contributions are warmly welcomed. See issues for features that can be worked on immediately. Or feel free to add your own features/issues to that list.
Let's chat about this on the Stellar-public Slack #dev channel. My username is @jem.