Blade SDKs
Last updated
Last updated
Blade offers SDKs for the most popular platforms, making it easy for you to implement our code, whatever your tech stack looks like.
Simplified version of diagram to show how Blade SDKs can be used in your application.
How to install
How to init
How to install
Add the following lines to your Package.swift file:
Or add the following line to your Podfile:
How to init
How to install
Add repositories to your project:
Add dependency to your project:
Add permission to your project:
How to init
How to install
How to init
A: The Blade SDK is a set of tools that allow you to easily integrate Blade's services into your application.
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.
A: There are two most popular problems:
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.
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").
A: In default scenario, you shouldn't specify BladeEnv, in than case Prod will be used
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.
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.
A: You can find examples for almost any of provided SDK. List of SDKs with examples provide above.
A: Feel free to contact us. We are always happy to help you.
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.
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.
✅ - implemented
❌ - not implemented
Inits instance of BladeSDK for correct work with Blade API and Hedera network.
Example
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
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
Clears current user credentials.
Example
Get hbar and token balances for specific account.
Example
Get list of all available coins on CoinGecko.
Example
Get coin price and coin info from CoinGecko. Search can be coin id or address in one of the coin platforms.
Example
Send hbars to specific account.
Example
Call contract function. Directly or via BladeAPI using paymaster account (fee will be paid by Paymaster account), depending on your dApp configuration.
Example
Call query on contract function. Similar to {@link contractCallFunction} can be called directly or via BladeAPI using Paymaster account.
Example
Send token to specific account.
Example
Create scheduled transaction
Example
Sign scheduled transaction
Example
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
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
Delete Hedera account. This method requires account private key and operator private key. Operator is the one who paying fees
Example
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
Get Node list
Example
Stake/unstake account
Example
Example
Get accounts list and keys from private key or mnemonic
Supporting standard and legacy key derivation.
Every key with account will be returned.
Example
Bladelink drop to account
Example
Sign base64-encoded message with private key. Returns hex-encoded signature.
Example
Verify message signature by public key
Example
Sign base64-encoded message with private key using ethers lib. Returns hex-encoded signature.
Example
Split signature to v-r-s format.
Example
Get v-r-s signature of contract function params
Example
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
Get configured url for C14 integration (iframe or popup)
Example
Get quotes from different services for buy, sell or swap
Example
Swap tokens
Example
Get configured url to buy or sell tokens or fiat
Example
Create token (NFT or Fungible Token)
Example
Associate token to account. Association fee will be covered by PayMaster, if tokenId configured in dApp
Example
Mint one NFT
Example
Get token info. Fungible or NFT. Also get NFT metadata if serial provided
Example
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
✅
❌
❌
❌
❌
❌
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)
C++ (beta)