#Get protocol parameters
cardano-cli shelley query protocol-parameters \
--testnet-magic 1097911063 \
--allegra-era \
--out-file protocol.json
#Get the transaction hash and index of the UTXO to spend
cardano-cli shelley query utxo \
--address $(cat payment.addr) \
--testnet-magic 1097911063 \
--allegra-era
Output:

#Draft the transaction
cardano-cli shelley transaction build-raw \
--tx-in 03ed78363f5d715302d84bbc79cfcdd7a7e92eaa1511a8ed87e45b2b07c5713e#0 \
--tx-out $(cat payment.addr)+0 \
--ttl 0 \
--fee 0 \
--out-file tx.draft
TxId = transaction hash
TxIx = transaction index
tx-out = TxOut+Lovelace
TxOut = hex encoded address
Lovelace = Amount of ADA*1000000
#Calculate the fee
cardano-cli shelley transaction calculate-min-fee \
--tx-body-file tx.draft \
--tx-in-count 1 \
--tx-out-count 2 \
--witness-count 1 \
--byron-witness-count 0 \
--testnet-magic 1097911063 \
--protocol-params-file protocol.json
Output:
175621
#Calculate the change to send back to payment.addr
expr <UTXO BALANCE> - <AMOUNT TO SEND> - <TRANSACTION FEE>
//Exmaple
expr 497628430 - 497452809 - 175621
#Determine the TTL (time to Live) for the transaction
– TTL = slotNo + N slots
– N = Amount of slots you want to add to give the transaction a window to be included in a block
currentSlot=$(cardano-cli query tip --testnet-magic 1097911063 | jq -r '.slotNo')
echo Current Slot: $currentSlot
updated_currentSlot=$(($currentSlot+1000))
echo Updated Slot: $updated_currentSlot
#Build the transaction
cardano-cli shelley transaction build-raw \
--tx-in 03ed78363f5d715302d84bbc79cfcdd7a7e92eaa1511a8ed87e45b2b07c5713e#0 \
--tx-out $(cat payment.addr)+497452809 \
--ttl 14689800 \
--fee 175621 \
--out-file tx.raw
#Build transaction2
cardano-cli shelley transaction build-raw \
--tx-in 03ed78363f5d715302d84bbc79cfcdd7a7e92eaa1511a8ed87e45b2b07c5713e#0 \
--tx-out $(cat payment2.addr)+100000000 \
--tx-out $(cat payment.addr)+397454217 \
--ttl 14689800 \
--fee 175621 \
--out-file tx.raw
-payment.addr = FROM address
-payment2.addr = TO address
#Sign the transaction
cardano-cli shelley transaction sign \
--tx-body-file tx.raw \
--signing-key-file payment.skey \
--signing-key-file node.skey \
--testnet-magic 1097911063 \
--out-file tx.signed
#Submit the transaction
cardano-cli shelley transaction submit \
--tx-file tx.signed \
--testnet-magic 1097911063
#Check the balances
cardano-cli shelley query utxo \
--address $(cat payment.addr) \
--testnet-magic 1097911063 \
--allegra-era
References :
https://docs.cardano.org/projects/cardano-node/en/1.18.0/reference/transactions.html
https://docs.cardano.org/projects/cardano-node/en/latest/stake-pool-operations/simple_transaction.html