I'm having trouble using the cardano-cli to send one tx. I have one address with 9 ADA and 10,000,000 each of two tokens with the same minting policy and I want to send 5,000,000 ADA of each token to a foreign address which has 10 ADA and no tokens.

For example

Address that has the native assets I want to send:

TxHash: 123456789123465

TxIx: 0

Amount: 9000000 lovelace + 10000000 1234567891234.token1 + 10000000 1234567891234.token2 + TxOutDatumHashNone

Address which I want to send native assets to:

TxHash: 123456789123456

TxIx: 0

Amount: 10000000

What commands/steps exactly are needed using the cardano-cli from here in order to accomplish sending 5,000,000 of each native token?

Thanks, Myles

  • 1
    First thing to note, you can only send to an address, not a txhash. Can you also provide what commands you've tried already and what error occurs when doing so? Commented Dec 17, 2021 at 2:20

1 Answer 1

#Send lovelace change to my address

# Build tx
cardano_cli transaction build \
--alonzo-era \
--tx-in $MY_UTXO_IN \
--tx-out $RECEPIENT_ADDR+9000000+"10000000 1234567891234.token1"+"10000000 1234567891234.token2") \
--change-address $CHANGE_ADDR \
--testnet-magic 1097911063 \
--out-file tx.build

If you have change in native tokens then you need to add another --tx-out to return to your address for example:

--tx-out $CHANGE_ADDR+1400000+"$TOKEN1_CHANGE 1234567891234.token1"+"$TOKEN2_CHANGE 1234567891234.token2"

Sign and submit

# Sign tx
echo "Sign Tx ..."
cardano_cli transaction sign \
--signing-key-file my_payment.skey \
--tx-body-file tx.build \
--out-file tx.sign
echo "Done."

# Submit tx
echo "Submiting Tx ..."
cardano-cli transaction submit --testnet-magic 1097911063 --tx-file tx.sign

Here you can find various examples for sending token and other stuff https://github.com/invictusappscom/cardano-terminal-wallet especially this script https://github.com/invictusappscom/cardano-terminal-wallet/blob/master/send-token.sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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