Retrieving sender address from UTXO

I went with the blockfrost.io route. This is one of the utxo transaction details from blockfrost.io. How to identify which one is the sender’s address.

{
  "hash": 
  "52b38f6d08138406ac6346f753b2a9254f3bba2afe5d0971253304b633bd6a4b",
  "inputs": [
    {
      "address": 
"addr1qye0s7efe98gyd9jfrjqm0kmq96t6c9qlr8mjnfuk33ulne8jyyvzx6mjrlcv80q8a22rn3decgx47km3vj4ycdyhc2q8sh6dm",
      "amount": [
        {
          "unit": "lovelace",
          "quantity": "1600000"
        },
        {
          "unit": "086c2ccb567991202a3e3bdc8c9f70567e54ad9cf2faff511cf99516526f79616c204772616e6420233030303033",
          "quantity": "1"
        }
      ],
      "tx_hash": 
 "24b908309ec54bfff9cbcc7283702b2c49b8ae41bc11aba028dbbda269cab77f",
      "output_index": 0,
      "collateral": false,
      "data_hash": null
    },
    {
      "address": "addr1qyp2llre84lxf4t7drnfm47ya2ws8lvmz4fnnf0lpxzanf38jyyvzx6mjrlcv80q8a22rn3decgx47km3vj4ycdyhc2q2c0rav",
      "amount": [
        {
          "unit": "lovelace",
          "quantity": "3038915"
        }
      ],
      "tx_hash": "b974db46c369d78291b06b2add8c2fa61016b0532730778b0f02dbf60184fd6d",
      "output_index": 1,
      "collateral": false,
      "data_hash": null
    }
  ],
  "outputs": [
    {
      "address": "addr1v8cwarljkvlwmwdegq5s0nkaut5jtvrs8u0ugph3243pr9ge9ksyt",
      "amount": [
        {
          "unit": "lovelace",
          "quantity": "2000000"
        }
      ],
      "output_index": 0,
      "data_hash": null
    },
    {
      "address": "addr1q9t7cyqgmkxqe8aag0ds8ag49d4jpf94ukr4kajtg0ffm038jyyvzx6mjrlcv80q8a22rn3decgx47km3vj4ycdyhc2qspfgvv",
      "amount": [
        {
          "unit": "lovelace",
          "quantity": "2463514"
        },
        {
          "unit": "086c2ccb567991202a3e3bdc8c9f70567e54ad9cf2faff511cf99516526f79616c204772616e6420233030303033",
          "quantity": "1"
        }
      ],
      "output_index": 1,
      "data_hash": null
    }
  ]
}

you can find the answer here

Hi @Alexd1985,
Thank you. I’m doing it programmatically to identify who send the transaction and I need to send them back the Token. One of the option is to go with blackfrost.io to retrieve the UTXO transaction using this API endpoint, “https://cardano-mainnet.blockfrost.io/api/v0/txs/{hash}/utxos”. There are two different addresses from the above response JSON for the “input”. Would like an confirmation that, can I assume that the first address in the “inputs” is the sender’s address. Is there any other way to find the sender’s address from utxo transaction hash would also be useful.

Hello, I have been trying to do the same thing. If you run the cardano-db -sync you can find the input address if you have an output UTxO using the query → select tx_out.address from tx_out inner join tx on tx_out.tx_id = tx.id where tx.hash = '\x526b62e36794a138d91932970b473672a4444bacf1a38f558bd0cd270a40e85' ;

I got this from cardano-db-sync/interesting-queries.md at master · input-output-hk/cardano-db-sync · GitHub (scroll down to the section “Transaction inputs for specified transaction hash:” cardano-db-sync/interesting-queries.md at master · input-output-hk/cardano-db-sync · GitHub)

I find cardano-db-sync an awesome tool, even though a little tricky to setup, but its worth the effort as once you have it up and running, you have your very own cardano explorer, which is simple awesome. Hope this can help, Simon

It’s an old question, but anyway: Regardless if you use Blockfrost, cardano-db-sync, or Cardanoscan, you will always find two inputs for that transaction and you simply cannot decide, which of the two is “the” sender.

Both have contributed to the transaction, both have to have signed the transaction, and – most probably – both are just different addresses from the same wallet. (You can build transactions using inputs from different wallets and let them sign by different people, but that will be very rare and standard wallet apps do not offer that.)

If you want to return tokens, your best bet is to look at the inputs in detail and send them back to exactly the address they came from.