I am working on a Fuel blockchain project where I need to send transactions to an already deployed contract. My goal is to retrieve the Transaction ID before the transaction is sent, without using await
. This is to check the transaction status (success or failure) asynchronously.
I am following the Fuel documentation, but the provided examples focus on deploying new contracts, whereas I am interacting with an existing contract.
for (let i = 0; i < transactionsPerAccount * accounts.length; i++) {
const accountIndex = i % accounts.length;
const account = accounts[accountIndex];
const userWallet = Wallet.fromPrivateKey(account.privateKey, provider);
try {
await delay(20); // Simulate delay between transactions
const contract = new LyncIgnite(contractAddress, userWallet);
contract.functions.hit("1").call();
console.log(
`Transaction ${i + 1} processed successfully by account ${
userWallet.address
}. Transaction ID: ${txn.transactionId}`
);
} catch (txError) {
console.error(
`Error processing transaction for account ${userWallet.address}:`,
txError
);
console.log("Added failed transaction to retry queue.");
}
}
- How can I retrieve the Transaction ID immediately before sending the transaction without using
await
? - Is there any method or API available in the Fuel SDK to interact with a deployed contract and get a transaction’s ID synchronously?
- How can I later verify the success or failure of the transaction once the ID is retrieved?