November 2021: This project is no longer actively maintained.
With the Stellar SDK for Scala, you can perform Stellar operations from your Scala application. It provides the ability to access Stellar networks via any Horizon instance to build and submit transactions, query the state of the network and stream updates. You'll like this SDK, because it provides a more natural API for Scala developers than the official Java SDK.
You can do what you like with this software, as long as you include the required notices. See the licence for more details.
Add the JitPack & jcenter resolvers and the latest dependency to your build tool. Here's how it might look in build.sbt
resolvers += "jitpack" at "https://jitpack.io"
resolvers += Resolver.jcenterRepo
libraryDependencies += "com.github.synesso" %% "scala-stellar-sdk" % "0.21.1"
From there, it is a simple affair to create and fund a new account on the test network.
import stellar.sdk._
import scala.concurrent.ExecutionContext.Implicits.global
val kp = KeyPair.random
val response = TestNetwork.fund(kp)
You can try this right now in your browser.
Here's the code necessary to fetch an account's sequence number and submit a payment operation to the network.
implicit val network = TestNetwork
for {
sourceAccount <- network.account(payerKeyPair)
response <- model.Transaction(sourceAccount, timeBounds = TimeBounds.Unbounded, maxFee = lumens(100))
.add(PaymentOperation(payeePublicKey, Amount.lumens(5000)))
.sign(payerKeyPair)
.submit()
} yield response
Please see the full SDK documentation for further examples and full API details.
There are a few ways to get help using this SDK.
- Post your question to the Stellar StackExchange and tag it with
scala-sdk
. - Ask in the #dev_discussion channel in Keybase.
- Raise an issue on this repository in GitHub.
If you'd like to contribute new ideas, bug fixes or help to build out a planned feature, please take a look at the current open issues, or join the gitter channel to discuss your thoughts.
To get started developing on the SDK itself, see the DEV notes.
_Thanks to the Stellar Development Foundation for their ongoing support.