Algorand
Sign Transaction
The DCENT Web SDK provides functions for signing transaction of coins.
getAlgorandSignedTransaction()
Supported Coin Type
- ALGORAND
- ALGORAND_ASSET
- ALGORAND_APP
- ALGORAND_TESTNET
- ALGORAND_ASSET_TESTNET
- ALGORAND_APP_TESTNET
Parameters
- unsignedTx: unsigned hexadecimal tx Algorand Developer Transaction Reference Docs
- path: key path, wallet sign with that private key with a given key path (BIP32 ex) "m/44'/283'/0'/0/0").
- fee: fee, It is fee that wallet displays on the screen.
- symbol: symbol, It is a symbol that the wallet displays on the screen.
- decimals: algorand or algorand token's decimals.
- optionParam: hexadecimal value of the algorand method type is used only in algorand token.
- '00' : ALGORAND Transfer
- '01' : ALGORAND ASSET Transfer
- '02' : ALGORAND ASSET OPTIN
- '03' : ALGORAND APP Contract call
- '04' : ALGORAND APP OPTIN
- '05' : ALGORAND ASSET FT Create
- '06' : ALGORAND ASSET NFT Create
Requirements
DCENT Bridgeversion 1.5.2 or higher is required.- DCENT Biometric Wallet version 2.29.1 or higher is required.
Usage
import algosdk from 'algosdk'
const algodClient = new algosdk.Algodv2('', 'https://mainnet-api.algonode.cloud', '')
const indexerClient = new algosdk.Indexer('', 'https://mainnet-idx.algonode.cloud', '')
// An account for Algorand should keep cost for maintaining the account.
const balanceInfo = await algodClient.accountInformation(walletAddress).do()
const balance = balanceInfo.amount.toString()
const maintenance = balanceInfo['min-balance'].toString()
// Make a transaction
const suggestedParams = await algodClient.getTransactionParams().do()
const tx = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
suggestedParams,
from: walletAddress,
to: someWhere,
amount: value, // Unit is microAlgos
memo: new Uint8Array(Buffer.from('Something what you want', 'hex')) || undefined
})
// Create JSON-formatted data for getting a signature
const unsignedRawData = Uint8ArrayToHex(tx.bytesToSign())
const sigHash = unsignedRawData
const transactionJson = {
coinType: DcentWebConnector.coinType.ALGORAND,
sigHash: unsignedRawData,
path: `m/44'/283'/0'/0/0`,
decimals: 6, // for ALGORAND
fee: tx.fee,
symbol: 'ALGO',
optionParam: '00'
}
var result
try {
result = await DcentWebConnector.getAlgorandSignedTransaction(transactionJson);
} catch (e) {
console.log(e)
result = e
}
Returned response object
{
"header": {
"version": "1.0",
"response_from": "algorand",
"status": "success"
},
"body": {
"command": "transaction",
"parameter": {
"signed_tx": "31aa13b5e04cb6fc6381ea0520bf7f6727ebdb6e96cd7ca8625bb3e3dd36cf0e2cee4ece13aa9f7ddc09ee10c74aa00af954201829d8016317f10f5a921dcc0d"
}
}
}