I am trying to sign a build & sign transaction then create a hex to broadcast the transaction on TRON Network.
I have successfully done this but when i broadcast this transaction i am getting "TRON TAPOS_ERROR" error. I have searched and got the reason that i have to include last block number and hash. check this : https://github.com/tronprotocol/java-tron/issues/857
But I don't know how to do this.
I have tried this code :
const CryptoUtils = require("@tronscan/client/src/utils/crypto");
const TransactionUtils = require("@tronscan/client/src/utils/transactionBuilder");
async function transferContractTx() {
const fromAddress = "FROM_ADDRESS";
const toAddress = "TO_ADDRESS";
const privateKey = "MY_PRIVATE_KEY";
const token = "TRX";
const amount = 1000000;
let transaction = TransactionUtils.buildTransferTransaction(token, fromAddress, toAddress, amount);
console.log(JSON.stringify(transaction));
let signedTransaction = CryptoUtils.signTransaction(privateKey, transaction);
console.log(signedTransaction);
}
transferContractTx();