Skip to main content

Contents

Methods

init

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

init( apiKey: string, network: string, dAppCode: string, visitorId: string = "", sdkEnvironment: SdkEnvironment = SdkEnvironment.Prod, sdkVersion: string = config.sdkVersion, completionKey?: string): Promise<InfoData>

Parameters

NameTypeDescription
apiKeystringUnique key for API provided by Blade team.
networkstring"Mainnet" or "Testnet" of Hedera network
dAppCodestringyour dAppCode - request specific one by contacting Bladelabs team
visitorIdstringoptional field to set client unique id. SDK will try to get it using fingerprintjs-pro library by default.
sdkEnvironmentSdkEnvironmentoptional field to set BladeAPI environment (Prod, CI). Prod used by default.
sdkVersionstringoptional field, used for header X-SDK-VERSION
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<InfoData> - status: "success" or "error"

Example

const info = await bladeSdk.init("apiKey", "Mainnet", "dAppCode");

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)

getInfo(completionKey?: string): InfoData

Parameters

NameTypeDescription
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

InfoData

Example

const info = bladeSdk.getInfo();

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 that credentials.

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

setUser( accountProvider: AccountProvider, accountIdOrEmail: string, privateKey?: string, completionKey?: string): Promise<UserInfoData>

Parameters

NameTypeDescription
accountProviderAccountProviderAccount provider (Hedera or Magic)
accountIdOrEmailstringHedera account id (0.0.xxxxx) or Magic email
privateKeystringprivate key with DER-prefix (302e020100300506032b657004220420...) or empty string for Magic provider
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<UserInfoData>

Example

// Set account for Hedera provider
const userInfo = await bladeSdk.setUser(AccountProvider.Hedera, "0.0.45467464", "302e020100300506032b6570042204204323472EA5374E80B07346243234DEADBEEF25235235...");
// Set account for Magic provider
const userInfo = await bladeSdk.setUser(AccountProvider.Magic, "your_email@domain.com", "");

resetUser

Clears current user credentials.

resetUser(completionKey?: string): Promise<StatusResult>

Parameters

NameTypeDescription
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<StatusResult>

Example

const result = await bladeSdk.resetUser();

getBalance

Get hbar and token balances for specific account.

getBalance(accountId: string, completionKey?: string): Promise<BalanceData>

Parameters

NameTypeDescription
accountIdstringHedera account id (0.0.xxxxx)
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<BalanceData> - hbars: number, tokens: [{tokenId: string, balance: number}]

Example

const balance = await bladeSdk.getBalance("0.0.45467464");

getCoinList

Get list of all available coins on CoinGecko.

getCoinList(completionKey?: string): Promise<CoinListData>

Parameters

NameTypeDescription
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<CoinListData>

Example

const coinList = await bladeSdk.getCoinList();

getCoinPrice

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

getCoinPrice( search: string = "hbar", currency: string = "usd", completionKey?: string): Promise<CoinInfoData>

Parameters

NameTypeDescription
searchstringcoin alias (get one using getCoinList method)
currencystringcurrency to get price in (usd, eur, etc.)
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<CoinInfoData>

Example

const coinInfo = await bladeSdk.getCoinPrice("hedera-hashgraph", "usd");

transferHbars

Send hbars to specific account.

transferHbars( accountId: string, accountPrivateKey: string, receiverId: string, amount: string, memo: string, completionKey?: string): Promise<TransactionReceiptData>

Parameters

NameTypeDescription
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)
amountstringamount of hbars to send (decimal number)
memostringtransaction memo
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<TransactionReceiptData>

Example

const receipt = await bladeSdk.transferHbars("0.0.10001", "302e020100300506032b65700422042043234DEADBEEF255...", "0.0.10002", "1.0", "test memo");

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, paramsEncoded: string | ParametersBuilder, accountId: string, accountPrivateKey: string, gas: number = 100000, usePaymaster: boolean = false, completionKey?: string): Promise<TransactionReceiptData>

Parameters

