1

I am trying to retrieve the transaction details like status and data using the operation hash in taquito.

What I want to achieve is basically take the op hash as user input and retrieve the details and status, something that taquito is already doing(when I perform a transaction, it can confirm the status).

2 Answers 2

1

If you want to do it with Taquito, the confirmation method on the operation object returns a promise with different information like the block, the status, etc. You can also use confirmationObservable to get the same information with an observable.
For more detailed information, you will have to use an indexer like Better Call Dev (although Taquito is working at integrating indexers so it should be available directly from Taquito in a near future!)

4
  • Okay so it is not possible to just take the tx-hash and get the tx details without an indexer in taquito? Also one more question is it possible to query the /chains/main/blocks/<id>/operations/<id> rpc endpoint with taquito? Oct 6, 2020 at 7:43
  • You do get details about the transaction with Taquito like the hash, the status, the block, etc. but if you want specific details like the gas fee, you have to use an indexer. Taquito doesn't have a feature to query RPC endpoints from the RPC client in this way because you can easily do it with fetch. You can retrieve the current RPC URL with getRpcUrl and append the parameters to it. Oct 6, 2020 at 8:02
  • Can you point me to the doc or code snippet that shows how I can retrieve the status, hash and block with taquito? I know I can get the operation details when I do a contract invocation and then get the operation object, but I couldn't find a way to directly create an operation object(using op-hash) without performing an actual tx. Oct 6, 2020 at 8:59
  • 1
    You cannot get information about any operation with its hash using Taquito, that's the job of an indexer, Taquito only gives you details about the operation you emitted with Taquito itself. Oct 6, 2020 at 10:16
0

We can retrieve transaction details using operation hash in Taquito. Hope the below code will be useful.

const rpc = require('@taquito/rpc').RpcClient;
const client = new rpc("TEZOS NODE RPC URL", "CHAIN ID of the TEZOS NODE");
const getTransaction = async function(opHash){
    const presentBlock = await client.getBlock();
    const hashValue = presentBlock.hash;
    for(let i = 1; i <= presentBlock.header.level; i++){
        let block = await client.getBlock({
            block   :   hashValue + '~' + i
        });
        block.operations.forEach(opArray => {
            if(opArray.length){
                opArray.forEach(opObj => {
                    if(opObj.hash == opHash){
                        console.log(opObj); break;
                    }
                });
            }
        });
    }
}

Basically, I am iterating all blocks synced by my tezos node. If you feel there are numerate blocks, then you can give start block and end block as limits and improve the code. Thanks. @claude-barde correct me if I am wrong.

1
  • This answer doesn't really fit because my question mentions that I have the op hash and no other details like block number. This is not an efficient solution in such cases, using the indexer is the right way to go. Dec 4, 2021 at 2:58

Your Answer

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

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