<p>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.</p>
<p>I can show you also how to do it using only Cardano Cli if you want.</p>
<p>Firts, set this ENV variables for everything to work:</p>
<pre><code>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
</code></pre>
<pre><code>#!/bin/bash

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

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

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

echo &quot;Creating Wallet with name $name passphrase $passphrase in $file.json&quot;

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

x=''
sep=''
for word in $phrase
do
    x=$x$sep'&quot;'$word'&quot;'
    sep=', '
done

cat &gt; $file.json &lt;&lt;- EOM
{ &quot;name&quot;: &quot;$name&quot;
, &quot;mnemonic_sentence&quot;: [$x]
, &quot;passphrase&quot;: &quot;$passphrase&quot;
}
EOM

echo &quot;Saved restoration file to $file.json&quot;

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

cat $file.root.prv | $CARDANO_WALLET/cardano-wallet key walletid &gt; $file.id

wallet_Id=$(cat $file.id)

echo &quot;Wallet ID:&quot; $wallet_Id

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

echo &quot;&quot;

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

echo $addresses| jq -r '.id' &gt;$file.addrs

echo &quot;Wallet Addresses:&quot;

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

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

echo &quot;&quot;

echo &quot;Firts Address:&quot; $address

echo $address&gt; $file.addr

echo &quot;UTxOs At Address:&quot;

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

</code></pre>
<p>I hope it helps!</p>

CC BY-SA 4.0
2023-03-04T23:41:48.620Z
2023-03-04T23:41:48.620Z
Manu Padilla
<p>for the first point / question, about finding the source address</p>
<p>i would do the follow,</p>
<p>create a &quot;project in blockfrost :</p>
<p>blockfrost.io/</p>
<p>and then execute the commands below:</p>
<p>curl -H 'project_id: type_blockfrost_Project_ID' <br />
<a href="https://cardano-mainnet.blockfrost.io/api/v0/txs/$%7Btx_hash%7D/utxos" rel="nofollow noreferrer">https://cardano-mainnet.blockfrost.io/api/v0/txs/${tx_hash}/utxos</a> <br />
| jq '.inputs' | jq '.[0]' | jq '.address' | sed 's/^.//;s/.$//'</p>

CC BY-SA 4.0
2022-02-07T16:40:24.263Z
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
CC BY-SA 4.0
2022-02-07T17:48:03.170Z
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
CC BY-SA 4.0
2022-02-07T15:32:36.853Z
2022-02-07T15:32:36.853Z
TTS17
<p><a href="https://i.sstatic.net/Vhm82.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Vhm82.png" alt="enter image description here" /></a></p>
<p>here is a list of subcommands of the cardano-wallet.</p>
<p>i didnt know you can do it from &quot;wallet&quot;,
but looks like you have this options.</p>
<p>transaction</p>
<pre><code>create   
</code></pre>

CC BY-SA 4.0
2022-02-07T15:29:45.797Z
2022-02-07T15:29:45.797Z
TTS17
<p>Following the <a href="https://developers.cardano.org/docs/native-tokens/minting/" rel="nofollow noreferrer">iohk guide to minting assets</a> we identify the input utxo using the following command:</p>
<pre><code>cardano-cli query utxo --address $address --testnet-magic 1097911063
</code></pre>
<p>This is all well and good if you know the address which you wish to query. However, if you are using wallet software (including <code>cardano-wallet</code>) 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.</p>
<p>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 <code>cardano-wallet</code>, <code>cardano-cli</code>, <code>cardano-address</code>, etc</p>

<wallet><cardano-cli><native-assets><minting>
How to figure out what address to query for utxos when minting
# How to figure out what address to query for utxos when minting

(Asked by: username_0 on 2022-02-07)

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

**Tags:** wallet, cardano-cli, native-assets, minting

---

## 3 answers

### Answer by username_1 on 2023-03-04. Score: 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!


---

### Answer by username_2 on 2022-02-07. Score: 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](https://cardano-mainnet.blockfrost.io/api/v0/txs/$%7Btx_hash%7D/utxos)   
| jq '.inputs' | jq '.[0]' | jq '.address' | sed 's/^.//;s/.$//'

> **Comments:**
> **username_0**: 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.  
> **username_2**: 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  

---

### Answer by username_2 on 2022-02-07. Score: -1

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


---

