Algorand
Last updated
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 blanace = balanceInfo.amount.toString()
const maintenance = balaceInfo['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 = rawData
const transactionJson = {
coinType: DcentWebConnector.coinType.ALGORAND,
sigHash: unsignedRawData,
path: `m/44'/283'/0'/0/0`,
decimals: 6, // for ALGORAND
fee: tx.fee,
symbol: 'ALGO',
optionParams: '00'
}
var result
try {
result = await DcentWebConnector.getAlgorandSignedTransaction(transactionJson);
} catch (e) {
console.log(e)
result = e
}{
"header": {
"version": "1.0",
"response_from": "algorand",
"status": "success"
},
"body": {
"command": "transaction",
"parameter": {
"signed_tx": "31aa13b5e04cb6fc6381ea0520bf7f6727ebdb6e96cd7ca8625bb3e3dd36cf0e2cee4ece13aa9f7ddc09ee10c74aa00af954201829d8016317f10f5a921dcc0d"
}
}
}