Skip to main content

Contents

Methods

initialize​

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

initialize (apiKey: String, dAppCode: String, network: String, bladeEnv: BladeEnv = BladeEnv.Prod, context: Context, force: Boolean = false, completion: (InfoData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
apiKeyStringUnique key for API provided by Blade team.
dAppCodeStringyour dAppCode - request specific one by contacting Bladelabs team
networkString"Mainnet" or "Testnet" of Hedera network
bladeEnvBladeEnvfield to set BladeAPI environment (Prod, CI). Prod used by default.
contextContextandroid context
forceBooleanoptional field to force init. Will not crash if already initialized
completion(InfoData?,BladeJSError?)->Unitcallback function, with result of InfoData or BladeJSError

Returns​

InfoData - with information about Blade instance, including visitorId

Example​

Blade.initialize(
Config.apiKey, Config.dAppCode, Config.network, Config.bladeEnv, requireContext(), false
) { infoData, error ->
println(infoData ?: error)
}

getInfo​

Get SDK info and check if SDK initialized

getInfo (completion: (InfoData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
completion(InfoData?,BladeJSError?)->Unitcallback function, with result of InfoData or BladeJSError

Returns​

InfoData - with information about Blade instance, including visitorId

Example​

Blade.getInfo { infoData, error ->
println(infoData ?: error)
}

getBalance​

Get balances by account id.

getBalance (id: String, completion: (BalanceData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
idStringHedera account id
completion(BalanceData?,BladeJSError?)->Unitcallback function, with result of BalanceData or BladeJSError

Returns​

BalanceData - with information about Hedera account balances (hbar and list of token balances)

Example​

Blade.getBalance("0.0.45467464") { result, error ->
println("${ result ?: error}")
}

getCoinList​

Get list of all available coins on CoinGecko.

getCoinList (completion: (CoinListData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
completion(CoinListData?,BladeJSError?)->Unitcallback function, with result of CoinListData or BladeJSError

Returns​

CoinListData - with list of coins described by name, alias, platforms

Example​

Blade.getCoinList { result, error ->
if (result != null) {
for (coin in result.coins) {
println(coin)
}
} else {
println(error)
}
}

getCoinPrice​

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

  • In addition to the price in USD, the price in the currency you specified is returned

getCoinPrice (search: String, currency: String = "usd", completion: (CoinInfoData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
searchStringCoinGecko coinId, or address in one of the coin platforms or hbar (default, alias for hedera-hashgraph)
currencyStringresult currency for price field
completion(CoinInfoData?,BladeJSError?)->Unitcallback function, with result of CoinListData or BladeJSError

Returns​

{CoinInfoData}

Example​

Blade.getCoinPrice(
search = "hbar",
currency = "uah"
) { result, bladeJSError ->
println("${result ?: bladeJSError}")
}

transferHbars​

Method to execute Hbar transfers from current account to receiver

transferHbars (accountId: String, accountPrivateKey: String, receiverId: String, amount: Double, memo: String, completion: (TransactionReceiptData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
accountIdStringsender account id
accountPrivateKeyStringsender's private key to sign transfer transaction
receiverIdStringreceiver
amountDoubleamount
memoStringmemo (limited to 100 characters)
completion(TransactionReceiptData?,BladeJSError?)->Unitcallback function, with result of TransactionReceiptData or BladeJSError

Returns​

TransactionReceiptData - receipt

Example​

val senderId = "0.0.10001"
val senderKey = "302d300706052b8104000a032200029dc73991b0d9cd..."
val receiverId = "0.0.10002"
val amount = 2.5
Blade.transferHbars(
senderId,
senderKey,
receiverId,
amount,
"Some memo text"
) { result, error ->
println(result ?: error)
}

transferTokens​

Method to execute token transfers from current account to receiver

transferTokens (tokenId: String, accountId: String, accountPrivateKey: String, receiverId: String, amountOrSerial: Double, memo: String, usePaymaster: Boolean = true, completion: (TransactionReceiptData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
tokenIdStringtoken id to send (0.0.xxxxx)
accountIdStringsender account id (0.0.xxxxx)
accountPrivateKeyStringsender's hex-encoded private key with DER-header (302e020100300506032b657004220420...). ECDSA or Ed25519
receiverIdStringreceiver account id (0.0.xxxxx)
amountOrSerialDoubleamount of fungible tokens to send (with token-decimals correction) on NFT serial number
memoStringtransaction memo (limited to 100 characters)
usePaymasterBooleanif true, Paymaster account will pay fee transaction. Only for single dApp configured fungible-token. In that case tokenId not used
completion(TransactionReceiptData?,BladeJSError?)->Unitcallback function, with result of TransactionReceiptData or BladeJSError

Returns​

TransactionReceiptData - receipt

Example​

val tokenId = "0.0.1337"
val senderId = "0.0.10001"
val senderKey = "302d300706052b8104000a032200029dc73991b0d9cd..."
val receiverId = "0.0.10002"
val amount = 2.5
Blade.transferTokens(
tokenId,
senderId,
senderKey,
receiverId,
amount,
"Token transfer memo"
) { result, error ->
println(result ?: error)
}

createScheduleTransaction​

Create scheduled transaction

createScheduleTransaction ( accountId: String, accountPrivateKey: String, type: ScheduleTransactionType, transfers: List<ScheduleTransactionTransfer>, usePaymaster: Boolean = false, completion: (CreateScheduleData?, BladeJSError?) -> Unit )

Parameters​

NameTypeDescription
accountIdStringaccount id (0.0.xxxxx)
accountPrivateKeyStringaccount key (hex encoded privateKey with DER-prefix)
typeScheduleTransactionTypeschedule transaction type (currently only TRANSFER supported)
transfersList<ScheduleTransactionTransfer>array of transfers to schedule (HBAR, FT, NFT)
usePaymasterBooleanif true, Paymaster account will pay transaction fee (also dApp had to be configured for free schedules)
completion(CreateScheduleData?,BladeJSError?)->Unitcallback function, with result of CreateScheduleData or BladeJSError

Returns​

CreateScheduleData - scheduleId

Example​

val receiverId = "0.0.10002"
val receiverKey = "302d300706052b8104000a032200029dc73991b00002..."
val senderId = "0.0.10001"
val tokenId = "0.0.1337"
var scheduleId = ""
Blade.createScheduleTransaction(
accountId = receiverId,
accountPrivateKey = receiverKey,
type = ScheduleTransactionType.TRANSFER,
transfers = listOf(
ScheduleTransactionTransferHbar(sender = senderId, receiver = receiverId, 10000000),
ScheduleTransactionTransferToken(sender = senderId, receiver = receiverId, tokenId = tokenId, value = 3)
),
usePaymaster = true,
) { result, error ->
if (result != null) {
println(result.scheduleId)
}
}

signScheduleId​

Method to sign scheduled transaction

signScheduleId ( scheduleId: String, accountId: String, accountPrivateKey: String, receiverAccountId: String = "", usePaymaster: Boolean = false, completion: (TransactionReceiptData?, BladeJSError?) -> Unit )

Parameters​

NameTypeDescription
scheduleIdStringscheduled transaction id (0.0.xxxxx)
accountIdStringaccount id (0.0.xxxxx)
accountPrivateKeyStringaccount key (hex encoded privateKey with DER-prefix)
receiverAccountIdStringaccount id of receiver for additional validation in case of dApp freeSchedule transactions configured
usePaymasterBooleanif true, Paymaster account will pay transaction fee (also dApp had to be configured for free schedules)
completion(TransactionReceiptData?,BladeJSError?)->Unitcallback function, with result of TransactionReceiptData or BladeJSError

Returns​

TransactionReceiptData - receipt

Example​

val senderId = "0.0.10001"
val senderKey = "302d300706052b8104000a032200029dc73991b00001..."
val receiverId = "0.0.10002"
var scheduleId = "0.0...." // result of createScheduleTransaction on receiver side
Blade.signScheduleId(
scheduleId = scheduleId,
accountId = senderId,
accountPrivateKey = senderKey,
receiverAccountId = receiverId,
usePaymaster = true
) { result, bladeJSError ->
println(result ?: bladeJSError)
}

createHederaAccount​

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.

createHederaAccount (privateKey: String = "", deviceId: String = "", completion: (CreatedAccountData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
privateKeyStringoptional field if you need specify account key (hex encoded privateKey with DER-prefix)
deviceIdStringoptional field unique device id (advanced security feature, required only for some dApps)
completion(CreatedAccountData?,BladeJSError?)->Unitcallback function, with result of CreatedAccountData or BladeJSError

Returns​

CreatedAccountData - new account data, including private key and account id

Example​

Blade.createHederaAccount() { result, error ->
println(result ?: error)
}

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.

getPendingAccount (transactionId: String, seedPhrase: String, completion: (CreatedAccountData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
transactionIdStringcan be received on createHederaAccount method, when busy network is busy, and account creation added to queue
seedPhraseStringreturned from createHederaAccount method, required for updating keys and proper response
completion(CreatedAccountData?,BladeJSError?)->Unitcallback function, with result of CreatedAccountData or BladeJSError

Returns​

CreatedAccountData - new account data

deleteHederaAccount​

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

deleteHederaAccount (deleteAccountId: String, deletePrivateKey: String, transferAccountId: String, operatorAccountId: String, operatorPrivateKey: String, completion: (TransactionReceiptData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
deleteAccountIdStringaccount id of account to delete (0.0.xxxxx)
deletePrivateKeyStringaccount private key (DER encoded hex string)
transferAccountIdStringThe ID of the account to transfer the remaining funds to.
operatorAccountIdStringoperator account id (0.0.xxxxx). Used for fee
operatorPrivateKeyStringoperator's account private key (DER encoded hex string)
completion(TransactionReceiptData?,BladeJSError?)->Unitcallback function, with result of TransactionReceiptData or BladeJSError

Returns​

TransactionReceiptData - receipt

Example​

val deleteAccountId = "0.0.65468464"
val deletePrivateKey = "3030020100300706052b8104000a04220420ebc..."
val transferAccountId = "0.0.10001"
val operatorAccountId = "0.0.10002"
val operatorPrivateKey = "302d300706052b8104000a032200029dc73991b0d9cd..."
Blade.deleteHederaAccount(
deleteAccountId,
deletePrivateKey,
transferAccountId,
operatorAccountId,
operatorPrivateKey,
) { result, error ->
println(result ?: error)
}

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.

getAccountInfo (accountId: String, completion: (AccountInfoData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
accountIdStringHedera account id (0.0.xxxxx)
completion(AccountInfoData?,BladeJSError?)->Unitcallback function, with result of AccountInfoData or BladeJSError

Returns​

{AccountInfoData}

Example​

Blade.getAccountInfo("0.0.10002") { accountInfoData, error ->
println(accountInfoData ?: error)
}

getNodeList​

Get Node list and use it for choosing account stacking node

getNodeList (completion: (NodesData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
completion(NodesData?,BladeJSError?)->Unitcallback function, with result of NodesData or BladeJSError

Returns​

NodesData - node list

Example​

Blade.getNodeList { nodeListData, error ->
println(nodeListData ?: error)
}

stakeToNode​

Stake/unstake account

stakeToNode (accountId: String, accountPrivateKey: String, nodeId: Int, completion: (TransactionReceiptData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
accountIdStringHedera account id (0.0.xxxxx)
accountPrivateKeyStringaccount private key (DER encoded hex string)
nodeIdIntnode id to stake to. If negative or null, account will be unstaked
completion(TransactionReceiptData?,BladeJSError?)->Unitcallback function, with result of TransactionReceiptData or BladeJSError

Returns​

TransactionReceiptData - receipt

Example​

Blade.stakeToNode("0.0.10002", "302d300706052b8104000a032200029dc73991b0d9cd...", 5) { result, error ->
println(result ?: error)
}

getKeysFromMnemonic​

Get private key and accountId from mnemonic. Supported standard and legacy key derivation.

  • If account not found, standard ECDSA key will be returned.

  • Keys returned with DER header. EvmAddress computed from Public key.

getKeysFromMnemonic (mnemonic: String, lookupNames: Boolean = false, completion: (PrivateKeyData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
mnemonicStringseed phrase (BIP39 mnemonic)
lookupNamesBooleanlookup for accounts (not used anymore, account search is mandatory)
completion(PrivateKeyData?,BladeJSError?)->Unitcallback function, with result of PrivateKeyData or BladeJSError

Returns​

PrivateKeyData - private key derived from mnemonic and account id

Example​

Blade.getKeysFromMnemonic("purity slab doctor swamp tackle rebuild summer bean craft toddler blouse switch") { result, error ->
println(result ?: error)
}

searchAccounts​

Get accounts list and keys from private key or mnemonic

  • Supporting standard and legacy key derivation.

  • Every key with account will be returned.

searchAccounts (keyOrMnemonic: String, completion: (AccountPrivateData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
keyOrMnemonicStringBIP39 mnemonic, private key with DER header
completion(AccountPrivateData?,BladeJSError?)->Unitcallback function, with result of AccountPrivateData or BladeJSError

Returns​

AccountPrivateData - list of found accounts with private keys

Example​

Blade.searchAccounts("purity slab doctor swamp tackle rebuild summer bean craft toddler blouse switch") { result, error ->
println(result ?: error)
}

dropTokens​

Bladelink drop to account

dropTokens (accountId: String, accountPrivateKey: String, secretNonce: String, completion: (TokenDropData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
accountIdStringHedera account id (0.0.xxxxx)
accountPrivateKeyStringaccount private key (DER encoded hex string)
secretNonceStringconfigured for dApp. Should be kept in secret
completion(TokenDropData?,BladeJSError?)->Unitcallback function, with result of TokenDropData or BladeJSError

Returns​

TokenDropData - status

Example​

val accountId = "0.0.10002"
val accountPrivateKey = "302d300706052b8104000a032200029dc73991b0d9cd..."
val secretNonce = "[ CENSORED ]"
Blade.dropTokens(
accountId,
accountPrivateKey,
secretNonce,
) { result, error ->
println(result ?: error)
}

sign​

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

sign (messageString: String, privateKey: String, completion: (SignMessageData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
messageStringStringbase64-encoded message to sign
privateKeyStringhex-encoded private key with DER header
completion(SignMessageData?,BladeJSError?)->Unitcallback function, with result of SignMessageData or BladeJSError

Returns​

SignMessageData - signature

Example​

import java.util.Base64
// ...
val originalString = "hello"
val encodedString: String = Base64.getEncoder().encodeToString(originalString.toByteArray())
val accountPrivateKey = "302d300706052b8104000a032200029dc73991b0d9cd..."
Blade.sign(
encodedString,
accountPrivateKey
) { result, error ->
println(result ?: error)
}

signVerify​

Verify message signature with public key

signVerify (messageString: String, signature: String, publicKey: String, completion: (SignVerifyMessageData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
messageStringStringbase64-encoded message (same as provided to sign() method)
signatureStringhex-encoded signature (result from sign() method)
publicKeyStringhex-encoded public key with DER header
completion(SignVerifyMessageData?,BladeJSError?)->Unitcallback function, with result of SignVerifyMessageData or BladeJSError

Returns​

SignVerifyMessageData - verification result

Example​

val originalString = "hello"
val encodedString: String = Base64.getEncoder().encodeToString(originalString.toByteArray())
val signature = "27cb9d51434cf1e76d7ac515b19442c619f641e6fccddbf4a3756b14466becb6992dc1d2a82268018147141fc8d66ff9ade43b7f78c176d070a66372d655f942"
val publicKey = "302d300706052b8104000a032200029dc73991b0d9cdbb59b2cd0a97a0eaff6de801726cb39804ea9461df6be2dd30"
Blade.signVerify(
encodedString,
signature,
publicKey
) { result, error ->
lifecycleScope.launch {
println(result ?: error)
}
}

contractCallFunction​

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

contractCallFunction (contractId: String, functionName: String, params: ContractFunctionParameters, accountId: String, accountPrivateKey: String, gas: Int = 100000, usePaymaster: Boolean, completion: (TransactionReceiptData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
contractIdStringcontract id (0.0.xxxxx)
functionNameStringname of the contract function to call
paramsContractFunctionParametersfunction argument. Can be generated with
accountIdStringoperator account id (0.0.xxxxx)
accountPrivateKeyStringoperator's hex-encoded private key with DER-header, ECDSA or Ed25519
gasIntgas limit for the transaction
usePaymasterBooleanif true, fee will be paid by Paymaster account (note: msg.sender inside the contract will be Paymaster account)
completion(TransactionReceiptData?,BladeJSError?)->Unitcallback function, with result of TransactionReceiptData or BladeJSError

Returns​

TransactionReceiptData - receipt

Example​

val contractId = "0.0.123456"
val functionName = "set_message"
val parameters = ContractFunctionParameters().addString("hello")
val accountId = "0.0.10002"
val accountPrivateKey = "302d300706052b8104000a032200029dc73991b0d9cd..."
val gas = 155000
val usePaymaster = false
Blade.contractCallFunction(
contractId,
functionName,
parameters,
accountId,
accountPrivateKey,
gas,
usePaymaster
) { result, error ->
println(result ?: error)
}

contractCallQueryFunction​

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

contractCallQueryFunction (contractId: String, functionName: String, params: ContractFunctionParameters, accountId: String, accountPrivateKey: String, gas: Int = 100000, usePaymaster: Boolean, returnTypes: List<String>, completion: (ContractQueryData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
contractIdStringcontract id (0.0.xxxxx)
functionNameStringname of the contract function to call
paramsContractFunctionParametersfunction argument. Can be generated with
accountIdStringoperator account id (0.0.xxxxx)
accountPrivateKeyStringoperator's hex-encoded private key with DER-header, ECDSA or Ed25519
gasIntgas limit for the transaction
usePaymasterBooleanif true, the fee will be paid by paymaster account (note: msg.sender inside the contract will be Paymaster account)
returnTypesList<String>List of return types, e.g. listOf("string", "int32")
completion(ContractQueryData?,BladeJSError?)->Unitcallback function, with result of ContractQueryData or BladeJSError

Returns​

ContractQueryData - contract query call result

Example​

val contractId = "0.0.123456"
val functionName = "get_message"
val parameters = ContractFunctionParameters()
val accountId = "0.0.10002"
val accountPrivateKey = "302d300706052b8104000a032200029dc73991b0d9cd..."
val gas = 55000
val usePaymaster = false
val returnTypes = listOf("string", "int32")
Blade.contractCallQueryFunction(
contractId,
functionName,
parameters,
accountId,
accountPrivateKey,
gas,
usePaymaster,
returnTypes
) { result, error ->
lifecycleScope.launch {
println(result ?: error)
}
}

ethersSign​

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

ethersSign (messageString: String, privateKey: String, completion: (SignMessageData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
messageStringStringbase64-encoded message to sign
privateKeyStringhex-encoded private key with DER header
completion(SignMessageData?,BladeJSError?)->Unitcallback function, with result of SignMessageData or BladeJSError

Returns​

SignMessageData - signature

Example​

import java.util.Base64
// ...
val originalString = "hello"
val encodedString: String = Base64.getEncoder().encodeToString(originalString.toByteArray())
val accountPrivateKey = "302d300706052b8104000a032200029dc73991b0d9cd..."
Blade.ethersSign(
encodedString,
accountPrivateKey
) { result, error ->
println(result ?: error)
}

splitSignature​

Split signature to v-r-s format.

splitSignature (signature: String, completion: (SplitSignatureData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
signatureStringhex-encoded signature
completion(SplitSignatureData?,BladeJSError?)->Unitcallback function, with result of SplitSignatureData or BladeJSError

Returns​

SplitSignatureData - v-r-s signature

Example​

Blade.splitSignature(
"0x27cb9d51434cf1e76d7ac515b19442c619f641e6fccddbf4a3756b14466becb6992dc1d2a82268018147141fc8d66ff9ade43b7f78c176d070a66372d655f942",
) { result, error ->
println(result ?: error)
}

getParamsSignature​

Get v-r-s signature of contract function params

getParamsSignature (params: ContractFunctionParameters, accountPrivateKey: String, completion: (SplitSignatureData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
paramsContractFunctionParametersdata to sign. (instance of ContractFunctionParameters)
accountPrivateKeyStringsigner private key (hex-encoded with DER header)
completion(SplitSignatureData?,BladeJSError?)->Unitcallback function, with result of SplitSignatureData or BladeJSError

Returns​

SplitSignatureData - v-r-s signature

Example​

val parameters = ContractFunctionParameters().addString("hello")
val accountPrivateKey = "302d300706052b8104000a032200029dc73991b0d9cd..."
Blade.getParamsSignature(
parameters,
accountPrivateKey
) { result, error ->
println(result ?: error)
}

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.

getTransactions (accountId: String, transactionType: String, nextPage: String = "", transactionsLimit: Int = 10, completion: (TransactionsHistoryData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
accountIdStringaccount id to get transactions for (0.0.xxxxx)
transactionTypeStringone of enum MirrorNodeTransactionType or "CRYPTOTRANSFERTOKEN"
nextPageStringlink to next page of transactions from previous request
transactionsLimitIntnumber of transactions to return. Speed of request depends on this value if transactionType is set.
completion(TransactionsHistoryData?,BladeJSError?)->Unitcallback function, with result of TransactionsHistoryData or BladeJSError

Returns​

TransactionsHistoryData - transactions list

Example​

Blade.getTransactions(
accountId = "0.0.10002",
transactionType = "",
nextPage = "",
transactionsLimit = 15
) { result, error ->
println(result ?: error)
}

getC14url​

Get configured url for C14 integration (iframe or popup)

getC14url (asset: String, account: String, amount: String = "", completion: (IntegrationUrlData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
assetStringUSDC, HBAR, KARATE or C14 asset uuid
accountStringreceiver account id (0.0.xxxxx)
amountStringpreset amount. May be overwritten if out of range (min/max)
completion(IntegrationUrlData?,BladeJSError?)->Unitcallback function, with result of IntegrationUrlData or BladeJSError

Returns​

IntegrationUrlData - url to open

Example​

Blade.getC14url(
asset = "HBAR",
account = "0.0.10002",
amount = "120"
) { result, error ->
println(result ?: error)
}

exchangeGetQuotes​

Get quotes from different services for buy, sell or swap

exchangeGetQuotes (sourceCode: String, sourceAmount: Double, targetCode: String, strategy: CryptoFlowServiceStrategy, completion: (SwapQuotesData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
sourceCodeStringname (HBAR, KARATE, other token code)
sourceAmountDoubleamount to swap, buy or sell
targetCodeStringname (HBAR, KARATE, USDC, other token code)
strategyCryptoFlowServiceStrategyone of enum CryptoFlowServiceStrategy (Buy, Sell, Swap)
completion(SwapQuotesData?,BladeJSError?)->Unitcallback function, with result of SwapQuotesData or BladeJSError

Returns​

SwapQuotesData - quotes from different providers

Example​

Blade.exchangeGetQuotes(
sourceCode = "EUR",
sourceAmount = 50.0,
targetCode = "HBAR",
strategy = CryptoFlowServiceStrategy.BUY
) { result, error ->
println(result ?: error)
}

getTradeUrl​

Get configured url to buy or sell tokens or fiat

getTradeUrl (strategy: CryptoFlowServiceStrategy, accountId: String, sourceCode: String, sourceAmount: Double, targetCode: String, slippage: Double, serviceId: String, redirectUrl: String = "", completion: (IntegrationUrlData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
strategyCryptoFlowServiceStrategyBuy / Sell
accountIdStringaccount id
sourceCodeStringname (HBAR, KARATE, USDC, other token code)
sourceAmountDoubleamount to buy/sell
targetCodeStringname (HBAR, KARATE, USDC, other token code)
slippageDoubleslippage in percents. Transaction will revert if the price changes unfavorably by more than this percentage.
serviceIdStringservice id to use for swap (saucerswap, onmeta, etc)
redirectUrlStringurl to redirect after final step
completion(IntegrationUrlData?,BladeJSError?)->Unitcallback function, with result of IntegrationUrlData or BladeJSError

Returns​

IntegrationUrlData - url to open

Example​

Blade.getTradeUrl(
strategy = CryptoFlowServiceStrategy.BUY,
accountId = "0.0.10002",
sourceCode = "EUR",
sourceAmount = 50.0,
targetCode = "HBAR",
slippage = 0.5,
serviceId = "moonpay"
) { result, error ->
println(result ?: error)
}

getExchangeStatus​

Get exchange order status

getExchangeStatus (serviceId: String, orderId: String, completion: (TransakOrderInfoData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
serviceIdStringservice id to use for swap (saucerswap, onmeta, etc)
orderIdStringorder id of operation
completion(TransakOrderInfoData?,BladeJSError?)->Unitcallback function, with result of IntegrationUrlData or BladeJSError

Returns​

{TransakOrderInfoData}

Example​

Blade.getExchangeStatus("transak", "abaf28be-609f-49f4-a09a-e8e7ea7c8bd9") { result, error ->
println(result ?: error)
}

swapTokens​

Swap tokens

swapTokens (accountId: String, accountPrivateKey: String, sourceCode: String, sourceAmount: Double, targetCode: String, slippage: Double, serviceId: String, completion: (SwapResultData?, BladeJSError?) -> Unit)

Parameters​

NameTypeDescription
accountIdStringaccount id
accountPrivateKeyStringaccount private key
sourceCodeStringname (HBAR, KARATE, other token code)
sourceAmountDoubleamount to swap
targetCodeStringname (HBAR, KARATE, other token code)
slippageDoubleslippage in percents. Transaction will revert if the price changes unfavorably by more than this percentage.
serviceIdStringservice id to use for swap (saucerswap, etc)
completion(SwapResultData?,BladeJSError?)->Unitcallback function, with result of SwapResultData or BladeJSError

Returns​

SwapResultData - swap result

Example​

val accountId = "0.0.10001"
val accountPrivateKey = "302d300706052b8104000a032200029dc73991b0d9cd..."
val sourceCode = "USDC"
val targetCode = "KARATE"
Blade.swapTokens(
accountId,
accountPrivateKey,
sourceCode,
sourceAmount = 123.4,
targetCode,
slippage = 0.5,
serviceId = "moonpay"
) { result, error ->
println(result ?: error)
}

createToken​

Create token (NFT or Fungible Token)

createToken ( treasuryAccountId: String, supplyPrivateKey: String, tokenName: String, tokenSymbol: String, isNft: Boolean, keys: List<KeyRecord>, decimals: Int, initialSupply: Int, maxSupply: Int, completion: (CreateTokenData?, BladeJSError?) -> Unit )

Parameters​

NameTypeDescription
treasuryAccountIdStringtreasury account id
supplyPrivateKeyStringsupply account private key
tokenNameStringtoken name (string up to 100 bytes)
tokenSymbolStringtoken symbol (string up to 100 bytes)
isNftBooleanset token type NFT
keysList<KeyRecord>token keys
decimalsInttoken decimals (0 for nft)
initialSupplyInttoken initial supply (0 for nft)
maxSupplyInttoken max supply
completion(CreateTokenData?,BladeJSError?)->Unitcallback function, with result of CreateTokenData or BladeJSError

Returns​

CreateTokenData - token id

Example​

val keys = listOf(
KeyRecord(Config.adminPrivateKey, KeyType.admin)
)
Blade.createToken(
treasuryAccountId = Config.accountId,
supplyPrivateKey = Config.privateKey,
tokenName = "Blade Demo Token",
tokenSymbol = "GD",
isNft = true,
keys,
decimals = 0,
initialSupply = 0,
maxSupply = 250
) { result, error ->
println(result ?: error)
}

associateToken​

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

associateToken ( tokenIdOrCampaign: String, accountId: String, accountPrivateKey: String, completion: (TransactionReceiptData?, BladeJSError?) -> Unit )

Parameters​

NameTypeDescription
tokenIdOrCampaignStringtoken id to associate. Empty to associate all tokens configured in dApp. Campaign name to associate on demand
accountIdStringaccount id to associate token
accountPrivateKeyStringaccount private key
completion(TransactionReceiptData?,BladeJSError?)->Unitcallback function, with result of TransactionReceiptData or BladeJSError

Returns​

TransactionReceiptData - receipt

Example​

Blade.associateToken(
tokenIdOrCampaign = "0.0.1337",
accountId = "0.0.10001",
accountPrivateKey = "302d300706052b8104000a032200029dc73991b0d9cd..."
) { result, error ->
println(result ?: error)
}

nftMint​

Mint one NFT

nftMint ( tokenId: String, supplyAccountId: String, supplyPrivateKey: String, file: String, metadata: Map<String, Any>, storageConfig: IPFSProviderConfig, completion: (TransactionReceiptData?, BladeJSError?) -> Unit )

Parameters​

NameTypeDescription
tokenIdStringtoken id to mint NFT
supplyAccountIdStringtoken supply account id
supplyPrivateKeyStringtoken supply private key
fileStringimage to mint (base64 DataUrl image, eg.: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAA...)
metadataMap<String,Any>NFT metadata
storageConfigIPFSProviderConfigIPFS provider config
completion(TransactionReceiptData?,BladeJSError?)->Unitcallback function, with result of CreateTokenData or BladeJSError

Returns​

TransactionReceiptData - receipt

Example​

val tokenId = "0.0.13377"
val supplyAccountId = "0.0.10001"
val supplyPrivateKey = "302d300706052b8104000a032200029dc73991b0d9cd..."
val base64Image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAARUlEQVR42u3PMREAAAgEIO1fzU5vBlcPGtCVTD3QIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIXCyqyi6fIALs1AAAAAElFTkSuQmCC"
val metaData = mapOf<String, Any>(
"name" to "NFTitle",
"score" to 10,
"power" to 4,
"intelligence" to 6,
"speed" to 10
)
val storageConfig = NFTStorageConfig(
provider = NFTStorageProvider.nftStorage,
apiKey = "eyJhbGcsfgrgsrgInR5cCI6IkpXVCJ9.eyJzd5235326ZXRocjoweDfsdfsdfFM0ZkZFOEJhNjdCNjc1NDk1Q2NEREFiYjk0NTE4Njdsfc3MiOiJuZnQtc3RvcmFnZSIsImlhdCI6sdfNDQ2NDUxODQ2MiwibmFt4I6IkJsYWRlUcvxcRLLXRlc3RrdffifQ.t1wCiEuiTvcYOwssdZgiYaug4aF8ZrvMBdkTASojWGU"
)
Blade.nftMint(
tokenId,
supplyAccountId,
supplyPrivateKey,
file = base64Image,
metaData,
storageConfig,
) { result, error ->
println(result ?: error)
}

cleanup​

Method to clean-up webView

cleanup ()

postMessage​

Method to handle JS responses. By technical reasons, must be public, but you can skip it :)

postMessage (jsonString: String)

Parameters​

NameTypeDescription
jsonStringString