> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Prepare a vault for a gated token

> Prepare what an asset manager's vault needs before it can hold a gated token: show that the gate blocks an unlisted vault, allowlist it, and confirm what a pause does to it.

An asset manager's vault holding a gated token is subject to that gate like
any other holder. If the vault's accounts were not allowlisted at deployment,
the first deposit fails.

This tutorial covers the token side of a vault deployment: show that the gate
applies to a vault, get the vault onto the allowlist, and verify its account.
It continues with the mint from
[gate the holders](/developers/docs/tokenization/tutorials/issuing/gate-the-holders),
so `$MINT` and `$LIST` should already be exported, on the same network.

<Note>
Mosaic issues and operates tokens; it does not deploy vaults. The steps below
use an ordinary key file to stand in for the vault's authority.
</Note>

<Steps titleSize="h2">

<Step title="Stand up the vault authority">

In a deployed vault this address is a PDA owned by the vault program. Here a
key file stands in, which is enough to show the allowlist interactions: the
gate checks the address only, so a PDA and a keypair are treated the same way,
in allowlist and in blocklist mode.

```bash Terminal
solana-keygen new --no-bip39-passphrase --silent \
  --outfile ~/.config/solana/demo-vault.json
export VAULT=$(solana-keygen pubkey ~/.config/solana/demo-vault.json)
```

