Public methods 📢
contructor Blade()
Blade()
Creates new instance of Blade and initialize shared parameters. On this step library got unique deviceId (hashed, none specific information shared).
Parameters
const std::string& apiKey
- key for API provided by Blade team. Unique per network and sdkEnvironment.const Network& network
- BladeSDK::Network:BladeSDK::Network::Testnet
orBladeSDK::Network::Mainnet
const std::string& dAppCode
- your dAppCode - request specific one by contacting usconst SdkEnvironment& sdkEnvironment
- BladeApi SdkEnvironment -BladeSDK::SdkEnvironment::CI
orBladeSDK::SdkEnvironment::Prod
Example
getInfo
InfoData getInfo()
Returns blade instance shared params (apiKey, dAppCode, network, visitorId, sdkEnvironment, sdkVersion)
Example
Output:
createAccount
AccountData createAccount()
Create 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
Output:
deleteAccount
TxReceipt deleteAccount(std::string deleteAccountId, std::string deletePrivateKey, std::string transferAccountId, std::string operatorAccountId, std::string operatorPrivateKey)
Delete Hedera account
Parameters
std::string deleteAccountId
- account id of account to delete (0.0.xxxxx)std::string deletePrivateKey
- account private key ECDSA (DER encoded hex string)std::string transferAccountId
- funds receiver account id. If any funds left on account, they will be transferred to this account (0.0.xxxxx)std::string operatorAccountId
- operator account id (0.0.xxxxx). Used for feestd::string operatorPrivateKey
- operator's account private key ECDSA (DER encoded hex string)
Example
Output:
getAccountInfo
AccountInfoData getAccountInfo(std::string accountId)
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.
Parameters
std::string accountId
- Hedera account id (0.0.xxxxx)
Example
Output:
getBalance
AccountBalanceData getBalance(std::string accountId)
Get hbar and token balances for specific account.
Parameters
std::string accountId
- Hedera account id (0.0.xxxxx)
Example
Output:
importAccount
PrivateKeyData importAccount(std::string seedPhrase, bool lookupAccounts)
Get ECDSA private key from mnemonic. Also try to find accountIds based on public key if lookupAccounts
is true. Returned keys with DER header. EvmAddress computed from Public key.
Parameters
std::string seedPhrase
- BIP39 mnemonicbool lookupAccounts
- if true, get accountIds from mirror node by public key
Example
Output:
transferHbars
TxReceipt transferHbars(std::string accountId, std::string accountPrivateKey, std::string recieverAccount, std::string amount, std::string memo)
Send hbars to specific account.
Parameters
std::string accountId
- sender account id (0.0.xxxxx)std::string accountPrivateKey
- sender's hex-encoded private key with DER-header (302e020100300506032b657004220420...) ECDSAstd::string recieverAccount
- receiver account id (0.0.xxxxx)std::string amount
- amout of hbars to sendstd::string memo
- transaction memo
Example
Output:
transferTokens
TxReceipt transferTokens(std::string tokenId, std::string accountId, std::string accountPrivateKey, std::string receiverId, std::string amount, std::string memo, bool freeTransfer)
Send token to specific account.
Parameters
std::string tokenId
- token id to send (0.0.xxxxx)std::string accountId
- sender account id (0.0.xxxxx)std::string accountPrivateKey
- sender's hex-encoded private key with DER-header (302e020100300506032b657004220420...). ECDSAstd::string receiverId
- receiver account id (0.0.xxxxx)std::string amount
- amount of tokens to sendstd::string memo
- transaction memobool freeTransfer
- if true, Blade will pay fee transaction. Only for single dApp configured token. In that case tokenId not used
Example
Output:
sign
SignMessageData sign(std::string message, std::string signerKey, std::string encoding)
Sign message with private key. Returns hex-encoded signature.
Parameters
std::string message
- hex/base64/string message to signstd::string signerKey
- ECDSA hex-encoded private key with DER headerstd::string encoding
- message encoding:hex
,base64
orstring
Example
Output:
signVerify
bool signVerify(std::string message, std::string signatureHex, std::string key, std::string encoding)
Verify message signature by public key.
Parameters
std::string message
- hex/base64/string message to signstd::string signatureHex
- hex-encoded signaturestd::string key
- ECDSA hex-encoded public key with DER headerstd::string encoding
- message encoding:hex
,base64
orstring
Example
Output:
contractCallFunction
TxReceipt contractCallFunction(std::string contractId, std::string functionName, ContractFunctionParameters parameters, std::string accountId, std::string accountPrivateKey, long long gas, bool bladePayFee)
Call contract function. Directly or via Blade Payer account (fee will be paid by Blade), depending on your dApp configuration.
Parameters
std::string contractId
- contract id (0.0.xxxxx)std::string functionName
- name of the contract function to callContractFunctionParameters parameters
- function arguments. Can be generated with ContractFunctionParameters objectstd::string accountId
- operator account id (0.0.xxxxx)std::string accountPrivateKey
- operator's hex-encoded private key with DER-header, ECDSAlong long gas
- gas limit for the transactionbool bladePayFee
- if true, fee will be paid by Blade (note: msg.sender inside the contract will be Blade Payer account)
Example
Output:
contractCallQueryFunction
ContractFunctionResult contractCallQueryFunction(std::string contractId, std::string functionName, ContractFunctionParameters parameters, std::string accountId, std::string accountPrivateKey, long long gas, double maxQueryPayment, std::vectorstd::string returnTypes)
Call query on contract function. Similar to contractCallFunction can be called directly only.
Parameters
std::string contractId
- contract id (0.0.xxxxx)std::string functionName
- name of the contract function to callContractFunctionParameters parameters
- function argument. Can be generated with ContractFunctionParameters objectstd::string accountId
- operator account id (0.0.xxxxx)std::string accountPrivateKey
- operator's hex-encoded private key with DER-header, ECDSAlong long gas
- gas limit for the transactiondouble maxQueryPayment
- max query payment amountstd::vector<std::string> returnTypes
- array of result types
Example
Output:
getC14url
std::string getC14url(std::string asset, std::string account, std::string amount)
Get configured url for C14 integration (iframe or popup)
Parameters
std::string asset
- name (USDC, HBAR, etc)std::string account
- receiver account id (0.0.xxxxx)std::string amount
- preset amount. May be overwritten if out of range (min/max)
Example
Output:
getTransactions
TransactionsHistoryData getTransactions(std::string accountId, std::string transactionType, std::string nextPage, int transactionsLimit)
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.
Parameters
std::string accountId
- account id to get transactions for (0.0.xxxxx)std::string transactionType
- one of available values (CRYPTOTRANSFER
,CONTRACTCALL
, etc...)std::string nextPage
- link to next page of transactions from previous requestint transactionsLimit
- number of transactions to return. Speed of request depends on this value if transactionType is set.
Example
Output:
Last updated