Core Concepts
Understanding the key concepts in Veil.
Vaults
A vault is a token account that holds funds for payment schedules. Each employer wallet can have one vault per token mint.
Properties:
- holds a single SPL token mint
- must use a mint allowed by the protocol whitelist when whitelist mode is enabled
- tracks
availablevsreservedbalance - is controlled by the employer wallet through the program
Lifecycle:
- create vault with
initVault() - deposit tokens with
deposit() - reserve funds when schedules are created
- withdraw available balance with
withdraw()
Schedules
A schedule defines a recurring payout plan with hidden recipients.
Key fields:
intervalSecs- time between executionsreservedAmount- total funds reservedperExecutionAmount- amount paid per cyclemerkleRoot- root of the recipient Merkle treetotalRecipients- number of recipientsnextExecution- unix timestamp of the next run
scheduleId is used to derive the schedule PDA, but it is not stored as a field inside the on-chain ScheduleAccount.
Status values:
ActivePausedCancelled
Merkle Trees
Merkle trees let Veil verify membership without storing the full recipient list on-chain.
Structure
Root (stored on-chain)
/ \
Hash(0-1) Hash(2-3)
/ \ / \
Leaf0 Leaf1 Leaf2 Leaf3Each leaf is hash(recipient_address || amount).
Why Merkle Trees?
- privacy - only the root is committed on-chain
- verification - proofs confirm membership without revealing the full set
- efficiency - proof size grows logarithmically with recipient count
Building a Tree
import { buildMerkleTree } from "@veil-dev/sdk";
const recipients = [
{ address: pubkey1, amount: 100_000n },
{ address: pubkey2, amount: 200_000n },
];
const { root, proofs } = buildMerkleTree(recipients);Batch Execution
Payments execute in batches:
- batch start - first successful claim sets
batchStartTime - claims - recipients are processed with Merkle proofs
- completion - all recipients are paid or timeout is reached
- settlement - reserved amount is decremented and the next run is scheduled
The global batch timeout is configurable in VeilConfig and defaults to 7 days in the SDK helper.
Ephemeral Rollups
MagicBlock ER provides:
- TEE execution
- private claim flow
- state handoff back to Solana through commit
Coordinator
The coordinator automates execution and stores off-chain payout metadata:
- monitors schedules for execution time
- validates and stores recipient payloads
- delegates to ER
- executes claims
- commits final state
- records execution history
Requirements:
- PostgreSQL
- Redis (recommended for distributed rate limiting)
- ER authority keypair
- Solana RPC connection
Reserved vs Available
Available - funds that can be withdrawn or used for new schedules
Reserved - funds locked for active schedules
Total Balance = Available + ReservedWhen a schedule is created, funds move from available to reserved. When a schedule completes or is cancelled, funds are released back to available.
Dashboard Conveniences
The published employer dashboard adds workflow features on top of the protocol and SDK:
- CSV / Excel recipient imports
- local saved schedule templates per wallet
- coordinator execution-history views
- pause / resume / cancel controls