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?
Hi @liuminert can you provide us with the Transaction Hash youâre using when forming your request?
0xc6eee520d8634c5426bd9f1040a8fc3dc3a4b0665d037bbae3e863b61e3bee0a
I user web3j to request.
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.
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?
In addition, i use eth_getBlockByHash to get the block, but the result is null. why is that?
I have get the transfer result ,thank you for the help.
But eth_getBlockByHash still canât work.
Hi @liuminert can you provide your code where you are generating these requests and the full response you are receiving?
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
}â
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.
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 !
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.
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