Blade SDKs

Intro

Blade offers SDKs for the most popular platforms, making it easy for you to implement our code, whatever your tech stack looks like.

JS

for browser-based apps

Swift

for native iOS apps

Kotlin

for native Android app

React Native

for React Native apps (supporting React Native Bare)

Unity (beta)

Unity based desktop apps (Windows, MacOS, Linux)

High-level SDK usage diagram

Simplified version of diagram to show how Blade SDKs can be used in your application.

Diagram

Quick start

JS

How to install

How to init

Swift

How to install

Add the following lines to your Package.swift file:

Or add the following line to your Podfile:

How to init

Kotlin

How to install

  1. Add repositories to your project:

  1. Add dependency to your project:

  1. Add permission to your project:

How to init

React Native

How to install

How to init

FAQ

Q: What is the Blade SDK?

A: The Blade SDK is a set of tools that allow you to easily integrate Blade's services into your application.

Q: What can I do with the Blade SDK?

A: You can use BladeSDK in your app smooth integration with the Blade services, partner services, interact Hedera hashgraph network and more. Check features list below.

Q: I have problems with initialisation, what should I do?

A: There are two most popular problems:

  1. Check your API key, dAppCode, network and environment. They should be correct. Worth to mention that apiKey may be different per network (testnet, mainnet) and platform (JS, Swift, Kotlin, React Native, etc.). Use credentials provided by BladeLabs team.

  2. Issues with getting visitorId. This problem may occur if region restrictions are applied. Sometimes it may be related Ad-blockers, so please disable them and try again. If the problem persists, please contact BladeLabs team.

In these cases please call method getInfo() and check if visitorId is not empty. Also, it will be useful if you provide us result of this method call when contacting support. Keep in mind that output may contain sensitive data, like apiKey, so please be careful with sharing this information (you can send it partially, like this "FG9dU...PcSAt").

Q: What is BladeEnv / SdkEnvironment?

A: In default scenario, you shouldn't specify BladeEnv, in than case Prod will be used

Q: What is dAppCode?

A: dAppCode is a unique identifier for your application. It is used to identify your application in Blade's system. This code is provided by BladeLabs team.

Q: Is it secure to provide private key to SDK methods

A: BladeSDK never share Private keys in any form. It is used only for signing transactions and never leaves the device. It's your responsibility to keep it safe. Please check best practices for storing private keys in your application. Also, treat apiKey as a sensitive data and never share it with anyone.

Q: Where I can find examples?

A: You can find examples for almost any of provided SDK. List of SDKs with examples provide above.

Q: Still have questions?

A: Feel free to contact us. We are always happy to help you.

Disclaimer

Please note that the security of your private keys is your sole responsibility.

Our SDKs, which wraps Hedera SDK and Blade wallet API, have been developed to ensure the highest level of security possible.

However, we do not take any responsibility for the security of your private keys.

Please be aware that once someone else gains access to your private keys, they will have full control of your account, funds, tokens, and NFTs.

We strongly recommend that you follow best practices for securing your private keys when using our SDKs. Please be aware that private keys will never be sent over the network or shared with any third party through our SDK.

Best practices for securing your private keys

Here are some examples of secure storage options for hex-encoded private keys for iOS, Android, and JavaScript:

iOS:

Keychain: iOS provides a secure Keychain service that allows you to store sensitive information, such as private keys, securely. You can use the Keychain API provided by Apple to store and retrieve private keys in a secure manner.

Encrypted file: You can store the private key in an encrypted file and save it to the device's file system. The file can be decrypted when needed using a password or passphrase.

Android:

Android Keystore: Android provides a secure hardware-backed Keystore service that allows you to store cryptographic keys securely. You can use the Android Keystore API provided by Google to store and retrieve private keys in a secure manner.

Encrypted file: Similar to iOS, you can store the private key in an encrypted file and save it to the device's file system. The file can be decrypted when needed using a password or passphrase.

JavaScript:

Browser local storage: You can store an encrypted private key in the browser's local storage, which provides a simple way to store data on the user's device. However, this is not the most secure option as the data can be accessed by other scripts running on the same page.

Encrypted cookie: You can store the private key in an encrypted cookie on the user's device. The cookie can be decrypted when needed using a password or passphrase. However, this is not the most secure option as cookies can be accessed by other scripts running on the same page.

It's important to note that these are just a few examples, and there may be other secure storage options available depending on your specific use case and requirements. It's recommended to consult with a security expert to determine the most appropriate storage solution for your needs.

Supported features across SDKs

Supported features
JS
Swift
Kotlin
React Native
Unity
C++

init

getInfo

setUser

resetUser

getBalance

getCoinList

getCoinPrice

transferHbars

contractCallFunction

contractCallQueryFunction

transferTokens

createScheduleTransaction

signScheduleId

