How can i get transaction information by hash

I user eth_getTransactionByHash and eth_getTransactionReceipt to get information, but the response do not have message like " From 0x6748f50f686bfbca6fe8ad62b22228b87f31ff2bTo 0x39db096e741b4991529e986530f601b13bb84859For 980 ($984.22) " , the response only have the from address, not have the to address and the number. Any one can help me?

2 Likes

Hi @liuminert can you provide us with the Transaction Hash you’re using when forming your request?

1 Like

0xc6eee520d8634c5426bd9f1040a8fc3dc3a4b0665d037bbae3e863b61e3bee0a

2 Likes

I user web3j to request.

1 Like

Hi @liuminert , for web3j, I’m looking at https://web3j.readthedocs.io/en/latest/transactions.html and seeing that you can get the Receipt if you have the transaction hash

Optional<TransactionReceipt> transactionReceipt = 
    web3j.ethGetTransactionReceipt(txHash).send().getTransactionReceipt();

Also, if you’re asking about the input data to a transaction, you can use web3j.ethGetTransactionByHash to get the transaction object as specified in the Ethereum JSON RPC specs (github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyhash). It includes an input variable.

1 Like

Thank you for your reply ! I transfer some usdt from one address to another address, i need the from address , to address and the transfer quantity. I tried it in two ways , eth_getTransactionReceipt and eth_getTransactionByHash, the from address is ok , the to address is contract address, there is No transfer quantity. How can i get the transfer quanity?

1 Like

In addition, i use eth_getBlockByHash to get the block, but the result is null. why is that?

1 Like

I have get the transfer result ,thank you for the help.
But eth_getBlockByHash still can’t work.

1 Like

Hi @liuminert can you provide your code where you are generating these requests and the full response you are receiving?

1 Like

Now there’s only one question , i use Postman to request , url is “https://mainnet.infura.io/v3/39bb15350b7e43338163d1e9ff618853”, body is “{“jsonrpc”:“2.0”, “id”:1, “method”:“eth_getBlockByHash”, “params”:[“0xc6eee520d8634c5426bd9f1040a8fc3dc3a4b0665d037bbae3e863b61e3bee0a”,false]}”, and the response is “{
“jsonrpc”: “2.0”,
“id”: 1,
“result”: null
}”

1 Like

A post was split to a new topic: How do you get hash for this request?

Hi @Sean_Infura ,
How do you get hash for this request? I have an app which use web3j, but I work with chain through contract wrappers. I just get a receipt when tx has been mined, I don’t see a way how to get receipt immediately to check its status later.

I am familiar with web3j.ethGetTransactionReceipt(hash) call, but don’t see a way to get a tx hash.

1 Like

hey, can you detail a little bit what you’re doing exactly ? When you send the tx the node will return the hash back as soon as it accepted it, there’s probably something that I’m missing here. Thanks !

1 Like

I have a self-made ethereum wallet which is encapsulated in the separate module. It is verified and tested. Now I am in process of integrating chain business logic with business logic off-chain. This brings some new requirements that force me to implement extra functional.
I have several use cases, but let’s say I want to mint a new token. I send a ‘mint token’ request and wait for it has been mined:

            logger.d("[start] mintToken() $to, $value, $uri")
            val txReceipt = swapValueContract.safeMint(to, value, uri).send()
            response = Response.Data<TransactionReceiptDomain>(txReceipt.toDomain())

Now I need to get tx receipt immediately and cache it. Web3j allows to get it by txhash, but I don’t have txhash either. In logs I see txHash is returned on POST request, but I do not see how I can obtain it in web3j , the interface I use to initiate the request is wait for txreceipt after mining.

1 Like

I think you do have transactionHash in the TransactionReceipt class, see Interacting with Smart Contracts - Web3j

Alternatively, you have also this way to send a tx to the smart contract with the data function encoded Transactions and Smart Contracts - Web3j

2 Likes