15th Sep 2020
7 min read

ARK’s Platform SDK — Tying It All Together

The ARK’s Platform SDK is the newest addition in our continual effort to expand support to other Coins & Tokens. In this article, we will review its standardization and integration into our upcoming Desktop Wallet 3.0 , and the infrastructure involved in making it seamless.

Platform SDK

The Platform SDK is a collection of TypeScript packages that aim to standardize the common interactions with any blockchain implemented using it (such as signing transactions, listing transactions, registering delegates, signing and verifying messages, voting, staking and more).

Platform SDK is available at https://github.com/ArkEcosystem/platform-sdk

Standardizing these interactions can be challenging since every blockchain project has its own idea of how things should function. One of the largest issues being that the inputs required to sign a transaction or retrieve wallet data vary widely between blockchains. Even after normalization of the inputs, multiple new issues pop up regarding different methods used to sign transactions. Some blockchains use 12 or 24-word mnemonic passphrases, some use private keys, while others use WIF (Wallet Import Format).

The snippet below shows how we defined and normalized the available inputs that can be used to sign transactions for various blockchains:

{
    Identity: {
        address: {
            mnemonic: true,
            multiSignature: true,
            publicKey: true,
            privateKey: true,
            wif: true,
        },
        publicKey: {
            mnemonic: true,
            multiSignature: true,
            wif: true,
        },
        privateKey: {
            mnemonic: true,
            wif: true,
        },
        wif: {
            mnemonic: true,
        },
        keyPair: {
            mnemonic: true,
            privateKey: false,
            wif: true,
        },
    }
}

All of these different inputs mean that normalization of the process is required without drastically altering the user experience. If you are using a coin that signs transactions with a private key, and it is possible to derive that private key from a 12 or 24-word mnemonic passphrase then the SDK will expect you to input the passphrase and it will derive the private key from it. This means that applications that integrate the Platform SDK will be able to provide a seamless user-experience for most coins without having to alter the user-interface.

Some things cannot be standardized due to how they work. Fees, for example, will require a different user-interface for certain blockchains because of how their fees are chosen and calculated. Ethereum for example requires Gas amount and price to be specified while ARK offers you to select a dynamic fee based on network averages. We chose to not reinvent the wheel and follow established conventions as closely as possible to create a familiar user experience for Bitcoin and Ethereum users.

Besides fees, there is also the surprisingly difficult task of finding coins with modern and easily accessible APIs. Bitcoin and Ethereum have vast amounts of data on their blockchain, but accessing it for historical usage can be a chore. Even if you succeed you will often hit performance bottlenecks with something like the Bitcoin JSON-RPC due to its heavily limited performance even with increased concurrent connections.

These challenges with the bigger coins led us to build an accompanying product that would organize the data in a more accessible way, allowing us to avoid major performance bottlenecks that we have experienced by interacting directly with Bitcoin and Ethereum APIs.

Note: Ethereum 2.0 will ship with a more modern REST API but it is yet to be seen if the performance and developer experience is vastly improved. The release date is still unknown as of now.

Platform SDK Server

The Platform SDK Server is the central piece of our infrastructure needed to interact with historical data of larger coins like Bitcoin and Ethereum, all that without experiencing performance bottlenecks or having excessive processing on the user’s machine. The Platform SDK Server consists of the application responsible for indexing and exposing the data through an API and multiple ElasticSearch instances holding full copies of the Bitcoin and Ethereum Blockchain.

Keeping full copies of those blockchains is necessary since they lack modern APIs to access historical data, and their existing tools like their JSON-RPCs experience heavy congestion when opening multiple connections. With ARK, we have access to hundreds of nodes with public APIs making it possible for us to balance the load over multiple nodes. With Bitcoin and Ethereum this is not possible since the APIs have to be manually activated and run separately instead of being an out-of-the-box tool, meaning we can’t expect every node on those blockchains to have an accessible API.

