> For the complete documentation index, see [llms.txt](https://docs.vault.ky/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vault.ky/smart-contracts/instructions.md).

# Instructions

## Campaign lifecycle

| Instruction            | Purpose                                                                              |
| ---------------------- | ------------------------------------------------------------------------------------ |
| `create_campaign`      | Creates the campaign and its escrow PDA. Fixes goal, deadline, fee rates, and caps.  |
| `contribute`           | Records a contribution, deducts the contribution fee, updates the receipt and index. |
| `sync_direct_deposits` | Credits SOL sent straight to the escrow address rather than through the interface.   |
| `add_tip`              | Adds an optional tip during the waiting window.                                      |
| `add_surplus`          | Records SOL received above the campaign target.                                      |
| `crank_campaign`       | Advances campaign state — funded, executable, or failed.                             |

## Settlement

| Instruction                      | Purpose                                                                                                                               |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `release_to_execution_wallet`    | Transfers the campaign target to the execution wallet.                                                                                |
| `release_to_execution_wallet_v2` | Transfers a configured execution payout, so the goal can represent retail price while the execution wallet receives fulfillment cost. |
| `sweep_to_treasury`              | Moves the remaining balance above the rent floor to treasury after execution.                                                         |
| `sweep_vault_fees`               | Collects accrued contribution fees.                                                                                                   |

## Refunds

| Instruction       | Purpose                                                                             |
| ----------------- | ----------------------------------------------------------------------------------- |
| `refund_batch`    | Processes refunds for a page of contributors.                                       |
| `refund_one`      | Refunds a single contributor, signed by that contributor.                           |
| `cancel_campaign` | Vault-initiated cancellation before release. Moves the campaign to the refund path. |

## Permissionless instructions

This is the property that makes Vault's guarantees meaningful.

**`crank_campaign` requires no signer at all.** Its accounts are the global config and the campaign. Any party can submit it and advance a campaign through its lifecycle.

**`refund_batch` takes an unconstrained signer.** The `cranker` account is any keypair — there is no authority check gating it.

**`refund_one` is signed by the contributor.** A contributor can recover their own refund directly.

Taken together: if Vault's infrastructure were unavailable, campaigns could still be progressed and refunds still recovered by anyone willing to pay the transaction fee. Vault cannot stall or block the state machine.

## Events

Every state transition emits an event, so indexers and external observers can reconstruct campaign history from chain data alone:

`CampaignCreated`, `ContributionMade`, `DirectDepositsSynced`, `CampaignFunded`, `ExecutionAllowed`, `TipAdded`, `SurplusAdded`, `CampaignExecuted`, `TreasurySwept`, `VaultFeesSwept`, `CampaignFailed`, `RefundProcessed`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.vault.ky/smart-contracts/instructions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
