Deposit
Locks tokens into a two-party escrow. The depositor moves amount tokens into the per-mint vault and creates an EscrowDeposit keyed by the claim authority — the account that can later claim the funds for a claimant. If never claimed, the depositor (or sponsor) can reclaim.
The deposit creates the per-mint vault on demand if it doesn't exist yet, so no setup is required — though you can pre-create it with token_account_init.
Program method — deposit
Derives the escrow PDA, the vault, and the depositor's associated token account, then builds, signs (payer + depositor), and sends.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
payer | Keypair | yes | — | The fee payer (the depositor, or a sponsor); co-signs. |
mint | #to_s | yes | — | The mint being escrowed. |
depositor | Keypair | yes | — | The depositor; co-signs. Source tokens come from its associated token account. |
claim_authority | #to_s | yes | — | The authority allowed to claim the deposit; keys the escrow PDA. |
amount | Integer | yes | — | Amount to deposit (base units). |
sponsor | #to_s | no | nil | Optional fee sponsor recorded on the deposit. When set, payer must be the sponsor — see Sponsors & Fee Payers. |
token_program_id | String | no | legacy SPL Token | Token program that owns the mint. |
Plus the shared sign: / execute: controls and Solace::Transaction return — see Conventions.
tx = program.deposit(
payer: depositor,
mint: mint_address,
depositor: depositor,
claim_authority: claim_authority.address,
amount: 1_000_000
)
connection.wait_for_confirmed_signature { tx.signature }Composer — ZarTrustlessEscrowDepositComposer
Use the composer for a custom fee payer/signing or to batch instructions. The escrow PDA, vault, and depositor token account must be resolved first (the program method does this via get_escrow_deposit_address, get_vault_address, and AssociatedTokenAccount.get_address).
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
mint | #to_s | yes | — | The mint being escrowed. |
depositor | #to_s | yes | — | The depositor (writable signer). |
depositor_token_account | #to_s | yes | — | The depositor's source token account (ATA). |
escrow_deposit | #to_s | yes | — | The EscrowDeposit PDA — from get_escrow_deposit_address. |
program_token_account | #to_s | yes | — | The vault PDA — from get_vault_address. |
fee_payer | #to_s · Keypair | yes | — | Pays fee + rent; writable signer. |
amount | Integer | yes | — | Amount to deposit (base units). |
claim_authority | #to_s | yes | — | The authority allowed to claim. |
sponsor | #to_s | no | nil | Optional fee sponsor recorded on the deposit. |
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. |
escrow_deposit, = program.get_escrow_deposit_address(claim_authority: claim_authority.address)
vault, = program.get_vault_address(mint: mint_address)
depositor_ata, = Solace::Programs::AssociatedTokenAccount.get_address(
owner: depositor.address, mint: mint_address
)
composer = Solace::Composers::ZarTrustlessEscrowDepositComposer.new(
mint: mint_address,
depositor: depositor.address,
depositor_token_account: depositor_ata,
escrow_deposit: escrow_deposit,
program_token_account: vault,
fee_payer: depositor.address,
amount: 1_000_000,
claim_authority: claim_authority.address
)
tx = Solace::TransactionComposer.new(connection:)
.add_instruction(composer)
.set_fee_payer(depositor)
.compose_transaction
tx.sign(depositor)
connection.send_transaction(tx.serialize)Low-level instruction (advanced)
DepositInstruction.build encodes the raw instruction. Account positions are indices into the compiled message's AccountContext.
- Discriminator:
[242, 35, 198, 137, 82, 225, 242, 182] - Encodes (
data):le_u64(amount)+pubkey(claim_authority)+option_pubkey(sponsor) - Accounts (in order):
mint·depositor(writable signer) ·depositor_token_account(writable) ·escrow_deposit(writable) ·program_token_account(writable) ·fee_payer(writable signer) ·system_program·token_program.
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | Integer | yes | u64 amount to deposit. |
claim_authority | #to_s | yes | Authority that can claim; encoded into data. |
sponsor | #to_s, nil | yes | Optional sponsor; encoded as a Borsh Option<publicKey>. |
mint_index | Integer | yes | Index of the mint. |
depositor_index | Integer | yes | Index of the depositor. |
depositor_token_account_index | Integer | yes | Index of the depositor's token account. |
escrow_deposit_index | Integer | yes | Index of the EscrowDeposit PDA. |
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. |