Skip to content

Latest commit

 

History

History
171 lines (119 loc) · 4.01 KB

transaction-eng.md

File metadata and controls

171 lines (119 loc) · 4.01 KB

Transaction

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:

Step by Step

Step-1 Generate Wallet Address

If you haven't generated a wallet address, you should follow this documentation first.

Step-2 Initiate Cardano Network (Optional)

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

Display Information About the Wallet Address UTxO

cardano-cli query utxo \
--address $myAddress \
--$network

Example Result:

                           TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------
62c0ce8d6e0b584e9e263e3ba076f53c23095ebd0a9198305819cfa5ecef8e81     0        1000000000 lovelace + TxOutDatumNone

Initiate TxHash and TxIx

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 '#'

Step-4 Initiate the Output: Recipient Address and Amount to Send

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

Step-5 Build Transaction

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

Step-6 Sign Transaction

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

Step-7 Submit Transaction

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

Demo

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.

References

Gimbalabs PPBL2023 Module 102.3: Build a Simple Transaction

Cardano Developer Portal: Create Simple Transactions