createAccount

getPendingAccount

deleteAccount

getAccountInfo

getNodeList

stakeToNode

getKeysFromMnemonic

searchAccounts

dropTokens

sign

signVerify

ethersSign

splitSignature

getParamsSignature

getTransactions

getC14url

exchangeGetQuotes

swapTokens

getTradeUrl

createToken

associateToken

nftMint

getTokenInfo

  • ✅ - implemented

  • ❌ - not implemented

Features

init

Inits instance of BladeSDK for correct work with Blade API and Hedera network.

Example

getInfo

This method returns basic params of initialized instance of BladeSDK. This params may useful for support.

Returned object likely will contain next fields: apiKey, dAppCode, network, visitorId, sdkEnvironment, sdkVersion, nonce

In case of support please not provide full apiKey, limit yourself to the part of the code that includes a few characters at the beginning and at the end (eg. AdR3....BFgd)

Example

setUser

Set account for further operations.

Currently supported two account providers: Hedera and Magic.

Hedera: pass accountId and privateKey as hex-encoded strings with DER-prefix (302e020100300506032b657004220420...)

Magic: pass email to accountIdOrEmail and empty string as privateKey. SDK will handle Magic authentication, and finish after user click on confirmation link in email.

After successful authentication, SDK will store public and private keys in memory and use them for further operations.

After that in each method call provide empty strings to accountId and accountPrivateKey. Otherwise, SDK will override current user with provided credentials as Hedera provider.

In case of calling method with accountId and accountPrivateKey arguments, SDK will override current user with this credentials.

It's optional method, you can pass accountId and accountPrivateKey in each method call. In further releases this method will be mandatory.

Example

resetUser

Clears current user credentials.

Example

getBalance

Get hbar and token balances for specific account.

Example

getCoinList

Get list of all available coins on CoinGecko.

Example

getCoinPrice

Get coin price and coin info from CoinGecko. Search can be coin id or address in one of the coin platforms.

Example

transferHbars

Send hbars to specific account.

Example

contractCallFunction

Call contract function. Directly or via BladeAPI using paymaster account (fee will be paid by Paymaster account), depending on your dApp configuration.

Example

contractCallQueryFunction

Call query on contract function. Similar to {@link contractCallFunction} can be called directly or via BladeAPI using Paymaster account.

Example

transferTokens

Send token to specific account.

Example

createScheduleTransaction

Create scheduled transaction

Example

signScheduleId

Sign scheduled transaction

Example

createAccount

Create new Hedera account (ECDSA). Only for configured dApps. Depending on dApp config Blade create account, associate tokens, etc.

In case of not using pre-created accounts pool and network high load, this method can return transactionId and no accountId.

In that case account creation added to queue, and you should wait some time and call getPendingAccount() method.

Example

getPendingAccount

Get account from queue (read more at createAccount()).

If account already created, return account data.

If account not created yet, response will be same as in createAccount() method if account in queue.

Example

deleteAccount

Delete Hedera account. This method requires account private key and operator private key. Operator is the one who paying fees

Example

getAccountInfo

Get account info.

EvmAddress is address of Hedera account if exists. Else accountId will be converted to solidity address.

CalculatedEvmAddress is calculated from account public key. May be different from evmAddress.

Example

getNodeList

Get Node list

Example

stakeToNode

Stake/unstake account

Example

getKeysFromMnemonic

Example

searchAccounts

Get accounts list and keys from private key or mnemonic

Supporting standard and legacy key derivation.

Every key with account will be returned.

Example

dropTokens

Bladelink drop to account

Example

sign

Sign base64-encoded message with private key. Returns hex-encoded signature.

Example

signVerify

Verify message signature by public key

Example

ethersSign

Sign base64-encoded message with private key using ethers lib. Returns hex-encoded signature.

Example

splitSignature

Split signature to v-r-s format.

Example

getParamsSignature

Get v-r-s signature of contract function params

Example

getTransactions

Get transactions history for account. Can be filtered by transaction type.

Transaction requested from mirror node. Every transaction requested for child transactions. Result are flattened.

If transaction type is not provided, all transactions will be returned.

If transaction type is CRYPTOTRANSFERTOKEN records will additionally contain plainData field with decoded data.

Example

getC14url

Get configured url for C14 integration (iframe or popup)

Example

exchangeGetQuotes

Get quotes from different services for buy, sell or swap

Example

swapTokens

Swap tokens

Example

getTradeUrl

Get configured url to buy or sell tokens or fiat

Example

createToken

Create token (NFT or Fungible Token)

Example

associateToken

Associate token to account. Association fee will be covered by PayMaster, if tokenId configured in dApp

Example

nftMint

Mint one NFT

Example

getTokenInfo

Get token info. Fungible or NFT. Also get NFT metadata if serial provided

Example

Last updated