# Bash & cURL

### Introduction

There are two ways to create a transaction, the first one is by passing the Cardano wallet address for the utxos (as the changeAddress), and the second one usually used with a frontend (wallet extension), requires to get a list of all cbor utxos to be used for the transaction.

The following examples are covering both approaches.

### Objectives

This example sends 10ADA from one wallet to another.

### Requirements

* A Cardano wallet with ADA
* A wallet to send ADA to
* A wallet extension to sign the transaction
* An API key

The wallets are on Preprod network and using Eternl (So the signature is done in the browser) See [Signing Transactions](https://github.com/Cardano-Forge/anvil-api/blob/main/docs/guides/transaction/signing-transaction.md) for more details.

### Using the Address to fetch Utxos

**Payload (Using an address only)**

> Important: This demo is meant for educational and testing purposes only. In production, please pass the UTXO list for your wallet. We recommend using the [@ada-anvil/weld](https://www.npmjs.com/package/@ada-anvil/weld) wallet connector to easily retrieve UTXOs from connected wallets. In this example, the API will fetch the UTXO list for you and automatically determine the UTXO(s) to be used for the transaction.

*You can use this payload when you cannot fetch the utxos, for example, when you don't have a wallet extension.*

```json
{
  "changeAddress": "addr_sender...",
  "outputs": [
    {
      "address": "addr_recipient...",
      "lovelace": 10_000_000
    }
  ]
}
```

**Example (Using cURL)**

*Using a preprod wallet.*

{% code overflow="wrap" %}

```sh
SENDER_ADDRESS="addr_test1qrvx8wgdndrk98qf62vka3q4fglchk7h940vepdtgcv9fuu0e0aeuac6j2xhz77esaaudku68ha89qesqvd29pmuzw6qk8xkcn"
RECEIVER_ADDRESS="addr_test1qztayr885vqrx6w0j946lvtxl622flxx4asj2z4ludm3y2rewu7hmazv8tm78tvphzlream22pp6zhk0rrsa84nf6qxsrua9nh"
# 10 ADA => 1ADA = 1'000'000LOVELACE
LOVELACE_AMOUNT=10_000_000
# See Authentication page for API key details.
X_API_KEY="testnet_EyrkvCWDZqjkfLSe1pxaF0hXxUcByHEhHuXIBjt9"
```

{% endcode %}

{% code overflow="wrap" %}

```sh
curl -X POST \
     -H "Content-Type: application/json" \
     -H "X-Api-Key: ${X_API_KEY}" \
     -d '{
           "changeAddress": "'${SENDER_ADDRESS}'",
           "outputs": [
             {
               "address": "'${RECEIVER_ADDRESS}'",
               "lovelace": 10000000
             }
           ]
         }' \
     https://preprod.api.ada-anvil.app/v2/services/transactions/build
```

{% endcode %}

**Output**

{% code overflow="wrap" fullWidth="false" %}

```json
{
  "complete": "84a400d901028182582059f796dba33ec94cd07dd609d175a6ef239a2590e974b73ec052eccb8daf53f30101828258390097d20ce7a3003369cf916bafb166fe94a4fcc6af61250abfe377122879773d7df44c3af7e3ad81b8be3cf76a5043a15ecf18e1d3d669d00d1a0098968082583900d863b90d9b47629c09d2996ec4154a3f8bdbd72d5ecc85ab461854f38fcbfb9e771a928d717bd9877bc6db9a3dfa728330031aa2877c13b41a1de51e21021a0003cb05031a04e05deea0f5f6",
  "stripped": "84a400d901028182582059f796dba33ec94cd07dd609d175a6ef239a2590e974b73ec052eccb8daf53f30101828258390097d20ce7a3003369cf916bafb166fe94a4fcc6af61250abfe377122879773d7df44c3af7e3ad81b8be3cf76a5043a15ecf18e1d3d669d00d1a0098968082583900d863b90d9b47629c09d2996ec4154a3f8bdbd72d5ecc85ab461854f38fcbfb9e771a928d717bd9877bc6db9a3dfa728330031aa2877c13b41a1de51e21021a0003cb05031a04e05deea0f5f6",
  "witnessSet": "a0"
}
```

{% endcode %}

### Using a list of UTXOs

**Payload**

*You can use this payload when you can fetch the utxos, for example, when you have a wallet extension.*

```json
{
  "utxos": ["8282...", "8282...", "..."],
  "changeAddress": "addr_sender...",
  "outputs": [
    {
      "address": "addr_recipient...",
      "lovelace": 10000000,
    }
  ]
}
```

<mark style="color:red;">TBD, do the example as above using an UTXOs list</mark>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.ada-anvil.io/guides/transaction/create-basic-transaction/bash-and-curl.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
