This documentation explains how to perform a basic transaction in Cardano. For example, if you want to send some ADA to another address from the wallet address generated earlier. Follow the steps below:
If you haven't generated a wallet address, you should follow this documentation first.
Hint: If you have choosen the network, you can skip this step
network="testnet-magic 1"
or
network="testnet-magic 2"
or
network="mainnet"
The following is a table regarding the network on Cardano
cli Parameter | Network Name |
---|---|
testnet-magic 1 | Preprod |
testnet-magic 2 | Preview |
mainnet | Mainnet |
Step-3 Initiate the Input: Transaction Hash (TxHash) and Transaction Index (TxIx) from Wallet Address (Sender)
Hint: Assuming you already have a Wallet Address
cardano-cli query utxo \
--address $myAddress \
--$network
Example Result:
TxHash TxIx Amount
--------------------------------------------------------------------------------------
62c0ce8d6e0b584e9e263e3ba076f53c23095ebd0a9198305819cfa5ecef8e81 0 1000000000 lovelace + TxOutDatumNone
Note: Each transaction can have one or multiple inputs, and one or multiple outputs
Single Input:
utxo="COPY THE TX-HASH HERE#COPY THE TX-IX NUMBER HERE"
Multiple Input:
utxo1="COPY THE TX-HASH1 HERE#COPY THE TX-IX1 NUMBER HERE"
utxo2="COPY THE TX-HASH2 HERE#COPY THE TX-IX2 NUMBER HERE"
Note: TxHash and TxIx are restricted between '#'
Single Output:
recipientAddress="COPY THE RECIPIENT ADDRESS HERE"
amount="AMOUNT IN LOVELACE"
Multiple Output:
recipientAddress1="COPY THE RECIPIENT1 ADDRESS HERE"
recipientAddress2="COPY THE RECIPIENT2 ADDRESS HERE"
amount1="AMOUNT1 IN LOVELACE"
amount2="AMOUNT2 IN LOVELACE"
Note: 1₳ = 1,000,000 Lovelace
Single Transaction:
cardano-cli transaction build \
--babbage-era \
--$network \
--tx-in $utxo \
--tx-out $recipientAddress+$amount \
--change-address $myAddress \
--out-file transaction.raw
Multiple Transaction:
cardano-cli transaction build \
--babbage-era \
--$network \
--tx-in $utxo1 \
--tx-in $utxo2 \
--tx-out $recipientAddress1+$amount1 \
--tx-out $recipientAddress2+$amount2 \
--change-address $myAddress \
--out-file transaction.raw
cardano-cli transaction sign \
--$network \
--tx-body-file transaction.raw \
--signing-key-file payment.skey \
--out-file transaction.signed
cardano-cli transaction submit \
--$network \
--tx-file transaction.signed
Hint: You can track the transaction using a blockchain explorer, such as Cardano Explorer or CardanoScan. Copy the link below.
Preprod:
https://preprod.cardanoscan.io/transaction/COPY-THE-TX-HASH-HERE
Preview:
https://preview.cardanoscan.io/transaction/COPY-THE-TX-HASH-HERE
Mainnet:
https://cardanoscan.io/transaction/COPY-THE-TX-HASH-HERE
The following is a video recorded by the Indonesian Cardano Developers Community where I demonstrated the steps above. Watch the recorded video at timestamp 1:27:27, here is the link.