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 provides a more natural API for Scala developers than the official Java SDK

The code throughout this documentation is compiled against Scala 2.13.

Quick-start

Add the jitpack resolver.

resolvers += "jitpack" at "https://jitpack.io"

Then, add the SDK via your dependency management tool.

sbt
libraryDependencies += "io.github.synesso" %% "scala-stellar-sdk" % "0.21.1"
Maven
<dependencies>
  <dependency>
    <groupId>io.github.synesso</groupId>
    <artifactId>scala-stellar-sdk_2.13</artifactId>
    <version>0.21.1</version>
  </dependency>
</dependencies>
Gradle
dependencies {
  implementation "io.github.synesso:scala-stellar-sdk_2.13:0.21.1"
}

Creating an account on the public test network.

sourceval kp = KeyPair.random
val response = TestNetwork.fund(kp)

Fetching the details of an account.

sourceval account: Future[Account] = network.account(kp).map(_.toAccount)
val nextSeqNo: Future[Long] = account.map(_.sequenceNumber)

Submitting a payment.

sourcefor {
  sourceAccount <- network.account(payerKeyPair)
  response <- model.Transaction(sourceAccount, timeBounds = Unbounded, maxFee = NativeAmount(100))
    .add(PaymentOperation(payeePublicKey.toAccountId, lumens(5000)))
    .sign(payerKeyPair)
    .submit()
} yield response

For more detailed coverage, continue by reading about KeyPairs.

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.

Check the CHANGELOG for details of breaking changes.

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.

You can contact me on KeyBase.