0

I am running my own geth node and doing some test transactions.

When making a transaction trough web3 I get an response of transaction information. But sometimes it happens that my node is not fully in sync so when I make a transaction from geth I get an empty response.

Since I want to save all the transaction hashes in my databas this is a problem.

How should I handle this kind of situation? Is there a way to get transaction hash from web3 anyway if this happens? I know geth shows it but it is not returned by web3..

1 Answer 1

1

If you are using web3 1.0 and trying to send a transaction to a contract. For example to make a tokens transfer and obtain the transaction hash you can do this:

token.methods.transfer(recipient, amount)
.send({ from: owner })
.on('transactionHash', function(hash){
    console.log(hash);
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.