SDK API Reference
Account#
create#
- Creates an instance of WalletKeypar using password.
This method is used to create a WalletKeypar using password. The Keypair contains some essential information, such as:
- Â address
- Â public key
- Â key store
and so on, and it is used for pretty much any personalized operation that user can do using FindoraSdk
Parameters:#
- Â
<string>- Password of account
Results:#
- Â
Promise<WalletKeypar>- An instance ofWalletKeypar
Example:#
const password = "qsjEI%123";
// Create a wallet info object using given passwordconst walletInfo = await Account.create(password);getBalance#
- Get the balance of the specific asset for the given user
Using this function user can retrieve the balance for the specific asset code, which could be either custom asset or an FRA asset
Parameters:#
- Â
<WalletKeypar>- An instance of WalletKeypar - Â
<string>- (optional) Asset Code which could be either custom asset or an FRA asset.
Results:#
- Â
Promise<string>- The balance of the specific asset for the given user.
Example:#
const pkey = "lfyd1234!";const password = "uuicnf!34";
// Restore Walletconst walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);
// Get balanceconst balance = await Account.getBalance(walletInfo, customAssetCode);getBalanceInWei#
- Get the balance of the specific asset for the given user in Wei format
Using this function user can retrieve the balance for the specific asset code, which could be either custom asset or an FRA asset
Parameters:#
- Â
<WalletKeypar>- An instance of WalletKeypar - Â
<string>- (optional) Asset Code which could be either custom asset or an FRA asset.
Results:#
- Â
Promise<BigNumberValue>- The balance of the specific asset for the given user in Wei format.
Example:#
const pkey = "lfyd1234!";const password = "uuicnf!34";
// Restore Walletconst walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);
// Get balance in Wei formatconst balance = await Account.getBalanceInWei(walletInfo, customAssetCode);getCreatedAssets#
- Get an array of instances of ProcessedIssuedRecord using wallet address.
This method is used to get created Assets. The ProcessedIssuedRecord contains some essential information, such as:
- Â code
- Â record
- Â id
- Â ownerMemo
and so on. It's the issued asset.
Parameters:#
- Â
<string>- Wallet address.
Results:#
- Â
Promise<ProcessedIssuedRecord[]>- an array ofProcessedIssuedRecordinstances.
Example:#
const pkey = "lfyd1234!";const password = "uuicnf!34";
// Restore Walletconst walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);
// Get balance in Wei formatconst balance = await Account.getBalanceInWei(walletInfo, customAssetCode);KeyPair#
createKeypair#
- Creates an instance of WalletKeypar using password.
This method is used to restore a wallet keypair. The Keypair contains some essential information, such as:
- Â address
- Â public key
- Â key store
and so on, and it is used for pretty much any personalized operation that user can do using FindoraSdk
Parameters:#
- Â
<string>- Password to be used to generate an encrypted KeyStore
Results:#
- Â
Promise<WalletKeypar>- An instance ofWalletKeypar
Example:#
const password = "qsjEI%123";
// Create a wallet info object using given passwordconst walletPair = await Keypair.createKeypair(password);getAddressByPublicKey#
- Get wallet address by given public key
Using this function user can retreive the wallet address by given public key
Parameters:#
- Â
<string>- Public key
Results:#
- Â
Promise<string>- A wallet address.
Example:#
const pubkey = "qsjEI%123";// Get wallet address by public keyconst walletAddress = await Keypair.getAddressByPublicKey(pubkey);getAddressPublicAndKey#
- Create an instance of LightWalletKeypair using given wallet address.
This method is used to create a light version of the WalletKeypar using given wallet address.The LightWalletKeypair contains two essential information:
- Â address
- Â public key
It's a light version of the WalletKeypar, containing only address and publickey
Parameters:#
- Â
<string>- Wallet address
Results:#
- Â
Promise<LightWalletKeypair>- An instance ofLightWalletKeypair.
Example:#
const address = "fra234xfde4";
// Create a LightWalletKeypair object using given addressconst lightWalletKeypair = await Keypair.getAddressPublicAndKey(address);getMnemonic#
- Creates an array of Mnemonic phrases.
This method is used to creates an array of Mnemonic phrases.
Parameters:#
- Â
<number>- Desired length of mnemonic phrases. It can only be 12/15/18/21/24. - Â
<string>- (optional) Default isen.
Results:#
- Â
Promise<LightWalletKeypair>- An instance ofLightWalletKeypair.
Example:#
const desiredLength = 24;
// Create a wallet info object using given passwordconst mnemonic = await Keypair.getMnemonic(desiredLength);restoreFromMnemonic#
- Creates an instance of WalletKeypar using Mnemonic and password.
This method is used to restore a wallet keypair. The Keypair contains some essential information, such as:
- Â address
- Â public key
- Â key store
and so on, and it is used for pretty much any personalized operation that user can do using FindoraSdk
Parameters:#
- Â
<string[]>- mnemonic words - Â
<string>- Password to be used to generate an encrypted KeyStore
Results:#
- Â
Promise<WalletKeypar>- An instance ofWalletKeypar.
Example:#
const password = "qsjEI%123";const mnemonic = ["Apple", "Orange", "Banana"];
// Create a wallet info object using given Mnemonic and passwordconst walletPair = await Keypair.restoreFromMnemonic(mnemonic, password);restoreFromPrivateKey#
- Creates an instance of WalletKeypar using given private key and password.
This method is used to restore a wallet keypair. The Keypair contains some essential information, such as:
- Â address
- Â public key
- Â key store
and so on, and it is used for pretty much any personalized operation that user can do using FindoraSdk
Parameters:#
- Â
<string>- Private key - Â
<string>- Password to be used to generate an encrypted KeyStore
Results:#
- Â
Promise<WalletKeypar>- An instance ofWalletKeypar.
Example:#
const password = "qsjEI%123";const pkey = "XXXXXXXXXX";
// Create a wallet info object using given private key and passwordconst walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);Network#
getAbciInfo#
- Get ABCI information
This method is used to get ABCI information.
Parameters:#
- Â
<string>- a wallet address - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<AbciInfoResult>- An instance ofAbciInfoResultcontaining the response and error.
Example:#
const data = "0x12345d";
// Get ABCI informationconst acbiInfo = await Network.getAbciInfo(data);getAbciNoce#
- Get ABCI Noce
This method is used to get ABCI Noce.
Parameters:#
- Â
<string>- a wallet address - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<AbciNoceResult>- An instance ofAbciNoceResultcontaining the response and error.
Example:#
const data = "0x12345d";
// Get ABCI Noceconst acbiNoce = await Network.getAbciNoce(data);getAssetToken#
- Get information of given type of asset token
This method is used to get information of given type of asset token
Parameters:#
- Â
<string>- asset code - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<AssetTokenDataResult>- An instance ofAssetTokenDataResultcontaining the response and error.
Example:#
const data = "0x12345d";
// Get ABCI Noceconst acbiNoce = await Network.getAbciNoce(data);getBlock#
- Get datails of given block
This method is used to get details of given block.
Parameters:#
- Â
<number>- block Height - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<BlockDetailsDataResult>- An instance ofBlockDetailsDataResultcontaining the response and error.
Example:#
const blockHeight = 1432;
// Get block #1432 detailsconst blockDetail = await Network.getBlock(blockHeight);getDelegateInfo#
- Get the delegation information
This method is used to get the delegation information.
Parameters:#
- Â
<string>- public key - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<DelegateInfoDataResult>- An instance ofDelegateInfoDataResultcontaining the response and error.
Example:#
const publickey = "qsedx23rtgds";
// Get the delegation informationconst blockDetail = await Network.getDelegateInfo(publickey);getHashSwap#
- Get transaction details
This method is used to get details of transaction with given hash
Parameters:#
- Â
<string>- transaction hash - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<HashSwapDataResult>- An instance ofHashSwapDataResultcontaining the response and error.
Example:#
const hash = `YOUR_TX_HASH`;
// Get transaction details of given hashconst txDetail = await Network.getHashSwap(hash);getIssuedRecords#
- Get information of issued records for given public key
This method is used to get information of issued records for given public key
Parameters:#
- Â
<string>- public key - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<IssuedRecordDataResult>- An instance ofIssuedRecordDataResultcontaining the response and error.
Example:#
const publickey = `publickeyexample`;
// Get issed records informationconst issuedRecords = await Network.getIssuedRecords(publickey);getOwnedSids#
- Get Sids owned by given address
This method is used to get Sids owned by given address
Parameters:#
- Â
<string>- wallet address - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<OwnedSidsDataResult>- An instance ofOwnedSidsDataResultcontaining the response and error.
Example:#
const address = `frabhhjsswerf`;
// Get Sids' informationconst ownedSids = await Network.getOwnedSids(address);getOwnerMemo#
- Get the owner memo by given UTXO sid
This method is used to get owner memo by given UTXO sid
Parameters:#
- Â
<number>- UTXO sid - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<OwnerMemoDataResult>- An instance ofOwnerMemoDataResultcontaining the response and error.
Example:#
const utxoSid = 143;
// Get owner memoconst ownerMemo = await Network.getOwnerMemo(utxoSid);getStateCommitment#
- Returns state commitment
An important property of a Findora ledger is the ability to authenticate transactions. Users can authenticate transactions against a small tag called the state commitment. The state commitment is a commitment to the current state of the ledger. The state commitment response is a tuple containing the state commitment and the state commitment version.
Parameters:#
- Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<StateCommitmentDataResult>- An instance ofStateCommitmentDataResultcontaining the response and error.
Example:#
// Get state commitmentconst stateCommitment = await Network.getStateCommitment();getTransactionStatus#
- Returns transaction status
Using the transaction handle, user can fetch the status of the transaction from the query server.
Parameters:#
- Â
<string>- transaction handle (hash) - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<TransactionStatusDataResult>- An instance ofTransactionStatusDataResultcontaining the response and error.
Example:#
const handle = `YOUR_TX_HASH`;
// Get transaction statusconst transactionStatus = await Network.getTransactionStatus(handle);getTransactionDetails#
- Returns transaction details
Using the transaction handle, user can fetch the details of the transaction from the query server.
Parameters:#
- Â
<string>- transaction handle (hash) - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<TxDetailsDataResult>- An instance ofTxDetailsDataResultcontaining the response and error.
Example:#
const handle = `YOUR_TX_HASH`;
// Get transaction detailsconst transactionDetails = await Network.getTransactionDetails(handle);getTxList#
- Get a list of transactions for given wallet address
This method is used to get a list of transactions for given wallet address
Parameters:#
- Â
<string>- wallet address - Â
<"to"|"from">- transaction type. it can only be "to" or "from" - Â
<number>- pagination. Default is 1. - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<TxListDataResult>- An instance ofTxListDataResultcontaining the response and error.
Example:#
const address = `fra000xxsr`;const type = "to";
// Get list of `to` transaction of given addressconst txDetail = await Network.getTxList(address, type);getUtxo#
- Get UTXO ledger for given utxo sid
This method is used to get UTXO ledger for given UTXO sid
Parameters:#
- Â
<number>- UTXO SID - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<UtxoDataResult>- An instance ofUtxoDataResultcontaining the response and error.
Example:#
const utxoSid = 143;
// Get UTXO detailsconst utxoData = await Network.getUtxo(utxoSid);getValidatorList#
- Get validator list
This method is used to get the list of validators.
Parameters:#
- Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<ValidatorListDataResult>- An instance ofValidatorListDataResultcontaining the response and error.
Example:#
// Get validator listconst acbiInfo = await Network.getValidatorList();sendRpcCall#
- Send RPC call
This method is used to send RPC call.
Parameters:#
- Â
<string>- RPC url - Â
<{[key: string]: any}>- payload - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<T>- The response object from RPC call.
Example:#
cont url = `https://prod-testnet.prod.findora.org:8545`;const payload = { method: `eth_getBlockByHash`, params: ['0x1af723767d06...',true],};
// Send the RPC call to get block details by hashconst response = await Network.sendRpcCall(url,payload);submitEvmTx#
- Submit EVM transaction
This method is used to submit a EVM transaction.
Parameters:#
- Â
<string>- transaction hash - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<SubmitEvmTxResult>- An instance ofSubmitEvmTxResultcontaining the response and error.
Example:#
const tx = "Your_TX_Hash";
// Submit a EVM transactionconst result = await Network.submitEvmTx(tx);submitTransaction#
- Submit transation
This method is used to submit a transaction
Parameters:#
- Â
<TransactionData>- (optinal) transaction data - Â
<NetworkAxiosConfig>- (optinal) network config
Results:#
- Â
Promise<SubmitTransactionDataResult>- An instance ofSubmitTransactionDataResultcontaining the response and error.
Example:#
const data = `Your_Transaction_Data`;
// Submit transactionconst txResult = await Network.submitTransaction(data);sdkAsset#
defineAsset#
- Defines a custom asset
An asset definition operation registers an asset with the Findora ledger. An asset is a digital resource that can be issued and transferred.
An asset has an issuer and a unique code. The DefineAsset operation must provide an unused token code. The transaction containing the DefineAsset operation will fail if there is already another asset on the ledger with the same code.
Parameters:#
- Â
<WalletKeypar>- Wallet keypair - Â
<string>- asset name - Â
<string>- (optinal) asset memo - Â
<string>- (optinal) A set of rules (options) for the new asset.
Results:#
- Â
Promise<TransactionBuilder>- An instance ofTransactionBuilderfromLedger
Example:#
const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);
// First, we create a transaction builderconst assetBuilder = await Asset.defineAsset(walletInfo, assetCode);
// Then, we submit a transactionconst handle = await Transaction.submitTransaction(assetBuilder);getAssetCode#
- Return Asset Code
This method returns Asset Code by given asset type
Parameters:#
- Â
<number[]>- asset type
Results:#
- Â
Promise<string>- asset code.
Example:#
const assetType = [1, 2];
// Get the decrypted Asset codeconst assetCode = await Asset.getAssetCode(assetType);getAssetDetails#
- Get Asset Details
This method returns Asset details by given asset code
Parameters:#
- Â
<string>- asset code
Results:#
- Â
Promise<IAsset>- An instance ofFindoraWallet.IAsset
Example:#
const assetCode = "Your_Asset_Code";
// Get asset detailsconst assetDetails = await getAssetDetails(assetCode);getFraAssetCode#
- Returns the pre-defined FRA asset code
FRA asset code can not be re-defined, as well as it can not be used in the DefineAset or IssueAsset operations.
This is the main asset code, which is used when user needs to create a transaction, or calculate the fee and so on.
Results:#
- Â
Promise<string>- Findora Asset code
Example:#
// Get the FRA Asset codeconst fraAssetCode = await Asset.getFraAssetCode();getFraPublicKey#
- Return Destination's Public Key
This method returns the public key of destination
Results:#
- Â
Promise<XfrPublicKey>- An instance ofXfrPublicKey.
Example:#
// Get the public key of destinationconst pubKey = await Asset.getFraPublicKey();getMinimalFee#
- Return Minimal Fee for transaction
This method returns the required minimal fee for transaction
Results:#
- Â
Promise<BigInt>- An instance ofBigInt.
Example:#
// Get the minimal fee for transactionconst minFee = await Asset.getMinimalFee();getRandomAssetCode#
- Returns a random asset code
Using Ledger, it generates and returns a random custom asset code
Results:#
- Â
Promise<string>- Asset code.
Example:#
// Get a random asset codeconst assetCode = await Asset.getRandomAssetCode();issueAsset#
- Issue some amount of a custom asset
Asset issuers can use the IssueAsset operation to mint units of an asset that they have created. Concretely, the IssueAsset operation creates asset records that represent ownership by a public key of a certain amount of an asset. These asset records are stored in a structure called a transaction output (TXO).
Parameters:#
- Â
<WalletKeypar>- wallet keypair - Â
<string>- asset name - Â
<string>- amount to be issued - Â
<AssetBlindRules>- asset blind rules - Â
<number>- (optional) asset decimals. This parameter can define how many numbers after the comma would this asset have
Results:#
- Â
Promise<TransactionBuilder>- An instance ofTransactionBuilderfromLedger
Example:#
const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);
// Define the new asset parameters (rules)const assetBlindRules = { isAmountBlind: false };
// First, we create a transaction builderconst assetBuilder = await Asset.issueAsset( walletInfo, customAssetCode, amountToIssue, assetBlindRules);
// Then, we submit a transactionconst handle = await Transaction.submitTransaction(assetBuilder);Staking#
claim#
- Claim FRA Token Rewards
This function enables users to claim rewards earned from staking FRA tokens.
Parameters:#
- Â
<WalletKeypar>- Wallet keypair - Â
<string>- the amout of rewards which users wants to claim
Results:#
- Â
Promise<TransactionBuilder>- TransactionBuilder which should be used inTransaction.submitTransaction.
Example:#
const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);
// First, we create a transaction builderconst assetBuilder = await Asset.defineAsset(walletInfo, assetCode);
// Then, we submit a transactionconst handle = await Transaction.submitTransaction(assetBuilder);delegate#
- Delegates FRA tokens
This function allows users to delegate FRA tokens to a validator.
This functionality is nearly identical to Transaction.sendToAddress except it adds one additional operation (i.e. add_operation_delegate) to the transaction builder.
Parameters:#
- Â
<WalletKeypar>- Wallet keypair - Â
<string>- Target address for delegation - Â
<string>- delegation amout - Â
<string>- Asset Code - Â
<string>- Target validator Address - Â
<AssetBlindRules>- (optional) Confidential options for blind rule
Results:#
- Â
Promise<TransactionBuilder>- TransactionBuilder which should be used inTransaction.submitTransaction.
Example:#
const ledger = await getLedger();
// This is the address funds are sent to.// Actual `transfer to validator` process would be handled via added `add_operation_delegate` operation
const delegationTargetPublicKey = Ledger.get_delegation_target_address();const delegationTargetAddress = await Keypair.getAddressByPublicKey( delegationTargetPublicKey);
const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);
const assetCode = await Asset.getFraAssetCode();
const assetBlindRules: Asset.AssetBlindRules = { isTypeBlind: false, isAmountBlind: false,};
const transactionBuilder = await StakingApi.delegate( walletInfo, delegationTargetAddress, amount, assetCode, validatorAddress, assetBlindRules);
const resultHandle = await Transaction.submitTransaction(transactionBuilder);getDelegateInfo#
- Get the delegation information
This method is used to get the delegation information
Parameters:#
- Â
<string>- wallet address
Results:#
- Â
Promise<DelegateInfoResponse>- An instance ofDelegateInfoDataResultcontaining the response and error..
Example:#
const address = "fra123sxde";
// Get the delegation informationconst delegateInfo = await StakingApi.getDelegateInfo(address);getValidatorList#
- Get validator list
This method is used to get the list of validators.
Results:#
- Â
Promise<validatorListResponse>- An instance ofvalidatorListResponsecontaining the response and error..
Example:#
// Get validator listconst validatorList = await StakingApi.getValidatorList();unStake#
- Unstake FRA tokens
This function allows users to unstake (aka unbond) FRA tokens.
Parameters:#
- Â
<WalletKeypar>- Wallet keypair - Â
<string>- the amount users wants to unstake - Â
<string>- validator's address - Â
<boolean>- fully unstake option. Default isfalse
Results:#
- Â
Promise<TransactionBuilder>- TransactionBuilder which should be used inTransaction.submitTransaction.
Example:#
const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);
// Define whether or not user desires to unstake all the tokens, or only part of the staked amountconst isFullUnstake = false;
const transactionBuilder = await StakingApi.unStake( walletInfo, amount, validator, isFullUnstake);
const resultHandle = await Transaction.submitTransaction(transactionBuilder);Transaction#
getTransactionBuilder#
- Create an instance of TransactionBuilder
This method is used to create a transaction builder
Results:#
- Â
Promise<TransactionBuilder>- TransactionBuilder which should be used inTransaction.submitTransaction.
Example:#
// Create a TransactionBuilder objectconst transactionBuilder = await Transaction.getTransactionBuilder();getTxList#
- Get a list of transactions for given wallet address
This method is used to get a list of transactions for given wallet address
Parameters:#
- Â
<string>- wallet address - Â
<"to" | "from">- transaction type. it can only be 'to' or 'from' - Â
<number>- pagination. The defaul value is 1.
Results:#
- Â
Promise<ProcessedTxListResponseResult>- An instance ofProcessedTxListResponseResultcontaining the total count and transactions.
Example:#
const address = `fra000xxsr`;const type = "to";
// Get list of `to` transaction of given addressconst txDetail = await Transaction.getTxList(address, type);sendToAddress#
- Send some asset to an address
Using this function, user can transfer some amount of given asset to another address
Parameters:#
- Â
<WalletKeypar>- wallet keypair - Â
<string>- target wallet address - Â
<string>- amount to be sent - Â
<string>- asset code - Â
<AssetBlindRules>- (optional) confidential options for blind rule
Results:#
- Â
Promise<TransactionBuilder>- A TransactionBuilder which should be used in Transaction.submitTransaction
Example:#
const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);const toWalletInfo = await Keypair.restoreFromPrivateKey(toPkeyMine2, password);
const assetCode = await Asset.getFraAssetCode();
const assetBlindRules: Asset.AssetBlindRules = { isTypeBlind: false, isAmountBlind: false,};
const transactionBuilder = await Transaction.sendToAddress( walletInfo, toWalletInfo.address, "2", assetCode, assetBlindRules);
const resultHandle = await Transaction.submitTransaction(transactionBuilder);sendToMany#
- Send some asset to multiple receivers
Using this function, user can transfer perform multiple transfers of the same asset to multiple receivers using different amounts
Parameters:#
- Â
<WalletKeypar>- wallet keypair - Â
<TransferReciever[]>- the list of target wallet addresses and amount - Â
<string>- asset code - Â
<AssetBlindRules>- (optional) confidential options for blind rule
Results:#
- Â
Promise<TransactionBuilder>- A TransactionBuilder which should be used in Transaction.submitTransaction
Example:#
const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);const toWalletInfoMine2 = await Keypair.restoreFromPrivateKey( toPkeyMine2, password);const toWalletInfoMine3 = await Keypair.restoreFromPrivateKey( toPkeyMine3, password);
const assetCode = await Asset.getFraAssetCode();
const assetBlindRules: Asset.AssetBlindRules = { isTypeBlind: false, isAmountBlind: false,};
const recieversInfo = [ { reciverWalletInfo: toWalletInfoMine2, amount: "2" }, { reciverWalletInfo: toWalletInfoMine3, amount: "3" },];
const transactionBuilder = await Transaction.sendToMany( walletInfo, recieversInfo, assetCode, assetBlindRules);
const resultHandle = await Transaction.submitTransaction(transactionBuilder);sendToPublicKey#
- Send some asset to a wallet by public key
Using this function, user can transfer some amount of given asset to another wallet by target's public key
Parameters:#
- Â
<WalletKeypar>- wallet keypair - Â
<string>- target's public key - Â
<string>- amount to be sent - Â
<string>- asset code - Â
<AssetBlindRules>- (optional) confidential options for blind rule
Results:#
- Â
Promise<TransactionBuilder>- A TransactionBuilder which should be used in Transaction.submitTransaction
Example:#
const walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);const toWalletPublicKey = `tgshauuy213`;
const assetCode = await Asset.getFraAssetCode();
const assetBlindRules: Asset.AssetBlindRules = { isTypeBlind: false, isAmountBlind: false,};
const transactionBuilder = await Transaction.sendToPublicKey( walletInfo, toWalletPublicKey, "2", assetCode, assetBlindRules);
const resultHandle = await Transaction.submitTransaction(transactionBuilder);submitTransaction#
- Submits a transaction
The next step after creating a transaction is submitting it to the ledger, and, as a response, we retrieve the transaction handle.
Parameters:#
- Â
<TransactionBuilder>- an instance ofTransactionBuilder
Results:#
- Â
Promise<string>- Transaction status handle
Example:#
onst walletInfo = await Keypair.restoreFromPrivateKey(pkey, password);
// First, we create a transaction builderconst assetBuilder = await Asset.defineAsset(walletInfo, assetCode);
// Then, we submit a transaction// If succcesful, the response of the submit transaction request will return a handle that can be used the query the status of the transaction.const handle = await Transaction.submitTransaction(assetBuilder);Helpers#
getBlockTime#
- Get Block Time by given block height.
Using this function, user can get block time by given block height
Parameters:#
- Â
<number>- block height
Results:#
- Â
Promise<undefined | string>- Block time
Example:#
const blockHeight = 2341;// Get block time at Block #2341const blockTime = await helpers.getBlockTime(blockHeight);getTxListFromResponse#
- Get Transaction List by given transaction data response.
Using this function, user can Get Transaction List by given transaction data response
Parameters:#
- Â
<TxListDataResult>- transaction data response
Results:#
- Â
Promise<null | TxInfo[]>- transaction list
Example:#
const address = "fra12dsfew";const type = "to";const dataResult = await Network.getTxList(address, type);// Get tx listconst txList = await helpers.getTxListFromResponse();getTxOperationsList#
- Get Operation List by given parsed transaction
Using this function, user can Get Transaction List by given parsed transaction
Parameters:#
- Â
<ParsedTx>- parsed tx info
Results:#
- Â
TxOperation[]>- transaction operation list
Example:#
const address = "fra12dsfew";const type = "to";const dataResult = await Network.getTxList(address, type);// Get tx listconst txList = await helpers.getTxListFromResponse();// Get one parsed txparsedTx = JSON.parse(Base64.decode(txList[0].tx));// Get operation LsitopList = helpers.getTxOperationsList(parsedTx);