When you move to a real vault, allowlist the program's PDA instead of a wallet,
derived the same way the program derives it. See
[program and authority design](/developers/docs/tokenization/design/program-and-authority-design#a-pda)
for why the vault's token account should be owned by a PDA.

</Step>

<Step title="Show that the gate blocks an unlisted vault">

Before allowlisting, confirm the failure mode: have the holder move the asset
into the vault while it is not on the list, with the `transfer` script from
[gate the holders](/developers/docs/tokenization/tutorials/issuing/gate-the-holders#show-that-the-gate-rejects-a-non-holder),
run with `$VAULT 1`.

<Tabs>
<Tab title="Mosaic SDK">
<div className="sol-tab-label">Mosaic SDK</div>

```ts
// npx tsx transfer.ts <recipient> <amount>
import { address } from "@solana/kit";
import { createTransferTransaction } from "@solana/mosaic-sdk";
import { arg, env, loadSigner, rpc, sendMessage } from "./common";

// The holder signs and pays for its own transfer.
const holder = await loadSigner("demo-holder");
const mint = address(env("MINT"));

// Creates the recipient's token account if it is missing and thaws it
// through the gate before the transfer, so the gate decides whether the
// recipient may hold the token.
await sendMessage(
  await createTransferTransaction({
    rpc,
    mint,
    from: holder.address,
    to: address(arg(1, "the recipient wallet")),
    feePayer: holder,
    authority: holder,
    amount: arg(2, "the amount"),
  }),
);
```

<div className="sol-run" data-run="paths/assets/gated-token/transfer-vault-blocked" data-tab="Mosaic SDK">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Sending 1 to the vault before it is on the allowlist</span></div>
<div className="sol-run-out">

```text Output
{
  discriminator: 1,
  bump: 255,
  enablePermissionlessThaw: true,
  enablePermissionlessFreeze: false,
  mint: '653XZoSFLEb7BuezYeLTiq5KBsdFDHZ71MfsybEzHr9G',
  freezeAuthority: 'Grr9mjov4Ao553eJfERUuGK7GPv2BmJsnsS7xxdcWjXF',
  gatingProgram: 'GATEzzqxhJnsWF6vHRsgtixxSB8PaQdcqGEVTEHWiULz'
}
EAEXfee6dPx7myBsnb6e4CEVgt9APZWdvYwYi54e7t4E
Failed: Program GATEzzqxhJnsWF6vHRsgtixxSB8PaQdcqGEVTEHWiULz failed: custom program error: 0x1002
```

</div>
</div>

</Tab>
<Tab title="Kit">
<div className="sol-tab-label">Kit</div>

```ts
// npx tsx transfer.ts <recipient> <amount>
import { address } from "@solana/kit";
import {
  fetchMint,
  findAssociatedTokenPda,
  getTransferCheckedInstruction,
  TOKEN_2022_PROGRAM_ADDRESS,
} from "@solana-program/token-2022";
import { arg, env, loadSigner, rpc, send, toBaseUnits } from "./common";
import { openThroughGate } from "./gate";

// The holder signs and pays for its own transfer.
const holder = await loadSigner("demo-holder");
const mint = address(env("MINT"));
const list = address(env("LIST"));
const { data } = await fetchMint(rpc, mint);

const [source] = await findAssociatedTokenPda({
  mint,
  owner: holder.address,
  tokenProgram: TOKEN_2022_PROGRAM_ADDRESS,
});
// The thaw is where an unlisted recipient fails: the gate rejects the owner
// and the whole transaction is dropped before any token moves.
const { tokenAccount: destination, instructions } = await openThroughGate(
  holder,
  mint,
  address(arg(1, "the recipient wallet")),
  list,
);
await send(holder, [
  ...instructions,
  getTransferCheckedInstruction({
    source,
    mint,
    destination,
    authority: holder,
    amount: toBaseUnits(arg(2, "the amount"), data.decimals),
    decimals: data.decimals,
  }),
]);
```

<div className="sol-run" data-run="paths/assets/gated-token/transfer-vault-blocked" data-tab="Kit">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Sending 1 to the vault before it is on the allowlist</span></div>
<div className="sol-run-out">

```text Output
Failed: Program GATEzzqxhJnsWF6vHRsgtixxSB8PaQdcqGEVTEHWiULz failed: custom program error: 0x1002
```

</div>
</div>

</Tab>
<Tab title="Web3.js v3">
<div className="sol-tab-label">Web3.js v3</div>

```ts
// npx tsx transfer.ts <recipient> <amount>
import { PublicKey } from "@solana/web3.js";
import {
  findAssociatedTokenPda,
  getMintDecoder,
  getTransferCheckedInstruction,
  TOKEN_2022_PROGRAM_ADDRESS,
} from "@solana-program/token-2022";
import {
  addressOf,
  arg,
  connection,
  env,
  loadKeypair,
  send,
  toBaseUnits,
} from "./common";
import { openThroughGate } from "./gate";

// The holder signs and pays for its own transfer.
const holder = await loadKeypair("demo-holder");
const mint = addressOf(env("MINT"));
const list = addressOf(env("LIST"));
const mintAccount = await connection.getAccountInfo(new PublicKey(mint));
const { decimals } = getMintDecoder().decode(mintAccount!.data);

const [source] = await findAssociatedTokenPda({
  mint,
  owner: holder.publicKey.toBase58(),
  tokenProgram: TOKEN_2022_PROGRAM_ADDRESS,
});
// The thaw is where an unlisted recipient fails: the gate rejects the owner
// and the whole transaction is dropped before any token moves.
const { tokenAccount: destination, instructions } = await openThroughGate(
  holder,
  mint,
  addressOf(arg(1, "the recipient wallet")),
  list,
);
await send(
  [holder],
  [
    ...instructions,
    getTransferCheckedInstruction({
      source,
      mint,
      destination,
      authority: holder,
      amount: toBaseUnits(arg(2, "the amount"), decimals),
      decimals,
    }),
  ],
);
```

<div className="sol-run" data-run="paths/assets/gated-token/transfer-vault-blocked" data-tab="Web3.js v3">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Sending 1 to the vault before it is on the allowlist</span></div>
<div className="sol-run-out">

```text Output
Failed: Program GATEzzqxhJnsWF6vHRsgtixxSB8PaQdcqGEVTEHWiULz failed: custom program error: 0x1002
```

</div>
</div>

</Tab>
<Tab title="Rust">
<div className="sol-tab-label">Rust</div>

```rust
// cargo run --release --bin transfer -- <recipient> <amount>
use anyhow::Result;
use gated_token::{
    acl, arg, arg_pubkey, ata, env, load_keypair, mint_decimals, rpc, send, to_base_units,
    TOKEN_2022,
};
use solana_sdk::signature::Signer;
use spl_token_2022_interface::instruction::transfer_checked;

#[tokio::main]
async fn main() -> Result<()> {
    let rpc = rpc();
    // The holder signs and pays for its own transfer.
    let holder = load_keypair("demo-holder")?;
    let mint = env("MINT")?;
    let list = env("LIST")?;
    let recipient = arg_pubkey(1, "the recipient wallet")?;
    let decimals = mint_decimals(&rpc, &mint).await?;

    // The thaw is where an unlisted recipient fails: the gate rejects the
    // owner and the whole transaction is dropped before any token moves.
    let (destination, mut instructions) =
        acl::open_through_gate(&rpc, &holder.pubkey(), &mint, &recipient, &list).await?;
    instructions.push(transfer_checked(
        &TOKEN_2022,
        &ata(&mint, &holder.pubkey()),
        &mint,
        &destination,
        &holder.pubkey(),
        &[],
        to_base_units(&arg(2, "the amount")?, decimals)?,
        decimals,
    )?);
    send(&rpc, &[&holder], &instructions).await
}
```

<div className="sol-run" data-run="paths/assets/gated-token/transfer-vault-blocked" data-tab="Rust">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Sending 1 to the vault before it is on the allowlist</span></div>
<div className="sol-run-out">

```text Output
Failed: Program GATEzzqxhJnsWF6vHRsgtixxSB8PaQdcqGEVTEHWiULz failed: custom program error: 0x1002
```

</div>
</div>

</Tab>
</Tabs>

It fails. The vault's token account is created frozen, and the gate program
rejects the permissionless thaw for it with custom program error `0x1002`
(4098), because the vault is not on the list. A program is not exempt from the
gate. A deposit that inserts the thaw fails with this error; one that does not
fails on the frozen account (`0x11`).

</Step>

<Step title="Allowlist every account the vault touches">

List them before you start. A vault over a gated token needs at least the
vault's wallet or PDA on this mint's list and, if the fund's shares are
themselves a restricted token, each participant's wallet on the share mint's
list. This covers the first:

<CodeGroup>
```bash TypeScript
npx tsx allowlist-add.ts $VAULT
```

```bash Rust
cargo run --release --bin allowlist-add -- $VAULT
```
</CodeGroup>

Repeat it for each address on your list. A missing one fails when a
participant tries to transact.

</Step>

<Step title="Confirm the deposit path works">

Run the same transfer again. It succeeds and prints its signature; as in the
issuing tutorial, only the list entry changed.

<CodeGroup>
```bash TypeScript
npx tsx transfer.ts $VAULT 1
```

```bash Rust
cargo run --release --bin transfer -- $VAULT 1
```
</CodeGroup>

</Step>

<Step title="Verify the gate state of each account">

Before going live, read every account the vault depends on and confirm its
state. This is the pre-deployment check to automate. First derive the vault's
token account address, with `spl-token` or with the `derive-ata` script from
the [custodian tutorial](/developers/docs/tokenization/tutorials/custodian#derive-the-token-account-address-before-it-exists)
run with `$VAULT`:

```bash spl-token
spl-token address --token $MINT --owner $VAULT --verbose \
  --url ${RPC_URL:-devnet}
```

<div className="sol-run" data-run="paths/assets/gated-token/address-vault" data-tab="spl-token">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Deriving the vault's token account</span></div>
<div className="sol-run-out">

```text Output
Wallet address: CKfxdA7YLKW8JxmCVQXDBJ43HRnwHKTUbQSVxRKgoHcP
Associated token address: Ag9Hfo8UdcsGgw7jRt44Zf3WEEafr51KAk7ZVnmiqv4k
```

</div>
</div>

Export the `Associated token address` it prints as `VAULT_ATA`:

```bash Terminal
export VAULT_ATA=<the associated token address>
```

Then read the account with `spl-token`, or run the `read-account` script with
`$VAULT_ATA`:

<Tabs>
<Tab title="spl-token">
<div className="sol-tab-label">spl-token</div>

```bash
spl-token display $VAULT_ATA --url ${RPC_URL:-devnet}
```

<div className="sol-run" data-run="paths/assets/gated-token/read-vault" data-tab="spl-token">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Reading the vault's token account after the deposit</span></div>
<div className="sol-run-out">

```text Output

SPL Token Account
  Address: Ag9Hfo8UdcsGgw7jRt44Zf3WEEafr51KAk7ZVnmiqv4k
  Program: TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
  Balance: 1
  Decimals: 6
  Mint: 8ComqBcog3Aig4hYN9PcCQHcK4rCCUhv7QoxUfrVVB66
  Owner: CKfxdA7YLKW8JxmCVQXDBJ43HRnwHKTUbQSVxRKgoHcP
  State: Initialized
  Delegation: (not set)
  Close authority: (not set)
Extensions:
  Immutable owner

* This token has a permanent delegate! 
  This means the mint may withdraw all funds from this account at any time.
  If this was not adequately disclosed to you, you may be dealing with a malicious mint.
```

</div>
</div>

</Tab>
<Tab title="Kit">
<div className="sol-tab-label">Kit</div>

```ts
// npx tsx read-account.ts <token account> [commitment]
import { address, type Commitment } from "@solana/kit";
import { AccountState, fetchToken } from "@solana-program/token-2022";
import { arg, rpc } from "./common";

const tokenAccount = address(arg(1, "the token account"));
// Read at a stated commitment level. Use "finalized" for anything that feeds
// a book of record; "confirmed" is enough for a display.
const commitment = (process.argv[3] ?? "confirmed") as Commitment;

const { data } = await fetchToken(rpc, tokenAccount, { commitment });
console.log("Mint:", data.mint);
console.log("Owner:", data.owner);
console.log("Balance (base units):", data.amount.toString());
console.log("State:", AccountState[data.state]);
```

<div className="sol-run" data-run="paths/assets/gated-token/read-vault" data-tab="Kit">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Reading the vault's token account after the deposit</span></div>
<div className="sol-run-out">

```text Output
Mint: 8ComqBcog3Aig4hYN9PcCQHcK4rCCUhv7QoxUfrVVB66
Owner: CKfxdA7YLKW8JxmCVQXDBJ43HRnwHKTUbQSVxRKgoHcP
Balance (base units): 1000000
State: Initialized
```

</div>
</div>

</Tab>
<Tab title="Web3.js v3">
<div className="sol-tab-label">Web3.js v3</div>

```ts
// npx tsx read-account.ts <token account> [commitment]
import { type Commitment, PublicKey } from "@solana/web3.js";
import { AccountState, getTokenDecoder } from "@solana-program/token-2022";
import { arg, connection } from "./common";

const tokenAccount = new PublicKey(arg(1, "the token account"));
// Read at a stated commitment level. Use "finalized" for anything that feeds
// a book of record; "confirmed" is enough for a display.
const commitment = (process.argv[3] ?? "confirmed") as Commitment;

const info = await connection.getAccountInfo(tokenAccount, commitment);
const data = getTokenDecoder().decode(info!.data);
console.log("Mint:", data.mint);
console.log("Owner:", data.owner);
console.log("Balance (base units):", data.amount.toString());
console.log("State:", AccountState[data.state]);
```

<div className="sol-run" data-run="paths/assets/gated-token/read-vault" data-tab="Web3.js v3">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Reading the vault's token account after the deposit</span></div>
<div className="sol-run-out">

```text Output
Mint: 8xDpQoKEXGrtCm5JwseD2v7KHCNnXv8kQmm61Cjozn7o
Owner: 9wBAjmtCpu5Aj7F24X7dnZZzez9x4SQZxs182TxZpUNw
Balance (base units): 1000000
State: Initialized
```

</div>
</div>

</Tab>
<Tab title="Rust">
<div className="sol-tab-label">Rust</div>

```rust
// cargo run --release --bin read-account -- <token account> [commitment]
use anyhow::{anyhow, Result};
use gated_token::{arg, arg_pubkey, rpc_with};
use solana_commitment_config::CommitmentConfig;
use spl_token_2022_interface::{
    extension::StateWithExtensions,
    state::{Account, AccountState},
};

#[tokio::main]
async fn main() -> Result<()> {
    let token_account = arg_pubkey(1, "the token account")?;
    // Read at a stated commitment level. Use "finalized" for anything that
    // feeds a book of record; "confirmed" is enough for a display.
    let commitment = match arg(2, "the commitment").as_deref() {
        Ok("finalized") => CommitmentConfig::finalized(),
        _ => CommitmentConfig::confirmed(),
    };
    let rpc = rpc_with(commitment);
    let account = rpc
        .get_account_with_commitment(&token_account, commitment)
        .await?
        .value
        .ok_or_else(|| anyhow!("{token_account} not found at {commitment:?}"))?;
    let state = StateWithExtensions::<Account>::unpack(&account.data)?.base;

    println!("Mint: {}", state.mint);
    println!("Owner: {}", state.owner);
    println!("Balance (base units): {}", state.amount);
    let label = if state.state == AccountState::Frozen {
        "Frozen"
    } else {
        "Initialized"
    };
    println!("State: {label}");
    Ok(())
}
```

<div className="sol-run" data-run="paths/assets/gated-token/read-vault" data-tab="Rust">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Reading the vault's token account after the deposit</span></div>
<div className="sol-run-out">

```text Output
Mint: 3zsS4p5aDBiqLmCynUBayqCM9WWR35jr51tT4maAT1P1
Owner: 8EF4uE7bL76WFJNah2nC5sCiYXH1KDZvALFeSKQwtCXM
Balance (base units): 1000000
State: Initialized
```

</div>
</div>

</Tab>
</Tabs>

**State** must read `Initialized`. `Frozen` means the account is gated out, and
any deposit or settlement that touches it will fail.

</Step>

<Step title="Confirm what a pause does to the vault">

A pause of the token stops the vault along with everything else: requests in
progress cannot settle while it holds. Issuer side:

<CodeGroup>
```bash TypeScript
npx tsx pause.ts
```

```bash Rust
cargo run --release --bin pause
```
</CodeGroup>

With the token paused, the same deposit fails with `0x43` (67), Token-2022's
`MintPaused`:

<Tabs>
<Tab title="Mosaic SDK">
<div className="sol-tab-label">Mosaic SDK</div>

```ts
// npx tsx transfer.ts <recipient> <amount>
import { address } from "@solana/kit";
import { createTransferTransaction } from "@solana/mosaic-sdk";
import { arg, env, loadSigner, rpc, sendMessage } from "./common";

// The holder signs and pays for its own transfer.
const holder = await loadSigner("demo-holder");
const mint = address(env("MINT"));

// Creates the recipient's token account if it is missing and thaws it
// through the gate before the transfer, so the gate decides whether the
// recipient may hold the token.
await sendMessage(
  await createTransferTransaction({
    rpc,
    mint,
    from: holder.address,
    to: address(arg(1, "the recipient wallet")),
    feePayer: holder,
    authority: holder,
    amount: arg(2, "the amount"),
  }),
);
```

<div className="sol-run" data-run="paths/assets/gated-token/transfer-vault-paused" data-tab="Mosaic SDK">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Sending 1 to the vault while the token is paused</span></div>
<div className="sol-run-out">

```text Output
Failed: Program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb failed: custom program error: 0x43
```

</div>
</div>

</Tab>
<Tab title="Kit">
<div className="sol-tab-label">Kit</div>

```ts
// npx tsx transfer.ts <recipient> <amount>
import { address } from "@solana/kit";
import {
  fetchMint,
  findAssociatedTokenPda,
  getTransferCheckedInstruction,
  TOKEN_2022_PROGRAM_ADDRESS,
} from "@solana-program/token-2022";
import { arg, env, loadSigner, rpc, send, toBaseUnits } from "./common";
import { openThroughGate } from "./gate";

// The holder signs and pays for its own transfer.
const holder = await loadSigner("demo-holder");
const mint = address(env("MINT"));
const list = address(env("LIST"));
const { data } = await fetchMint(rpc, mint);

const [source] = await findAssociatedTokenPda({
  mint,
  owner: holder.address,
  tokenProgram: TOKEN_2022_PROGRAM_ADDRESS,
});
// The thaw is where an unlisted recipient fails: the gate rejects the owner
// and the whole transaction is dropped before any token moves.
const { tokenAccount: destination, instructions } = await openThroughGate(
  holder,
  mint,
  address(arg(1, "the recipient wallet")),
  list,
);
await send(holder, [
  ...instructions,
  getTransferCheckedInstruction({
    source,
    mint,
    destination,
    authority: holder,
    amount: toBaseUnits(arg(2, "the amount"), data.decimals),
    decimals: data.decimals,
  }),
]);
```

<div className="sol-run" data-run="paths/assets/gated-token/transfer-vault-paused" data-tab="Kit">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Sending 1 to the vault while the token is paused</span></div>
<div className="sol-run-out">

```text Output
Failed: Program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb failed: custom program error: 0x43
```

</div>
</div>

</Tab>
<Tab title="Web3.js v3">
<div className="sol-tab-label">Web3.js v3</div>

```ts
// npx tsx transfer.ts <recipient> <amount>
import { PublicKey } from "@solana/web3.js";
import {
  findAssociatedTokenPda,
  getMintDecoder,
  getTransferCheckedInstruction,
  TOKEN_2022_PROGRAM_ADDRESS,
} from "@solana-program/token-2022";
import {
  addressOf,
  arg,
  connection,
  env,
  loadKeypair,
  send,
  toBaseUnits,
} from "./common";
import { openThroughGate } from "./gate";

// The holder signs and pays for its own transfer.
const holder = await loadKeypair("demo-holder");
const mint = addressOf(env("MINT"));
const list = addressOf(env("LIST"));
const mintAccount = await connection.getAccountInfo(new PublicKey(mint));
const { decimals } = getMintDecoder().decode(mintAccount!.data);

const [source] = await findAssociatedTokenPda({
  mint,
  owner: holder.publicKey.toBase58(),
  tokenProgram: TOKEN_2022_PROGRAM_ADDRESS,
});
// The thaw is where an unlisted recipient fails: the gate rejects the owner
// and the whole transaction is dropped before any token moves.
const { tokenAccount: destination, instructions } = await openThroughGate(
  holder,
  mint,
  addressOf(arg(1, "the recipient wallet")),
  list,
);
await send(
  [holder],
  [
    ...instructions,
    getTransferCheckedInstruction({
      source,
      mint,
      destination,
      authority: holder,
      amount: toBaseUnits(arg(2, "the amount"), decimals),
      decimals,
    }),
  ],
);
```

<div className="sol-run" data-run="paths/assets/gated-token/transfer-vault-paused" data-tab="Web3.js v3">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Sending 1 to the vault while the token is paused</span></div>
<div className="sol-run-out">

```text Output
Failed: Program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb failed: custom program error: 0x43
```

</div>
</div>

</Tab>
<Tab title="Rust">
<div className="sol-tab-label">Rust</div>

```rust
// cargo run --release --bin transfer -- <recipient> <amount>
use anyhow::Result;
use gated_token::{
    acl, arg, arg_pubkey, ata, env, load_keypair, mint_decimals, rpc, send, to_base_units,
    TOKEN_2022,
};
use solana_sdk::signature::Signer;
use spl_token_2022_interface::instruction::transfer_checked;

#[tokio::main]
async fn main() -> Result<()> {
    let rpc = rpc();
    // The holder signs and pays for its own transfer.
    let holder = load_keypair("demo-holder")?;
    let mint = env("MINT")?;
    let list = env("LIST")?;
    let recipient = arg_pubkey(1, "the recipient wallet")?;
    let decimals = mint_decimals(&rpc, &mint).await?;

    // The thaw is where an unlisted recipient fails: the gate rejects the
    // owner and the whole transaction is dropped before any token moves.
    let (destination, mut instructions) =
        acl::open_through_gate(&rpc, &holder.pubkey(), &mint, &recipient, &list).await?;
    instructions.push(transfer_checked(
        &TOKEN_2022,
        &ata(&mint, &holder.pubkey()),
        &mint,
        &destination,
        &holder.pubkey(),
        &[],
        to_base_units(&arg(2, "the amount")?, decimals)?,
        decimals,
    )?);
    send(&rpc, &[&holder], &instructions).await
}
```

<div className="sol-run" data-run="paths/assets/gated-token/transfer-vault-paused" data-tab="Rust">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Sending 1 to the vault while the token is paused</span></div>
<div className="sol-run-out">

```text Output
Failed: Program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb failed: custom program error: 0x43
```

</div>
</div>

</Tab>
</Tabs>

Then resume, issuer side:

<CodeGroup>
```bash TypeScript
npx tsx resume.ts
```

```bash Rust
cargo run --release --bin resume
```
</CodeGroup>

</Step>

</Steps>

## Building the vault itself

The remaining decisions are set out in
[vault architectures](/developers/docs/tokenization/custody/vault-architectures):
whether the design is synchronous or request-and-settle, what is escrowed at
request time, how the cut-off is enforced, who may publish a valuation, and
what happens to a request that cannot settle.

If subscriptions or redemptions are to settle through the
[DvP program](/developers/docs/defi/dvp-program), note that it rejects mints
carrying Scaled UI Amount, which this tutorial's mint has.

## Next steps

- [Vault architectures](/developers/docs/tokenization/custody/vault-architectures):
  the design decisions behind the program
- [NAV strikes](/developers/docs/tokenization/nav-strikes): a full
  request-and-settle implementation for a fund
- [Vault Standard Suite](https://github.com/solana-foundation/vault): the
  reference vault program to read and adapt (see its repository for deployment
  and review status)