The indexing of new transactions for Bitcoin and Ethereum happens every minute and currently totals somewhere around 4TB and this will only continue to grow. Hopefully, Bitcoin and Ethereum will offer modern APIs to access historical data without having to build custom solutions or rely on community tooling. Access to all blockchain information shouldn’t be a chore for developers. It should be as simple as possible if you already have a full copy of the blockchain on your synced node.

Networking & Security

The Platform SDK Server is responsible for the network communication with Bitcoin and Ethereum but what about others? All other coins we plan to support in the foreseeable future provide relatively modern APIs or hosted solutions of their own, allowing access to historical blockchain data. This means we can leverage their existing ecosystem without much effort on our end and rely on their tooling.

All transactions done via Platform SDK and Desktop Wallet will be signed offline which will ensure that no personally identifiable information like a passphrase is sent or intercepted by potentially malicious actors.

The benefit of relying on existing infrastructure is automatic updating in a timely manner. With Bitcoin and Ethereum we will have to maintain our own infrastructure to provide a smooth user experience. All nodes that are used for network communication are either official nodes of the blockchain you are using or officially hosted solutions by ARK, like our Platform SDK Server, which ensures you are using trusted and secure connections without having to download copies of blockchains before using them.

In the example below you can see how we define and normalize network-specific data:

{
    networks: {
        mainnet: {
            id: "mainnet",
            type: "live",
            name: "Mainnet",
            explorer: "https://explorer.ark.io/",
            currency: {
                ticker: "ARK",
                symbol: "Ѧ",
            },
            crypto: {
                slip44: 111,
            },
            hosts: ["https://wallets.ark.io"],
            hostsMultiSignature: [],
            voting: {
                enabled: true,
                maximum: 1,
                maximumPerTransaction: 1,
            },
        },
        devnet: {
            id: "devnet",
            type: "test",
            name: "Devnet",
            explorer: "https://dexplorer.ark.io/",
            currency: {
                ticker: "DARK",
                symbol: "DѦ",
            },
            crypto: {
                slip44: 111,
            },
            hosts: ["https://dwallets.ark.io"],
            hostsMultiSignature: [],
            voting: {
                enabled: true,
                maximum: 1,
                maximumPerTransaction: 1,
            },
        },
    }
}

All-in-all our goal is to make networking with blockchains as seamless and secure as possible with minimal input from developers and users to provide an enjoyable experience for everyone.

Desktop Wallet Integration

The initial development of the Platform SDK is driven by the upcoming Desktop Wallet 3.0 that will be released soon for beta testing. The Desktop Wallet is the primary product that most people using ARK will interact with. This interaction ultimately drives how things are implemented and eventually consumed by you, the everyday user.

The architecture of the 2.0 and 3.0 Desktop Wallet is vastly different since interaction with multiple coins is needed as opposed to only ARK-based blockchains. Achieving this might sound difficult, but the concept and design of the Platform SDK make it easier than you would think.

Let’s take a look at a code sample to get a better idea of how the Platform SDK works when integrated into a real-world product like a wallet.

import { ARK } from "@arkecosystem/platform-sdk-ark";
import { LSK } from "@arkecosystem/platform-sdk-lsk";new Environment({ coins: { ARK, LSK }, httpClient, storage });

Because the Platform SDK is intended to be plug and play, it is very easy to integrate new coins into the Desktop Wallet. Simply implement your new coin (while respecting the Platform SDK implementation contracts to ensure consistent behavior), install it into the Desktop Wallet and rebuild it. We are looking into supporting new coins through plugins so you can completely customize your wallet with other coins besides ARK.

What coin/token additions do you want to see first in the upcoming Platform SDK and Desktop Wallet releases? Please let us know on social channels!

Conclusion

The Platform SDK is a first step in supporting multiple networks and a way to standardize blockchain. We hope that by building these tools, developers from other blockchain companies and communities will see the benefit of a more standardized and modern approach for building apps that could streamline and expedite the development of exciting new products and services built on top of decentralized solutions.

Share:

Get in Touch!

Whether you want to learn more about ARK Ecosystem, want to apply for developer bounty, become our partner or just want to say Hello, get in touch and we will get back to you.



An Ecosystem of Developers

Join us on our journey to create the future of Web3.