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

# Dawn: segregated BTC staking on Bitcoin

> Dawn connects your Bitcoin to traditional finance yield. Each deposit sits in its own pair of Bitcoin scripts. Learn the four-transaction lifecycle and what Bitcoin enforces.

Dawn is the segregated rail. It connects your Bitcoin to a Yield Provider: an established traditional finance institution that puts BTC to work off-chain and pays you a fixed return. Each deposit is its own position on Bitcoin. Your BTC sits in two scripts, the provider claims one of them and sends principal plus yield back, and after the deadline you sweep everything in one transaction. Nothing is bridged or wrapped.

Dawn is built on [`btc-locker`](https://docs.sundialprotocol.com/sdk/btc-locker), the TypeScript library that constructs the scripts and transactions.

> [!NOTE]
>
> Dawn is on public testnet. See [Status and security](https://docs.sundialprotocol.com/overview/status.md).

## The four transactions

Every position follows the same sequence. Two scripts are created with the same deadline: a **Timelock (Return) script** and an **Escrow script**.

**1. Deposit**

You broadcast one Bitcoin transaction that funds both scripts:

* The **Timelock script** receives part of your principal. Only you can spend it, and only after the deadline.
* The **Escrow script** receives the rest. The provider can claim it, and you can reclaim it after the deadline.

The transaction also carries an `OP_RETURN` output with a 60-byte `SNDL` payload that identifies the deposit and the provider.

**2. Claim**

The provider sweeps the Escrow output to its own address using the `OP_ELSE` branch of the script, which needs only the provider's signature.

**3. Distribute**

The provider sends your principal plus the agreed yield to your Timelock address. This is an ordinary Bitcoin payment from the provider's wallet.

The amount and the schedule are set by the agreement you sign with the provider before depositing.

**4. Withdraw**

After the deadline, you broadcast one transaction that spends everything at the Timelock address and any unclaimed Escrow output.

## The scripts

> **Timelock (Return) script**
>
> ```
> <locktime> OP_CHECKLOCKTIMEVERIFY OP_DROP <user_pubkey> OP_CHECKSIG
> ```
>
> The spending transaction's `nLockTime` must be at or after `locktime`. Only the holder of `user_pubkey` can spend. The provider holds no key for this script.

> **Escrow script**
>
> ```
> OP_IF
>   <deadline> OP_CHECKLOCKTIMEVERIFY OP_DROP <user_pubkey> OP_CHECKSIG
> OP_ELSE
>   <provider_pubkey> OP_CHECKSIG
> OP_ENDIF
> ```
>
> The `OP_IF` branch is your reclaim path: available after the deadline, with your signature. The `OP_ELSE` branch is the provider's claim path: available at any time, with the provider's signature.

Both are P2WSH outputs and share the same deadline, which is what lets one withdrawal transaction sweep both.

## How Dawn connects Bitcoin to traditional finance

Dawn is the link between Bitcoin and a traditional finance institution. Bitcoin scripts hold the position and enforce the timing and the keys. The provider earns the yield off-chain, under a signed agreement with you that sets the return and when it is paid.

### What Bitcoin enforces

| Property | Mechanism |
| - | - |
| Your position runs to the deadline you agreed | `OP_CHECKLOCKTIMEVERIFY` on both scripts |
| Only you can spend the Timelock script | The provider holds no key for it |
| Only you can use the Escrow reclaim path | `OP_CHECKSIG` against your public key |
| Only the provider can use the Escrow claim path | `OP_CHECKSIG` against the provider's public key |
| No third party can spend either script | Both paths require a signature |

### What the provider does

| Step | How it works |
| - | - |
| Claims the escrowed BTC | With its own key, through the Escrow claim path |
| Earns the yield | Off-chain, in its own traditional finance strategy |
| Pays principal plus yield | To your Timelock script, or directly to you, on the schedule in your agreement |

Yield is paid to a script only you can spend, or straight to you.

## On-chain metadata

Each protocol transaction embeds a 60-byte payload in an `OP_RETURN` output. Sundial's indexer uses it to bind a Bitcoin transaction to a position.

| Offset | Field | Description |
| - | - | - |
| 0 to 3 | `magic` | ASCII `"SNDL"` |
| 4 | `version` | Schema version (`0x01`) |
| 5 | `txType` | `0x01` Deposit, `0x02` Claim, `0x03` Distribution, `0x04` Withdrawal |
| 6 to 21 | `subjectId` | UUID v4 (16 raw bytes) identifying the deposit |
| 22 to 53 | `providerXonlyPubkey` | The provider's 32-byte x-only public key |
| 54 to 55 | `flags` | Reserved (`0x0000`) |
| 56 to 59 | `checksum` | CRC-32 over bytes 0 to 55 |

Example transactions on Bitcoin testnet:

* [Deposit](https://mempool.space/testnet/tx/3a673e2b13aedae92bbe2589dcb161856aa26d86abc9e33541c8bf95ecf277c9)
* [Claim](https://mempool.space/testnet/tx/53fc2d443872e5818a5e0b10011620a3baa1d51a727bf103271bf24b36d9af0c)
* [Distribution](https://mempool.space/testnet/tx/435742c80b0ea67fbaea1fa28ce59079ebf47447dc3e61f76bbda6c74f029676)
* [Withdrawal](https://mempool.space/testnet/tx/87cc2463cc68030830b3c07141973f63d46a7df637a17b60b8d8d39c6490485b)

## Assurance

Dawn core has been audited by Hacken, with no critical or high findings and every finding fixed. It is also covered by an ongoing HackenProof bug bounty. See [Status and security](https://docs.sundialprotocol.com/overview/status.md#audits-and-reviews).

## Next steps

> **[Stake with Dawn](https://docs.sundialprotocol.com/guides/stake-with-dawn.md)**
>
> The dashboard walkthrough for depositors.

> **[btc-locker SDK](https://docs.sundialprotocol.com/sdk/btc-locker.md)**
>
> Build the four transactions from your own application.


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