NameTypeDescription
contractIdstringcontract id (0.0.xxxxx)
functionNamestringname of the contract function to call
paramsEncodedstring | ParametersBuilderfunction argument. Can be generated with ParametersBuilder object
accountIdstringoperator account id (0.0.xxxxx)
accountPrivateKeystringoperator's hex-encoded private key with DER-header, ECDSA or Ed25519
gasnumbergas limit for the transaction
usePaymasterbooleanif true, fee will be paid by Paymaster account (note: msg.sender inside the contract will be Paymaster account)
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<TransactionReceiptData>

Example

const params = new ParametersBuilder().addString("Hello");
const contractId = "0.0.123456";
const gas = 100000;
const receipt = await bladeSdk.contractCallFunction(contractId, "set_message", params, "0.0.10001", "302e020100300506032b65700422042043234DEADBEEF255...", gas, false);

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, paramsEncoded: string | ParametersBuilder, accountId: string, accountPrivateKey: string, gas: number = 100000, usePaymaster: boolean = false, resultTypes: string[], completionKey?: string): Promise<ContractCallQueryRecordsData>

Parameters

NameTypeDescription
contractIdstring- contract id (0.0.xxxxx)
functionNamestring- name of the contract function to call
paramsEncodedstring | ParametersBuilder- function argument. Can be generated with ParametersBuilder object
accountIdstring- operator account id (0.0.xxxxx)
accountPrivateKeystring- operator's hex-encoded private key with DER-header, ECDSA or Ed25519
gasnumber- gas limit for the transaction
usePaymasterboolean- if true, the fee will be paid by paymaster account (note: msg.sender inside the contract will be Paymaster account)
resultTypesstring[]- array of result types. Currently supported only plain data types
completionKeystring- optional field bridge between mobile webViews and native apps

Returns

Promise<ContractCallQueryRecordsData>

Example

const params = new ParametersBuilder();
const contractId = "0.0.123456";
const gas = 100000;
const result = await bladeSdk.contractCallQueryFunction(contractId, "get_message", params, "0.0.10001", "302e020100300506032b65700422042043234DEADBEEF255...", gas, false, ["string"]);

transferTokens

Send token to specific account.

transferTokens( tokenId: string, accountId: string, accountPrivateKey: string, receiverID: string, amountOrSerial: string, memo: string, usePaymaster: boolean = false, completionKey?: string): Promise<TransactionReceiptData>

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)
amountOrSerialstringamount of fungible tokens to send (with token-decimals correction) on NFT serial number
memostringtransaction memo
usePaymasterbooleanif true, Paymaster account will pay fee transaction. Only for single dApp configured fungible-token. In that case tokenId not used
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<TransactionReceiptData>

Example

const receipt = await bladeSdk.transferTokens("0.0.1337", "0.0.10001", "302e020100300506032b65700422042043234DEADBEEF255...", "0.0.10002", "1.0", "test memo", false);

createScheduleTransaction

Create scheduled transaction

createScheduleTransaction( accountId: string, accountPrivateKey: string, type: ScheduleTransactionType, transfers: ScheduleTransactionTransfer[], usePaymaster: boolean = false, completionKey?: string): Promise<ScheduleResult>

Parameters

NameTypeDescription
accountIdstringaccount id (0.0.xxxxx)
accountPrivateKeystringoptional field if you need specify account key (hex encoded privateKey with DER-prefix)
typeScheduleTransactionTypeschedule transaction type (currently only TRANSFER supported)
transfersScheduleTransactionTransfer[]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)
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<ScheduleResult>

Example

const receiverAccountId = "0.0.10001";
const receiverAccountPrivateKey = "302e020100300506032b65700422042043234DEADBEEF255...";
const senderAccountId = "0.0.10002";
const tokenId = "0.0.1337";
const nftId = "0.0.1234";
const {scheduleId} = await bladeSdk.createScheduleTransaction(
receiverAccountId,
receiverAccountPrivateKey,
"TRANSFER", [
{
type: "HBAR",
sender: senderAccountId,
receiver: receiverAccountId,
value: 1 * 10**8,
},
{
type: "FT",
sender: senderAccountId,
receiver: receiverAccountId,
tokenId: tokenId,
value: 1
},
{
type: "NFT",
sender: senderAccountId,
receiver: receiverAccountId,
tokenId: nftId,
serial: 4
},
],
false
);

