for my demo I need the transaction hash instantly without waiting for callback of sync call. Here my code:
aggiungiAllaBlockChain: async(u,n,c,e) => {
try {
const web3 = new Web3(App.web3Provider);
const contract_PartecipazioneContest = new web3.eth.Contract(JSON.parse(App.ABI_PartecipazioneContest), App.ADDR_PartecipazioneContest);
const account = App.account;
//const receipt = await App.sendUserInBlockChain(web3, account, contract_PartecipazioneContest.methods.addUser(u, n, c, e));
const transaction = contract_PartecipazioneContest.methods.addUser(u, n, c, e);
value = 0;
const options = {
to : transaction._parent._address,
data : transaction.encodeABI(),
gas : await transaction.estimateGas({from: account.address, value: value}),
gasPrice: await web3.eth.getGasPrice(),
value : value
};
const signed = await web3.eth.accounts.signTransaction(options, account.privateKey);
const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction)
.on('transactionHash', function(hash){
console.log("hash on(transactionHash " + hash);
return hash;
});
} catch (error) {
console.log("errore Aggiungi utente alla blockchain" + error)
}
}
I print the hash of my transaction but the return value doesn't work.
I have got this result using truffle but now I need this following this path (not passing for meta mask)
Thanks a lot for your help.