Initialize the Vault
Creates the per-mint program vault — the token account every escrow for that mint deposits into (see The Program Vault). Run this once per mint before the first two-party deposit. (The mediated deposit initializes the vault on demand, so it isn't required there.)
Program method — token_account_init
Derives the vault PDA, builds, signs (payer), and sends.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
payer | Keypair | yes | — | Pays the fee and the vault rent; the only signer. |
mint | #to_s | yes | — | The mint the vault will hold. |
token_program_id | String | no | Solace::Constants::TOKEN_PROGRAM_ID | Token program that owns the mint. Use TOKEN_2022_PROGRAM_ID for Token-2022 mints. |
Plus the shared sign: / execute: controls and Solace::Transaction return — see Conventions.
tx = program.token_account_init(payer: fee_payer, mint: mint_address)
connection.wait_for_confirmed_signature { tx.signature }Composer — ZarTrustlessEscrowTokenAccountInitComposer
Use the composer for a custom fee payer or to batch with other instructions. The vault address must be resolved first (the program method does this via get_vault_address).
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
mint | #to_s | yes | — | The mint the vault holds. |
program_token_account | #to_s | yes | — | The vault PDA — from get_vault_address. |
fee_payer | #to_s · Keypair | yes | — | Pays fee + rent; writable signer. |
program_id | #to_s | no | mainnet PROGRAM_ID | The escrow program id. |
token_program_id | #to_s | no | legacy SPL Token | Token program that owns the mint. |
vault, = program.get_vault_address(mint: mint_address)
composer = Solace::Composers::ZarTrustlessEscrowTokenAccountInitComposer.new(
mint: mint_address,
program_token_account: vault,
fee_payer: fee_payer.address
)
tx = Solace::TransactionComposer.new(connection:)
.add_instruction(composer)
.set_fee_payer(fee_payer)
.compose_transaction
tx.sign(fee_payer)
connection.send_transaction(tx.serialize)Low-level instruction (advanced)
TokenAccountInitInstruction.build encodes the raw instruction. Account positions are indices into the compiled message's AccountContext (the composer resolves these with context.index_of(...)).
- Discriminator:
[124, 4, 173, 7, 212, 208, 18, 239] - Encodes (
data): discriminator only — no arguments. - Accounts (in order):
mint(writable) ·program_token_account(writable) ·fee_payer(writable signer) ·system_program·token_program.
| Parameter | Type | Required | Description |
|---|---|---|---|
mint_index | Integer | yes | Index of the mint. |
program_token_account_index | Integer | yes | Index of the vault. |
fee_payer_index | Integer | yes | Index of the fee payer. |
system_program_index | Integer | yes | Index of the System program. |
token_program_index | Integer | yes | Index of the token program. |
program_index | Integer | yes | Index of the escrow program (the invoked program). |