signScheduleId

Sign scheduled transaction

signScheduleId( scheduleId: string, accountId: string, accountPrivateKey: string, receiverAccountId?: string, usePaymaster: boolean = false, completionKey?: string): Promise<TransactionReceiptData>

Parameters

NameTypeDescription
scheduleIdstringscheduled transaction id (0.0.xxxxx)
accountIdstringaccount id (0.0.xxxxx)
accountPrivateKeystringoptional field if you need specify account 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)
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<TransactionReceiptData>

Example

const scheduleId = "0.0.754583634";
const senderAccountId = "0.0.10002";
const senderAccountPrivateKey = "302e020100300506032b65700422042043234DEADBEEF255...";
const receiverAccountId = "0.0.10001";
const receipt = await bladeSdk.signScheduleId(scheduleId, senderAccountId, senderAccountPrivateKey, receiverAccountId, false);

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.

createAccount(privateKey?: string, deviceId?: string, completionKey?: string): Promise<CreateAccountData>

Parameters

NameTypeDescription
privateKeystringoptional field if you need specify account key (hex encoded privateKey with DER-prefix)
deviceIdstringoptional field for headers for backend check
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<CreateAccountData>

Example

const account = await bladeSdk.createAccount();

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, mnemonic: string, completionKey?: string): Promise<CreateAccountData>

Parameters

NameTypeDescription
transactionIdstringreturned from createAccount() method
mnemonicstringreturned from createAccount() method
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<CreateAccountData>

Example

const account = await bladeSdk.createAccount();
if (account.status === "PENDING") {
// wait some time and call getPendingAccount method
account = await bladeSdk.getPendingAccount(account.transactionId, account.seedPhrase);
}

deleteAccount

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

deleteAccount( deleteAccountId: string, deletePrivateKey: string, transferAccountId: string, operatorAccountId: string, operatorPrivateKey: string, completionKey?: string): Promise<TransactionReceiptData>

Parameters

NameTypeDescription
deleteAccountIdstringaccount id of account to delete (0.0.xxxxx)
deletePrivateKeystringaccount private key (DER encoded hex string)
transferAccountIdstringif any funds left on account, they will be transferred to this account (0.0.xxxxx)
operatorAccountIdstringoperator account id (0.0.xxxxx). Used for fee
operatorPrivateKeystringoperator's account private key (DER encoded hex string)
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<TransactionReceiptData>

Example

const receipt = await bladeSdk.deleteAccount(accountToDelete.accountId, accountToDelete.privateKey, "0.0.10001", "0.0.10001", "302e020100300506032b65700422042043234DEADBEEF255...");

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, completionKey?: string): Promise<AccountInfoData>

Parameters

NameTypeDescription
accountIdstringHedera account id (0.0.xxxxx)
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<AccountInfoData>

Example

const accountInfo = await bladeSdk.getAccountInfo("0.0.10001");

getNodeList

Get Node list

getNodeList(completionKey?: string): Promise<NodeListData>

Parameters

NameTypeDescription
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<NodeListData>

Example

const nodeList = await bladeSdk.getNodeList();

stakeToNode

Stake/unstake account

stakeToNode( accountId: string, accountPrivateKey: string, nodeId: number, completionKey?: string): Promise<TransactionReceiptData>

Parameters

NameTypeDescription
accountIdstringHedera account id (0.0.xxxxx)
accountPrivateKeystringaccount private key (DER encoded hex string)
nodeIdnumbernode id to stake to. If negative or null, account will be unstaked
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<TransactionReceiptData>

Example

const receipt = await bladeSdk.stakeToNode("0.0.10001", "302e020100300506032b65700422042043234DEADBEEF255...", 3);

getKeysFromMnemonic

getKeysFromMnemonic( mnemonicRaw: string, // eslint-disable-next-line @typescript-eslint/no-unused-vars lookupNames: boolean = true, completionKey?: string): Promise<PrivateKeyData>

Parameters

NameTypeDescription
mnemonicRawstringBIP39 mnemonic
lookupNamesbooleannot used anymore, account search is mandatory
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<PrivateKeyData>

Example

const result = await bladeSdk.getKeysFromMnemonic("purity slab doctor swamp tackle rebuild summer bean craft toddler blouse switch");

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, completionKey?: string): Promise<AccountPrivateData>

