'Web3j how to get transaction status
I am using web3j to query the Ethereum blockchain. Now I want to check if a transaction was mined or just sent to the network. How can I achieve this?
Solution 1:[1]
As mentioned before, you can use web3.eth.getTransactionReceipt(hash [, callback])
It will return the object with status. It will be false for unsuccessful transactions.
Solution 2:[2]
/**
* ??hash??????????????success???fail???unknown
* @param hash
* @return
*/
public String txStatus(String hash){
if(StringUtils.isBlank(hash)) {
return STATUS_TX_UNKNOWN;
}
try {
EthGetTransactionReceipt resp = web3j.ethGetTransactionReceipt(hash).send();
if(resp.getTransactionReceipt().isPresent()) {
TransactionReceipt receipt = resp.getTransactionReceipt().get();
String status = StringUtils.equals(receipt.getStatus(), "0x1") ?
"success" : "fail";
return status;
}
}catch (Exception e){
log.info("txStatusFail {}", e.getMessage(), e);
}
return "hash_unknown";
}
Solution 3:[3]
The limit is not limited to the imports API, all HubSpot authenticated API calls count against it. Additionally the daily limit endpoint also counts against the daily limit.
If you think you're seeing that 429 response in error, contact HubSpot support. help.hubspot.com
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Roman Jukovskii |
| Solution 2 | |
| Solution 3 | TheWebTech |
