> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sundialprotocol.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Use the Sundial L2

> Send a transaction on the Sundial L2 testnet with the midgard CLI, and learn how deposits, withdrawals and forced transaction orders work.

This guide sends a transaction on the Sundial L2 testnet and explains how funds move between L1 and L2.

Your browser wallet's **Send** button builds transactions for the settlement L1, not for the Sundial L2. To transact on the L2 you build a transaction against the L2 node. The `midgard` command-line tool does this for you.

## Send a transaction with the CLI

**1. Build the CLI**

From a checkout of [`sundial-monorepo`](https://github.com/sundial-protocol/sundial-monorepo):

```bash theme={null}
cd demo/midgard-manager/packages/cli
pnpm install
pnpm build
```

Commands below use `node dist/bin.js`. By default they connect to `http://localhost:3000`. Pass `--endpoint https://rpc.testnet.sundialprotocol.com` to use the public testnet node.

**2. Create a wallet**

```bash theme={null}
node dist/bin.js wallet create alice
```

This prints a new `addr_test1…` address and saves the wallet locally under the name you gave it.

**3. Fund it**

Paste the address into the [faucet](https://www.sundialprotocol.com/testnet/faucet), then check the balance:

```bash theme={null}
node dist/bin.js wallet balance alice
```

```text theme={null}
Balance for alice (addr_test1vqfy…):
  100.000000 sBTC
  (100000000 lovelace across 1 UTxO(s))
```

**4. Send**

```bash theme={null}
node dist/bin.js send \
  --from alice \
  --to addr_test1vpmkj5p7v93m2j5m5laqj27w2u6veqcgnfrt3zt50cvkunqs0rnyz \
  --amount 1.5
```

The amount is in sBTC. The command prints the transaction hash.

**5. Confirm it was accepted**

```bash theme={null}
node dist/bin.js tx-lookup <transaction hash>
```

Submission only queues the transaction. The node validates it a moment later. If the lookup says "Not found", wait a few seconds and try again.

If a command can't connect, check the node first:

```bash theme={null}
node dist/bin.js node node-status --endpoint https://rpc.testnet.sundialprotocol.com
```

The [CLI reference](https://docs.sundialprotocol.com/operators/cli-reference.md) lists every command.

## Build transactions in your own code

The L2 uses a Cardano-style transaction format, so libraries such as Lucid Evolution can build transactions. The difference is the provider:

1. Read spendable outputs from `GET /utxos` on the L2 node.
2. Build and sign the transaction. The fee follows the node's formula: 44 lovelace per byte plus 155,381.
3. Submit the hex-encoded transaction to `POST /submit`.
4. Poll `GET /tx?tx_hash=…` until the node returns it.

See the [Transactions API](https://docs.sundialprotocol.com/api/transactions.md) and the [Midgard SDK](https://docs.sundialprotocol.com/sdk/midgard-sdk.md).

## Deposit from L1

A deposit is an L1 transaction that sends tokens to the L2's deposit contract and names the L2 address to credit. The block whose time interval covers the deposit's inclusion time must include it, and your funds then appear on L2.

Build it with the SDK: see [Constructing a deposit](https://docs.sundialprotocol.com/sdk/midgard-sdk.md#constructing-a-deposit).

## Withdraw to L1

A withdrawal is an L1 transaction that posts a withdrawal order: which L2 output to withdraw, and which L1 address to pay.

1. The order is included in an L2 block, which removes the output from the L2 ledger.
2. The block waits out the maturity period and is merged.
3. The order is paid out from the reserve to your L1 address.

Build it with the SDK: see [Constructing a withdrawal](https://docs.sundialprotocol.com/sdk/midgard-sdk.md#constructing-a-withdrawal).

## If an operator ignores your transaction

Post it on L1 as a transaction order. The block covering its inclusion time must include it. See [Posting a transaction order](https://docs.sundialprotocol.com/sdk/midgard-sdk.md#posting-a-transaction-order-guaranteed-inclusion) and [how inclusion times work](https://docs.sundialprotocol.com/l2/user-events.md#inclusion-times).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.