1

Following the iohk guide to minting assets we identify the input utxo using the following command:

cardano-cli query utxo --address $address --testnet-magic 1097911063

This is all well and good if you know the address which you wish to query. However, if you are using wallet software (including cardano-wallet) you will find that the change behavior of wallets will move assets across addresses (but within the same wallet). As such, just because you sent ada to an address at one time does not mean you will find it there in the future if you have performed any transactions since sending it.

We'd like to know if anyone is aware of a better approach to identifying a source utxo for buildling an asset minting transaction when starting with a wallet rather than with an address and using the core standard toolset cardano-wallet, cardano-cli, cardano-address, etc

3 Answers 3

1

If you run this bash script, you will create a wallet, load it in cardano-wallet and get all the info you need, including the address you are needing. The script if going to create some files for the wallet in the same folder where you are running it.

I can show you also how to do it using only Cardano Cli if you want.

Firts, set this ENV variables for everything to work:

CARDANO_WALLET=rute to your cardano wallet folder 
CARDANO_WALLET_PORT=port used in the cardano wallet server (eg. 9091)
CARDANO_NODE=rute to your cardano node folder
NETWORK_WITH_MAGIC=testnet-magic 1097911063
#!/bin/bash

if [ -z "$1" ]; then
    echo "File name:"
    read file
else
  file=$1
fi

if [ -z "$2" ]; then
    echo "Name:"
    read name
else
  name=$2
fi

if [ -z "$3" ]; then
    echo "Passphrase (10 or more characters):"
    read passphrase
else
  passphrase=$3
fi

echo "Creating Wallet with name $name passphrase $passphrase in $file.json"

phrase=$($CARDANO_WALLET/cardano-wallet recovery-phrase generate)

x=''
sep=''
for word in $phrase
do
    x=$x$sep'"'$word'"'
    sep=', '
done

cat > $file.json <<- EOM
{ "name": "$name"
, "mnemonic_sentence": [$x]
, "passphrase": "$passphrase"
}
EOM

echo "Saved restoration file to $file.json"

echo $phrase | $CARDANO_WALLET/cardano-wallet key from-recovery-phrase Shelley > $file.root.prv

cat $file.root.prv | $CARDANO_WALLET/cardano-wallet key walletid > $file.id

wallet_Id=$(cat $file.id)

echo "Wallet ID:" $wallet_Id

curl -H "content-type: application/json" -XPOST \
  -d @$file.json \
  localhost:$CARDANO_WALLET_PORT/v2/wallets

echo ""

addresses=$(curl -H "content-type: application/json" \
      -XGET localhost:$CARDANO_WALLET_PORT/v2/wallets/$wallet_Id/addresses | jq -r '.[]' )

echo $addresses| jq -r '.id' >$file.addrs

echo "Wallet Addresses:"

echo $addresses| jq -r '.id' | nl 

address=$(echo $addresses| jq -r '.id'| sed -n 1p)

echo ""

echo "Firts Address:" $address

echo $address> $file.addr

echo "UTxOs At Address:"

$CARDANO_NODE/cardano-cli query utxo --address $address --$NETWORK_WITH_MAGIC 

I hope it helps!

0

for the first point / question, about finding the source address

i would do the follow,

create a "project in blockfrost :

blockfrost.io/

and then execute the commands below:

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

2
  • I appreciate your feedback, but using a third party service is not an option. We are interested in the low level details of how to do this using Cardano directly. Further, I think you've misunderstood our goals. We are not trying to determine the utxos related to a tx. We are trying to find a utxo to use as input to a minting tx.
    – melchoir55
    Feb 7, 2022 at 16:40
  • ok the "source" confused me. sorry for the misunderstanding. the only option i find for the "cardano-cli query utxo " is only --address.- then, sorry mate still dont have answer
    – TTS17
    Feb 7, 2022 at 17:48
-1

enter image description here

here is a list of subcommands of the cardano-wallet.

i didnt know you can do it from "wallet", but looks like you have this options.

transaction

create   

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.