Stellar SDK for Scala

This is the SDK for performing Stellar operations via Scala. It provides the ability to access the Stellar network via Horizon instances to build and submit transactions, query the state of the network and stream updates.

Scala developers may prefer to use this SDK because:

  • it has a simple, Scala-centric API
  • its operations are asynchronous by default
  • it uses explicit type hierarchies instead of primitives
  • it is tested to near 100% coverage with generative testing

The code throughout this documentation is compiled against Scala 2.12.

Quick-start

Add the SDK via your dependency management tool.

sbt
libraryDependencies += "io.github.synesso" %% "scala-stellar-sdk" % "0.4.1"
Maven
<dependency>
  <groupId>io.github.synesso</groupId>
  <artifactId>scala-stellar-sdk_2.12</artifactId>
  <version>0.4.1</version>
</dependency>
Gradle
dependencies {
  compile group: 'io.github.synesso', name: 'scala-stellar-sdk_2.12', version: '0.4.1'
}

Creating an account on the public test network.

val kp = KeyPair.random
val response = TestNetwork.fund(kp)
Full source at GitHub

Fetching the details of an account.

val account: Future[Account] = network.account(kp).map(_.toAccount)
val nextSeqNo: Future[Long] = account.map(_.sequenceNumber)
Full source at GitHub

Submitting a payment.

for {
  sourceAccount <- network.account(payerKeyPair)
  response <- Transaction(sourceAccount)
    .add(PaymentOperation(payeePublicKey, Amount.lumens(5000)))
    .sign(payerKeyPair)
    .submit()
} yield response
Full source at GitHub

For more detailed coverage, continue by reading about Transacting.

API

Please enjoy the scaladoc for this release.

Deprecation warning

At this stage, classes and interfaces are likely to be refined. Minor releases may break backwards compatibility with minimal notice until v1.0.0.

Contributing

Contributions are warmly welcomed. Please feel free to contribute by reporting issues you find, or by suggesting changes to the code. Or feel free to add your own features/issues to that list.

Let’s chat about any of this on the Stellar-public Slack #dev channel. My username is @jem.