Parameters

NameTypeDescription
keyOrMnemonicstringBIP39 mnemonic, private key with DER header
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<AccountPrivateData>

Example

const resultKey = await bladeSdk.searchAccounts("302e020100300506032b65700422042043234DEADBEEF255...");
const resultSeed = await bladeSdk.searchAccounts("purity slab doctor swamp tackle rebuild summer bean craft toddler blouse switch");

dropTokens

Bladelink drop to account

dropTokens( accountId: string, accountPrivateKey: string, secretNonce: string, completionKey?: string): Promise<TokenDropData>

Parameters

NameTypeDescription
accountIdstringHedera account id (0.0.xxxxx)
accountPrivateKeystringaccount private key (DER encoded hex string)
secretNoncestringconfigured for dApp. Should be kept in secret
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<TokenDropData>

Example

const drop = await bladeSdk.dropTokens("0.0.10001", "302e020100300506032b65700422042043234DEADBEEF255...", "secret-nonce");

sign

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

sign(messageString: string, privateKey: string, completionKey?: string): SignMessageData

Parameters

NameTypeDescription
messageStringstringbase64-encoded message to sign
privateKeystringhex-encoded private key with DER header
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

SignMessageData

Example

const signed = await bladeSdk.sign(btoa("Hello"), "302e020100300506032b65700422042043234DEADBEEF255...");

signVerify

Verify message signature by public key

signVerify( messageString: string, signature: string, publicKey: string, completionKey?: string): SignVerifyMessageData

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
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

SignVerifyMessageData

Example

const signature = "27cb9d51434cf1e76d7ac515b19442c619f641e6fccddbf4a3756b14466becb6992dc1d2a82268018147141fc8d66ff9ade43b7f78c176d070a66372d655f942";
const publicKey = "302d300706052b8104000a032200029dc73991b0d9cdbb59b2cd0a97a0eaff6de...";
const valid = await bladeSdk.signVerify(btoa("Hello"), signature, publicKey);

ethersSign

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

ethersSign(messageString: string, privateKey: string, completionKey?: string): Promise<SignMessageData>

Parameters

NameTypeDescription
messageStringstringbase64-encoded message to sign
privateKeystringhex-encoded private key with DER header
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<SignMessageData>

Example

const signed = await bladeSdk.ethersSign(btoa("Hello"), "302e020100300506032b65700422042043234DEADBEEF255...");

splitSignature

Split signature to v-r-s format.

splitSignature(signature: string, completionKey?: string): SplitSignatureData

Parameters

NameTypeDescription
signaturestringhex-encoded signature
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

SplitSignatureData

Example

const signature = "27cb9d51434cf1e76d7ac515b19442c619f641e6fccddbf4a3756b14466becb6992dc1d2a82268018147141fc8d66ff9ade43b7f78c176d070a66372d655f942";
const {v, r, s} = await bladeSdk.splitSignature(signature);

getParamsSignature

Get v-r-s signature of contract function params

getParamsSignature( paramsEncoded: string | ParametersBuilder, privateKey: string, completionKey?: string): Promise<SplitSignatureData>

Parameters

NameTypeDescription
paramsEncodedstring | ParametersBuilderdata to sign. Can be string or ParametersBuilder
privateKeystringsigner private key (hex-encoded with DER header)
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<SplitSignatureData>

Example

const params = new ParametersBuilder().addAddress(accountId).addString("Hello");
const result = await bladeSdk.getParamsSignature(params, "302e020100300506032b65700422042043234DEADBEEF255...");

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: string = "10", completionKey?: string): Promise<TransactionsHistoryData>

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
transactionsLimitstringnumber of transactions to return. Speed of request depends on this value if transactionType is set.
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<TransactionsHistoryData>

Example

const transactions = await bladeSdk.getTransactions("0.0.10001");

getC14url

