Skip to content

The Program Vault

All escrowed tokens for a given mint live in a single program vault — a token account owned by a Program Derived Address. Both escrow types deposit into and pay out of the same per-mint vault.

One vault per mint

The vault address is derived from the mint:

ruby
vault, = program.get_vault_address(mint: mint_address)

On chain the seeds are ["vault", mint], so there is exactly one vault per mint, shared across every EscrowDeposit and MediatedEscrowDeposit for that mint. The individual deposit accounts track who owns what; the vault just holds the pooled tokens.

Initializing the vault

Both deposit instructions create the vault on demand (the on-chain account uses init_if_needed), so you don't have to pre-create it — the first deposit or mediated_deposit for a mint initializes it automatically.

token_account_init lets you create it ahead of time instead — for example so the program (not the first depositor) bears the vault's rent:

ruby
tx = program.token_account_init(payer: fee_payer, mint: mint_address)
connection.wait_for_confirmed_signature { tx.signature }

It's idempotent in practice — every later deposit reuses the same vault.

TIP

Pre-creating the vault is optional: both the two-party deposit and the three-party mediated_deposit initialize it automatically if it doesn't exist yet, so you can skip token_account_init entirely.

Token-2022 mints

The vault is a standard token account under whichever token program owns the mint. For a Token-2022 mint, pass token_program_id: Solace::Constants::TOKEN_2022_PROGRAM_ID to token_account_init (and to every deposit/claim/release call) so the vault is created and used under the right program. See Conventions.

Built on Solace