3

i am looking so long, but till now didnt find a complete answer about : how to send a token / asset from cardano-cli. can you please help me to go in details about build the transaction from the CLI ?

  1. cardano-cli transaction build-raw \
  2. cardano-cli transaction calculate-min-fee
  3. cardano-cli transaction build-raw
  4. cardano-cli transaction sign
  5. cardano-cli transaction submit

is the steps correct in high Level? can we go in details to write the commands?

thank you in advanced, Thomas theTokenSquare17

3 Answers 3

2

The tx-out of the build-raw command is the only thing that is different for sending assets. Instead of address+1000000 it will be address+"1000000 + 5 <policy id><<asset name>"

2

The only difference between building a regular ADA-only transaction and one that contains ADA + asset(s) is in the cardano-cli transaction build-raw step that follows the multi-asset syntax as discussed in the official cardano documentation

It would look something along the lines of:

cardano-cli transaction build-raw \
--tx-in <TX_ID> \
--fee <FEE> \
--tx-out <ADDRESS+LOVELACE+"NUMBER_OF_TOKEN(s) POLICYID" \
--out-file tx.raw

Note that in the --tx-out step, LOVELACE should be an integer value, and "NUMBER_OF_TOKEN(s) POLICYID" should all be a string.

The rest of the steps for caluclating min fees and signing/submitting should be the same.

0

thank you so much for the link, it was exactly what i needed and yes, it is righ. used it, tested and worked

cardano-cli transaction build-raw
--fee 0
--tx-in ${tx_in}
--tx-in ${my_tx_in}
--tx-out ${in_addr}+${amountToSendUser}+"1 ${myToken}"
--tx-out ${paymentAddr}+${amountToDonate}+"999 ${myToken}"
--invalid-hereafter $FINALTIP
--out-file tx.draft

fee=$(cardano-cli transaction calculate-min-fee
--tx-body-file tx.draft
--tx-in-count ${TXNS}
--tx-out-count 2
--witness-count 3
--mainnet
--protocol-params-file protocol.json

cardano-cli transaction build-raw
--fee ${fee}
--tx-in ${tx_in}
--tx-in ${my_tx_in}
--tx-out ${in_addr}+${amountToSendUser}+"1 ${myToken}"
--tx-out ${paymentAddr}+${amountToReturn}+"999 ${myToken}"
--invalid-hereafter $FINALTIP
--out-file tx.raw

cardano-cli transaction sign
--signing-key-file $paymentSignKeyPath
--tx-body-file tx.raw
--out-file tx.signed
--mainnet

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

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.