# Send a transaction

End-to-end example: sign a value transfer locally, broadcast it via `eth_sendRawTransaction`, wait for the receipt.

## With viem

```ts
import { createWalletClient, createPublicClient, http, parseEther } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { aeredium } from "./chain";

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);

const wallet = createWalletClient({ account, chain: aeredium, transport: http() });
const client = createPublicClient({ chain: aeredium, transport: http() });

const hash = await wallet.sendTransaction({
  to: "0x742d35Cc6634C0532925a3b844Bc9e7595f3bA21",
  value: parseEther("0.1"),
});

const receipt = await client.waitForTransactionReceipt({ hash });
console.log(`tx ${hash} included in block ${receipt.blockNumber}, status=${receipt.status}`);
```

## With ethers v6

```ts
import { JsonRpcProvider, Wallet, parseEther } from "ethers";

const provider = new JsonRpcProvider("https://rpc.aeredium.io", { chainId: 1000, name: "aeredium" });
const wallet = new Wallet(process.env.PRIVATE_KEY!, provider);

const tx = await wallet.sendTransaction({
  to: "0x742d35Cc6634C0532925a3b844Bc9e7595f3bA21",
  value: parseEther("0.1"),
});

const receipt = await tx.wait();
console.log(`tx ${tx.hash} included in block ${receipt!.blockNumber}, status=${receipt!.status}`);
```

## With Foundry

```bash
cast send 0x742d35Cc6634C0532925a3b844Bc9e7595f3bA21 \
  --value 0.1ether \
  --rpc-url https://rpc.aeredium.io \
  --private-key $PRIVATE_KEY
```

## With raw curl (build the tx yourself)

This is the lowest-level path — useful for benchmarking and for languages without a mature EVM library.

1. Build and sign the transaction in your language of choice (any RLP/EIP-1559 encoder will do).
2. Submit the hex-encoded raw transaction:

```bash
curl -X POST https://rpc.aeredium.io \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc":"2.0",
    "method":"eth_sendRawTransaction",
    "params":["0x02f8..."],
    "id":1
  }'
```

The response is the transaction hash. Poll for the receipt:

```bash
curl -X POST https://rpc.aeredium.io \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0xTxHash"],"id":1}'
```

## High-throughput batching

If you're submitting thousands of transactions per second (e.g. market makers, bridges, indexers), use JSON-RPC batch requests so each round-trip carries multiple `eth_sendRawTransaction` calls:

```bash
curl -X POST https://rpc.aeredium.io \
  -H "Content-Type: application/json" \
  -d '[
    {"jsonrpc":"2.0","id":1,"method":"eth_sendRawTransaction","params":["0x02f8..."]},
    {"jsonrpc":"2.0","id":2,"method":"eth_sendRawTransaction","params":["0x02f8..."]},
    {"jsonrpc":"2.0","id":3,"method":"eth_sendRawTransaction","params":["0x02f8..."]}
  ]'
```

Internally the network groups submitted transactions into 1,000-tx micro-batches that flush every 1ms — your batch requests feed straight into that pipeline. For institutional integrators that need the absolute maximum throughput (1.4M TPS), there's a direct gRPC `SubmitBatch` interface; contact `ops-team@aeredium.com` for access.

## Common errors

| Error message                                | Cause                                            | Fix                                                           |
| -------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------- |
| `nonce too low`                              | You re-used a nonce that's already on-chain      | Refresh nonce with `eth_getTransactionCount(addr, "pending")` |
| `nonce too high`                             | Future nonce, no preceding tx in mempool         | Send the missing nonce, or reset and resend                   |
| `insufficient funds for gas * price + value` | Not enough AER                                   | Top up the sender                                             |
| `intrinsic gas too low`                      | `gasLimit` < base cost (21,000 for transfers)    | Raise `gasLimit` or omit it to let the client estimate        |
| `replacement transaction underpriced`        | Resending the same nonce without a 10%+ fee bump | Increase `maxFeePerGas` and `maxPriorityFeePerGas`            |


---

# 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://aeredium.gitbook.io/developer.aeredium.io/examples/send-transaction.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.