Get configured url for C14 integration (iframe or popup)

getC14url( asset: string, account: string, amount: string, completionKey?: string): Promise<IntegrationUrlData>

Parameters

NameTypeDescription
assetstringname (USDC or HBAR)
accountstringreceiver account id (0.0.xxxxx)
amountstringpreset amount. May be overwritten if out of range (min/max)
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<IntegrationUrlData>

Example

const {url} = await bladeSdk.getC14url("HBAR", "0.0.10001", "100");

exchangeGetQuotes

Get quotes from different services for buy, sell or swap

exchangeGetQuotes( sourceCode: string, sourceAmount: number, targetCode: string, strategy: CryptoFlowServiceStrategy, completionKey?: string): Promise<SwapQuotesData>

Parameters

NameTypeDescription
sourceCodestringname (HBAR, KARATE, other token code)
sourceAmountnumberamount to swap, buy or sell
targetCodestringname (HBAR, KARATE, USDC, other token code)
strategyCryptoFlowServiceStrategyone of enum CryptoFlowServiceStrategy (Buy, Sell, Swap)
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<SwapQuotesData>

Example

const quotes = await bladeSdk.exchangeGetQuotes("EUR", 100, "HBAR", CryptoFlowServiceStrategy.BUY);

swapTokens

Swap tokens

swapTokens( accountId: string, accountPrivateKey: string, sourceCode: string, sourceAmount: number, targetCode: string, slippage: number, serviceId: string, completionKey?: string): Promise<SwapResult>

Parameters

NameTypeDescription
accountIdstringaccount id
accountPrivateKeystringaccount private key
sourceCodestringname (HBAR, KARATE, other token code)
sourceAmountnumberamount to swap
targetCodestringname (HBAR, KARATE, other token code)
slippagenumberslippage in percents. Transaction will revert if the price changes unfavorably by more than this percentage.
serviceIdstringservice id to use for swap (saucerswap, etc)
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<SwapResult>

Example

const result = await bladeSdk.swapTokens("0.0.10001", "302e020100300506032b65700422042043234DEADBEEF255...", "HBAR", 1, "SAUCE", 0.5, "saucerswapV2");

getExchangeStatus

Get exchange order status

getExchangeStatus(serviceId: string, orderId: string, completionKey?: string): Promise<TransakOrderInfo>

Parameters

NameTypeDescription
serviceIdstringservice id to use for swap (saucerswap, onmeta, etc)
orderIdstringorder id of operation
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<TransakOrderInfo>

Example

const orderInfo = await bladeSdk.getExchangeStatus("transak", "abaf28be-609f-49f4-a09a-e8e7ea7c8bd9");

getTradeUrl

Get configured url to buy or sell tokens or fiat

getTradeUrl( strategy: CryptoFlowServiceStrategy, accountId: string, sourceCode: string, sourceAmount: number, targetCode: string, slippage: number, serviceId: string, redirectUrl: string = "", completionKey?: string): Promise<IntegrationUrlData>

Parameters

NameTypeDescription
strategyCryptoFlowServiceStrategyBuy / Sell
accountIdstringaccount id
sourceCodestringname (HBAR, KARATE, USDC, other token code)
sourceAmountnumberamount to buy/sell
targetCodestringname (HBAR, KARATE, USDC, other token code)
slippagenumberslippage in percents. Transaction will revert if the price changes unfavorably by more than this percentage.
serviceIdstringservice id to use for swap (saucerswap, onmeta, etc)
redirectUrlstringoptional url to redirect after final step
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<IntegrationUrlData>

Example

const {url} = await bladeSdk.getTradeUrl(CryptoFlowServiceStrategy.BUY, "0.0.10001", "EUR", 50, "HBAR", 0.5, "saucerswapV2", redirectUrl);

createToken

Create token (NFT or Fungible Token)

createToken( treasuryAccountId: string, supplyPrivateKey: string, tokenName: string, tokenSymbol: string, isNft: boolean, keys: KeyRecord[] | string, decimals: number, initialSupply: number, maxSupply: number = 250, completionKey?: string): Promise<CreateTokenResult>

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
keysKeyRecord[] | stringtoken keys
decimalsnumbertoken decimals (0 for nft)
initialSupplynumbertoken initial supply (0 for nft)
maxSupplynumbertoken max supply
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<CreateTokenResult>

