0

How do I list all Utxos that is in my script as well as the public key addresses that it came from.I am using the result as a parameter for a different function.I want to know if a public key address has already send a transaction to this script , if they have then do something , and if they have not then do something else.

2
  • Scripts do not spend utxos, transactions do. Do you mean all outputs that belong to the script at any given time?, including or excluding current unsuspended outputs? Mar 24, 2022 at 9:43
  • Yep, like outputs that belong to the script.
    – szhang9921
    Mar 26, 2022 at 0:12

1 Answer 1

1

sorry can you please be more specific?

what exactly do you mean "ist all Utxos that were consumed by my script " ?

do you need a list of UTXOs for a specific address? and additionally, do you need the address from the sender of this UTXOs?

if yes, please see below.

find all UTXOs

fullUtxo=/fullUtxo.out
myAddr=addr1qljkdlgamadjnlh8xmgxln4535kj5j3lgl9mawrr99nkrt2meqa2z
cardano-cli query utxo --address $myAddr --mainnet > $fullUtxo

find sender

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

if that helps you, would be great if you vote for my answer and give me some credits :)

have a nice day mate, pool operator for TTS17

4
  • Yep, i wanted a list of UTXOs for a specific address and the address from the sender of this UTXOs.How can i also get the amount of times an address has send UTXOs to a script.
    – szhang9921
    Mar 24, 2022 at 17:20
  • i dont understand what is your goal, because either i need to sell / send something to everyone for each transaction..... or i can send back tokens to many addresses ,who sent transactions, in the same transaction i send. - - - - if you want to know "how many times " of something, you can create a txt file with one line for each transaction and then execute this commands to find the number of lines "wc -l fileName.txt" -#-#-#-#-
    – TTS17
    Mar 24, 2022 at 17:58
  • I want to see how many times an address has send UTXOs to a script. I am going to use that value as parameters for the script. I want to create a logic like if this public address has send UTXOs to this script once before , something happens.
    – szhang9921
    Mar 26, 2022 at 0:11
  • like i said, i would add create a new file txt will all the tx you have currently "echo ${tx_in} >> $txsin" and better for your case, add tx there based on the sender....here you can see what i do, maybe related... if that helps you
    – TTS17
    Mar 27, 2022 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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