Xpring SDK

Xpring is a solution for developers who want straightforward access to the capabilities of the XRP Ledger, regardless of their knowledge of, or comfort with, cryptography and distributed systems. You can build apps using your preferred language. With Xpring, your app can be used to transact value around the world, regardless of payment size, borders, or the platform you use to build your app.

Xpring SDK delivers the most common features of the XRP ecosystem in an easy to use package. Xpring SDK is the foundation for the Xpring developer site and will also power future Xpring services.

When you use Xpring SDK together with the XRP Ledger protocols, you can:

  • Check an account balance
  • Make XRP payments
  • Determine transaction status
  • Generate or derive a wallet, whether seed-based or hierarchically deterministic
  • Validate an address
  • Obtain payment history

When you use Xpring SDK together with Interledger protocols, you can:

  • Send payments
  • Check account balance

Xpring SDK supports these capabilities across the following languages:

All of these features use a common code base, which ensures that Xpring delivers features across all supported languages simultaneously. In practice, this means that an iOS engineer who is integrating Xpring SDK into their app can explain how to use the APIs to their peer Android engineer.

Architecture

Xpring SDK achieves cross-platform consistency with pragmatic code reuse. At a high level, you can break most multi-platform SDKs, including Xpring SDK, into three components:

  • Networking and Remote Procedure Calls (RPCs)
  • Common core functionality
  • A public API that connects these features together in an idiomatic API

Networking

Any client-side library needs a reliable way to communicate with a remote service. In the case of Xpring SDK, a client-side library connects to a remote XRP Ledger node which serves data about the state of the XRP Ledger across the distributed system.

Without Xpring SDK, each XRP Ledger server uses a JSON API to communicate and interact with the node. This API has no preconfigured bindings in any language, requiring developers of client libraries to interact with the node by hand-rolling their own untyped JSON objects in their language of choice.

Xpring uses gRPC, which is a cross-platform technology used to define an API using a lightweight markup language. The markup language is then “compiled” to generate code in a number of native languages. The generated code builds request and response objects for the client which are type-safe and human-readable. gRPC also provides built-in connection management and error handling, and gRPC uses an on-wire format that outperforms JSON in both serialization time and payload size.

With gRPC in the Xpring technology stack, the Xpring team writes code once in order to generate a networking API layer that behaves consistently in every language supported across the Xpring stack. To a rippled server for use with gRPC, refer to Configure gRPC .

Common core functionality

The XRP ecosystem has some common use cases which use a common core of logic. Some examples include:

  • Address derivation and validation
  • Serializing transactions to a binary format
  • Base58 Check Encoding

These sorts of functions are not easy to write or maintain, and now you can outsource this work to the Xpring SDK.

Xpring SDK consumes a common JavaScript core by binding it to the host language and calling into it for core functionality. This common core is not exposed to users of the public API, which minimizes the chances of incorrect use of JavaScript’s type system. Similarly, having just a small number of call sites minimizes the performance impact of the JavaScript virtual machine. Keeping a common core in JavaScript provides the optimal trade off among the benefits of code reuse, performance and a high level of type safety.

Take a look at the common core library in Xpring SDK.

"Glue" code

Xpring SDK binds a common set of core functions and a generated network layer together.

Because the public API is written natively, it provides an idiomatic design in whatever language the SDK is being written in. For example, a JavaScript developer typically expects asynchronous code to use promises, while a Swift developer likely expects a closure completion handler. The Xpring code-sharing patterns allow both of these programmers to write code in the way they’d expect, while still sharing the majority of functionality with each other.

On the importance of modularity

Xpring SDK is built with modularity in mind. Thus, unsupported platforms have a baseline level of support, and third-party developers can make make meaningful contributions to the XRP ecosystem by wrapping up Xpring's open source components.

For example, a developer might be interested in using Python to integrate the XRP Ledger with their exchange. When provided with a gRPC representation of the network interface, this developer can immediately gain access to any network calls they'd like to use. This developer can then wrap up the core library and leverage Xpring SDK's existing code.

With modularity, it’s easy to swap out components and future-proof the Xpring platform. If the Xpring team changes the language that the core code is written in, that will not affect the public API. If the Xpring team decided to use a different networking technology than gRPC, again this change would not affect the public API.

Towards the future

With the architecture described, the cost for Xpring or any external developer to add an additional platform to our SDK is relatively low. To support a new language or platform, you can invoke a program to generate the necessary gRPC networking code, create a lightweight set of bindings between JavaScript and your language of choice, and write an idiomatic public API to connect the two. Similarly, adding an additional feature across platforms is easier and cheaper because of the level of code reuse.

The Xpring team is planning to support more features of the XRP Ledger, to increase the number of languages covered by Xpring SDK, and to cover additional services like cross-currency payments and the digital identity system that the Interledger Protocol provides.