Example

const keys: KeyRecord[] = [
{type: KeyType.admin, privateKey: adminKey},
{type: KeyType.wipe, privateKey: wipeKey},
{type: KeyType.pause, privateKey: pauseKey},
];
const treasuryAccountId = "0.0.10001";
const supplyKey = "302e020100300506032b65700422042043234DEADBEEF255...";
const result = await bladeSdk.createToken(
treasuryAccountId, // treasuryAccountId
supplyKey, // supplyPrivateKey
tokenName,
tokenSymbol,
true, // isNft
keys,
0, // decimals
0, // initialSupply
250, // maxSupply
);

associateToken

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

associateToken( tokenIdOrCampaign: string, accountId: string, accountPrivateKey: string, completionKey?: string): Promise<TransactionReceiptData>

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
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<TransactionReceiptData>

Example

const result = await bladeSdk.associateToken("0.0.1337", "0.0.10001", "302e020100300506032b65700422042043234DEADBEEF255...");
const result = await bladeSdk.associateToken("CampaignName", "0.0.10001", "302e020100300506032b65700422042043234DEADBEEF255...");

nftMint

Mint one NFT

nftMint( tokenId: string, accountId: string, accountPrivateKey: string, file: File | string, metadata: object, ipfsProviderConfig: IPFSProviderConfig, completionKey?: string): Promise<TransactionReceiptData>

Parameters

NameTypeDescription
tokenIdstringtoken id to mint NFT
accountIdstringtoken supply account id
accountPrivateKeystringtoken supply private key
fileFile | stringimage to mint (File or base64 DataUrl image, eg.: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAA...)
metadataobjectNFT metadata (JSON object)
ipfsProviderConfigIPFSProviderConfigIPFS provider config
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<TransactionReceiptData>

Example

const receipt = await bladeSdk.nftMint(
tokenId,
treasuryAccountId,
supplyKey,
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAARUlEQVR42u3PMREAAAgEIO1fzU5vBlcPGtCVTD3QIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIXCyqyi6fIALs1AAAAAElFTkSuQmCC", // TODO upload file base64
{
author: "GaryDu",
other: "metadata",
some: "more properties"
},
{
provider: IPFSProvider.pinata,
token: Pinata_JWT,
}
);

getTokenInfo

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

getTokenInfo(tokenId: string, serial: string = "", completionKey?: string): Promise<TokenInfoData>

Parameters

NameTypeDescription
tokenIdstringtoken id
serialstringserial number for NFT
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<TokenInfoData>

Example

const tokenInfo = await bladeSdk.getTokenInfo("0.0.1234", "3");

brokenMnemonicEmergencyTransfer

Emergency balance transfer from broken mnemonic account to new account

Accounts with broken mnemonic sometimes were created because of hedera-sdk issue

To transfer funds from broken mnemonic account to new account a couple of steps required:

  1. Create new account

  2. Associate all tokens with new account that you want to transfer

  3. Call this method to transfer funds to new account

  4. Send some HBAR to broken mnemonic account to cover fees if needed

brokenMnemonicEmergencyTransfer(seedPhrase: string, accountId: string, receiverId: string, hbarAmount: string, tokenList: string[], checkOnly: boolean, completionKey?: string): Promise<EmergencyTransferData>

Parameters

NameTypeDescription
seedPhrasestringmnemonic from account
accountIdstringaccount id (broken)
receiverIdstringnew account id
hbarAmountstringamount of HBAR to resque. Can be 0
tokenListstring[]list of token ids to transfer all tokens. Up to 9 at once. Can be empty
checkOnlybooleanif true, will only check if mnemonic is broken. No transfer will be made
completionKeystringoptional field bridge between mobile webViews and native apps

Returns

Promise<EmergencyTransferData>

Example

const receipt = await bladeSdk.brokenMnemonicEmergencyTransfer(brokenSeed, resqueAccountId, newAccountId, "0.5", ["0.0.1337"], false);