[SOLVED] Can't send native tokens to a wallet and ADA+Tokens to another

Hey guys, i’m kinda new to all this and i’m having the following issue:

I’ve got this wallet:

$ cardano-cli query utxo --address $(cat payment.addr ) --mainnet
                           TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------
9fd27cf74cc30982fc927d1c60e6523cutxoutxoutxo1d0aacb71d330c5e542e     0        4810211 lovelace + 1000001 38149ef0f3886ffedpolicyidpolicyid9243c3dc0b76e0a1ef37662.TokenName + TxOutDatumHashNone

I’m trying to send away 1000000 TokenName and keep 1 and the resulting change.

So i’ve done this:

utxo=4810211
txin=9fd27cf74cc30982fc927d1c60e6523cutxoutxoutxo1d0aacb71d330c5e542e
txix=0
expire=$(( $(cardano-cli query tip --mainnet | jq -r '.slot') + 1800 ))
cardano-cli transaction build-raw \
        --fee 10000 \
        --tx-in "$txin#$txix" \
        --tx-out "$(cat tokens.addr)+1000000 $(cat policy/tokens/policy.id).TokenName" \
        --tx-out "$(cat payment.addr)+$((utxo-fee))+1 $(cat policy/tokens/policy.id).TokenName" \
        --invalid-hereafter $expire \
        --out-file token_tx.raw

then i calculate the fee, considering there’s just one txin and two tx-outs.

    fee=( $(cardano-cli transaction calculate-min-fee \
    --tx-body-file token_tx.raw \
    --tx-in-count 1 \
    --tx-out-count 2 \
    --witness-count 2 \
    --protocol-params-file protocol.json) )

Then i rebuild the transaction:

cardano-cli transaction build-raw \
        --fee ${fee[0]} \
        --tx-in "$txin#$txix" \
        --tx-out "$(cat tokens.addr)+1000000 $(cat policy/tokens/policy.id).TokenName" \
        --tx-out "$(cat payment.addr)+$((utxo-fee))+1 $(cat policy/tokens/policy.id).TokenName" \
        --invalid-hereafter $expire \
        --out-file token_tx.raw

Then i sign it and sumit:

cardano-cli transaction sign \
        --signing-key-file payment.skey \
        --mainnet \
        --tx-body-file token_tx.raw \
        --out-file token_tx.signed

cardano-cli transaction submit \
        --tx-file token_tx.signed \
        --mainnet

And i get the following error:

Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (OutputTooSmallUTxO [(Addr Mainnet (KeyHashObj (KeyHash "<somehash>")) (StakeRefBase (KeyHashObj (KeyHash "<another hash>"))),Value 0 (fromList [(PolicyID {policyID = ScriptHash "<script hash>"},fromList [("TokenName",1000000)])]),SNothing)])))])

I have simply NO IDEA what i’m doing wrong. Any ideas?

I also couldn’t transfer the tokens while minting. This is what i tried:

fee=( 0 )
    cardano-cli transaction build-raw \
        --fee ${fee[0]} \
        --tx-in "$txin#$txix" \
        --tx-out "$(cat payment.addr)+0+1 $(cat policy/tokens/policy.id).TokenName" \
        --tx-out "$(cat tokens.addr)+$token_quantity $(cat policy/tokens/policy.id).TokenName" \
        --mint "$(($token_quantity+1)) $(cat policy/tokens/policy.id).TokenName" \
        --minting-script-file policy/tokens/token_policy.script \
        --metadata-json-file policy/tokens/token_meta.json \
        --out-file token_tx.raw 

and then calculated fees for 1 txin and two tx-outs.

Hi @atcasanova welcome to the community.

When sending native tokens you always need to include some ADA. As per the protocol rules it is not possible to have only non-ADA tokens being part of a UTXO. There must always be some ADA.

Please see following links:

Token deposit:
https://github.com/Emurgo/yoroi-frontend/blob/0038bc0afc5066904c59f376bef56c5e8581c4f7/docs/readme/cardano-token-deposit-explained.md

Minimum ADA requirement:
https://docs.cardano.org/native-tokens/minimum-ada-value-requirement

Online min ADA calculator:
https://mantis.functionally.io/how-to/min-ada-value/

2 Likes

Thanks, that was precisely the issue.

1 Like

Glad you resolved it. Please mark the question as resolved so others can find the solution easier.

I found no option to do this. Is it enough to edit the title?

You can just mark the answer as “solution” like in the image below. No worries if you can’t find it.
solution

1 Like