1

Is there away to retrieve the senders addresses of a transaction in cli commands, given the transaction hash? How do APIs (like blockfrost) get this data?

I know db-sync stores the data, but how does db-sync know in the first place about these details that are not directly retrievable from the ledger?

3 Answers 3

0

You would have to use cardano-db-sync - it is a service that stores ledger (chain) data into a more easy-to-work-with SQL structure. Otherwise, one would have to parse raw chain data (incredibly inefficient), which is why a framework like db-sync is so useful.

All the API's like Blockfrost or Cardanoscan use db-sync at backend to provide their services.

1
  • I am familiar with db-sync and APIs that provide services to provide users with more details than can be found in the ledger. But how does db-sync know this in the first place? since only the utxo hashes are available at the input of a transaction. I am currently using blockfrost, but with congestion it is my weak point and there are times it does not respond, which miss up my wor
    – Fourzin
    Commented Jan 31, 2022 at 15:59
0

With Cardano-cli you can only query your UtxOs to get the corresponding tx hash. Unfortunately, there is nothing to go deeper and get additional information.

I dont' understand what you mean by "are not directly retrievable from the ledger", but yes, db-sync has access to this information.

The purpose of Cardano DB Sync is to follow the Cardano chain and take information from the chain and an internally maintained copy of ledger state. Data is then extracted from the chain and inserted into a PostgreSQL database. SQL queries can then be written directly against the database schema or as queries embedded in any language with libraries for interacting with an SQL database.

However, you need some non negligible resource to run db-sync. What Blockfrost does is "just" to wrap a web API around the DB in order for everyone to get an easy access to it. Blockfrost is the easiest way to retrieve your sender address.

2
  • I am familiar with db-sync and APIs that provide services to provide users with more details than can be found in the ledger. But how does db-sync know this in the first place? since only the utxo hashes are available at the input of a transaction. I am currently using blockfrost, but with congestion it is my weak point and there are times it does not respond, which miss up my work
    – Fourzin
    Commented Jan 31, 2022 at 15:51
  • I don't know exactly how, but a transaction references the Utxo it consumes. This reference is made up of a Tx Hash and UtxO index (from a previous transaction). But, the referenced UtxO belongs to some address, so, somehow, you can get the sender. Commented Feb 1, 2022 at 21:16
0

like the other colleagues mentioned it is not possible from cli. what i would recommend is to

  1. create account in https://blockfrost.io/
  2. take a Project ID

and then "curl" info from the DB using the command below

curl -H 'project_id: Insert_here_youProject_ID'
https://cardano-mainnet.blockfrost.io/api/v0/txs/${tx_hash}/utxos
| jq '.inputs' | jq '.[0]' | jq '.address' | sed 's/^.//;s/.$//'

TX_Hash, you can receive it from

cardano-cli query utxo --address $myAddr --mainnet

3
  • I am familiar with db-sync and APIs that provide services to provide users with more details than can be found in the ledger. But how does db-sync know this in the first place? since only the utxo hashes are available at the input of a transaction. I am currently using blockfrost, but with congestion it is my weak point and there are times it does not respond, which miss up my work
    – Fourzin
    Commented Jan 31, 2022 at 15:53
  • i dont know if that here is clear for you. github.com/input-output-hk/cardano-db-sync - The purpose of Cardano DB Sync is to follow the Cardano chain and take information from the chain and an internally maintained copy of ledger state. Data is then extracted from the chain and inserted into a PostgreSQL database. SQL queries can then be written directly against the database schema or as queries embedded in any language with libraries for interacting with an SQL database. - i am learning also, and i read so many related infos here –
    – TTS17
    Commented Jan 31, 2022 at 17:38
  • Yeah I understand, I have been developing on Cardano for awhile now. I like most of the concepts but the fact that you cant get info of input and output addresses is frustrating. It would be much more robust for the ledger to include these info. I know main reason is size and all, but still. Anyways thank you a lot
    – Fourzin
    Commented Jan 31, 2022 at 17:50

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.