Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command failed: transaction build Error: Non-Ada assets are unbalanced (testnet) #3799

Closed
HT-Moh opened this issue Apr 17, 2022 · 3 comments
Closed
Labels
type: not a bug Triaging concludes it is not a bug user type: external Created by an external user

Comments

@HT-Moh
Copy link

HT-Moh commented Apr 17, 2022

I am trying to mint NFT with the same commands that worked before successfully, but now I am getting Command failed: transaction build Error: Non-Ada assets are unbalanced:

cardano-cli query utxo --address $(cat $ADDRESS) --testnet-magic 1097911063 --out-file utxo-1.json
# Get utxo 0
TXIN=$(jq -r 'keys[0]' utxo-1.json)
# Get lovelace value
LOVELACE_TXIN=$(jq -r ".[\"$TXIN\"].value.lovelace" utxo-1.json)
# output lovelace (it should be smaller as than utxo value)
LOVELACE_TXIN_DV3=$(expr $LOVELACE_TXIN / 3)
# Sot number 100000 slot in the future to give time for our NFT to be minted 
SLOTNUMBER=$(expr $(cardano-cli query tip --testnet-magic 1097911063 | jq .slot) + 100000)
# Generate hash using the policy verification key, this will be used in the minting policy
export KEYHASH=$(cardano-cli address key-hash --payment-verification-key-file $VKEY)
# script name 
SCRIPT=policy.script

cat << EOF > $SCRIPT
{
  "type": "all",
  "scripts":
  [
   {
     "type": "before",
     "slot": $SLOTNUMBER
   },
   {
     "type": "sig",
     "keyHash": "$KEYHASH"
   }
  ]
}
EOF
# Script policy ID
POLICICYID=$(cardano-cli transaction policyid --script-file $SCRIPT)
# Asset/NFT name 
export ASSET_NAME="TEST02"
# Encode Asset name to HEX
export ASSET_ENC=$(echo -n $ASSET_NAME | basenc --base16 | awk '{print tolower($0)}')
echo "Asset name '$ASSET_NAME' encoded as base16: '$ASSET_ENC'"

cardano-cli transaction build \
--testnet-magic 1097911063 \
--alonzo-era  \
--tx-in $TXIN \
--tx-out $(cat $ADDRESS)+$LOVELACE_TXIN_DV3+"$TOKENAMOUNT $NFT" \
--change-address $(cat $ADDRESS) \
--mint="$TOKENAMOUNT $SUBJECT" \
--minting-script-file $SCRIPT \
--metadata-json-file $METAFILE  \
--invalid-hereafter $SLOTNUMBER \
--witness-override 2 \
--out-file matx.raw

Error
Command failed: transaction build Error: Non-Ada assets are unbalanced: 221670712 lovelace + 1 286bcf642f7db2247af480fda886c5e783a226c4ac5f316b63464f46.43435954 + 1 39df0587057f77075064fcea7c262d16ac50dc0283f2f1f9e82ebdd9.43727970746f20436174616c797374202d2041444120506f6f6c

I am using the first utxo
image

Versions:

cardano-cli 1.34.1 - linux-aarch64 - ghc-8.10
git rev 73f9a746362695dc2cb63ba757fbcabb81733d23
cardano-node 1.34.1 - linux-aarch64 - ghc-8.10
git rev bf8b0e1cebe9decfa6ca0b98c7513e8dd64b8333
@HT-Moh HT-Moh added the bug Something isn't working label Apr 17, 2022
@HT-Moh
Copy link
Author

HT-Moh commented Apr 17, 2022

Ok I needed to put the already existing NFT on tx output.
My question is, I thought this is automated once I specify the change address? I should get back whatever exists on the UTXO (ADA change and TOKEN change)

image

@dorin100
Copy link

| I thought this is automated once I specify the change address

there is a feature request we have on our backlog for adding this functionality - #3068

@dorin100
Copy link

could we close this issue and keep only the above one?

@HT-Moh HT-Moh closed this as completed Apr 19, 2022
@dorin100 dorin100 added type: not a bug Triaging concludes it is not a bug user type: external Created by an external user and removed bug Something isn't working labels Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: not a bug Triaging concludes it is not a bug user type: external Created by an external user
Projects
None yet
Development

No branches or pull requests

2 participants