I am using Truffle Contract to call a Smart Contract method that writes to the ethereum blockchain. My web3 client is connected to my own Open Ethereum node. Below is the code (nodejs) that I am using to send the transaction to blockchain. I would expect, since this is an asynchronous call that the response would be immediately and the transaction hash value would be returned. However, this is NOT happening. The only time I get a response is after the transaction is mined. I can't rely on this because my front-end client will time out (30 secs for AWS API Gateway). What am I doing wrong? I can see all the eth_getTransactionReceipt json calls in my OE log, being called back to back until the transaction is mined.
async function sendTransClaimProperty(_instance) {
var result;
try {
result = await web3.eth.personal.unlockAccount(web3.eth.defaultAccount, process.env.oranges, null);
console.log(web3.eth.defaultAccount + " Account UnLocked", result);
if (result) {
var claimState = "Property Claimed on " + new Date();
console.log("Calling Ethereum Node at " + new Date());
result = await _instance.claimProperty.sendTransaction(claimTitle,claimHash,claimTime,claimCreditCardTx,claimClientIP,claimState);
console.log("Return from Ethereum Node result", result);
console.log("Return from Ethereum Node. TX", result.tx);
return { response: "OK", transHash: result.tx };
}
}
catch (error) {
console.log("Error Sending Transaction");
console.log(error.message);
return { response: "FAIL", message: "Error claiming property " + error.message };
}
}