> ## 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.

# Create the mint

> Create a Token-2022 mint for a tokenized security with frozen-by-default accounts, pause, a permanent delegate, permissioned burn, and an onchain allowlist, with each operational authority on its own key.

This step creates the mint: a Token-2022 mint with the extension set of
Mosaic's tokenized-security template, gated by an onchain allowlist, with the
pause, permanent delegate, permissioned burn, and metadata authorities on
separate keys. The mint, Confidential Balances, and Scaled UI Amount
authorities stay on the fee payer. It assumes you have done the setup in
[before you start](/developers/docs/tokenization/tutorials/issuing#before-you-start).

<Steps titleSize="h2">

<Step title="Map the authorities">

Each operational power has its own key, from the four you generated in the
setup. If one key held every power, one compromise would expose all of them.
In production each can sit in its own custody arrangement: an
incident-response key for pause, a legal and compliance quorum for the
permanent delegate, a redemption-operations key for permissioned burn, and a
low-privilege operations key for metadata.

```mermaid
flowchart LR
  accTitle: Who holds each authority on the tutorial mint
  accDescr: The fee payer holds the mint, Confidential Balances, and Scaled UI Amount authorities and the Token ACL config and allowlist. The freeze authority belongs to the Token ACL mint config, and it also governs the default account state. Pause, permanent delegate, permissioned burn, and metadata each have their own key. Two settings are not used on this mint: an optional auditor key, which the Confidential Balances authority can set and which decrypts transfer amounts without signing anything, and a transfer hook, which the tokenized-security template does not include.
  P["Fee payer<br/>tokenization-demo.json"] --> A1["Mint, Confidential Balances, Scaled UI Amount<br/>Token ACL config and allowlist authority"]
  A1 -.->|can set| AUD["Auditor key, optional<br/>Not set on this mint<br/>Decrypts transfer amounts, not a signer"]
  T["Token ACL mint config<br/>PDA of the Token ACL program"] --> A2["Freeze authority<br/>Freezes and thaws accounts<br/>Also governs the default account state"]
  K1["pause.json"] --> A3["Pause authority<br/>Halts mint, burn, and transfer"]
  K2["delegate.json"] --> A4["Permanent delegate<br/>Moves or burns any holder's balance"]
  K3["burn.json"] --> A5["Permissioned burn authority<br/>Co-signs every burn"]
  K4["metadata.json"] --> A6["Metadata and metadata pointer<br/>Changes name, symbol, and URI"]
  H["Transfer hook authority<br/>Not in this template"] -.-> HP["Hook program<br/>Would run on every transfer"]
  class T focal
```

<div className="sol-mermaid" data-fallback="mermaid" data-mermaid="be0803dfbb67">
  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/be0803dfbb67-light.svg" alt="Who holds each authority on the tutorial mint. The fee payer holds the mint, Confidential Balances, and Scaled UI Amount authorities and the Token ACL config and allowlist. The freeze authority belongs to the Token ACL mint config, and it also governs the default account state. Pause, permanent delegate, permissioned burn, and metadata each have their own key. Two settings are not used on this mint: an optional auditor key, which the Confidential Balances authority can set and which decrypts transfer amounts without signing anything, and a transfer hook, which the tokenized-security template does not include." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/be0803dfbb67.svg" alt="Who holds each authority on the tutorial mint. The fee payer holds the mint, Confidential Balances, and Scaled UI Amount authorities and the Token ACL config and allowlist. The freeze authority belongs to the Token ACL mint config, and it also governs the default account state. Pause, permanent delegate, permissioned burn, and metadata each have their own key. Two settings are not used on this mint: an optional auditor key, which the Confidential Balances authority can set and which decrypts transfer amounts without signing anything, and a transfer hook, which the tokenized-security template does not include." />

  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/be0803dfbb67-sm-light.svg" alt="Who holds each authority on the tutorial mint. The fee payer holds the mint, Confidential Balances, and Scaled UI Amount authorities and the Token ACL config and allowlist. The freeze authority belongs to the Token ACL mint config, and it also governs the default account state. Pause, permanent delegate, permissioned burn, and metadata each have their own key. Two settings are not used on this mint: an optional auditor key, which the Confidential Balances authority can set and which decrypts transfer amounts without signing anything, and a transfer hook, which the tokenized-security template does not include." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/be0803dfbb67-sm.svg" alt="Who holds each authority on the tutorial mint. The fee payer holds the mint, Confidential Balances, and Scaled UI Amount authorities and the Token ACL config and allowlist. The freeze authority belongs to the Token ACL mint config, and it also governs the default account state. Pause, permanent delegate, permissioned burn, and metadata each have their own key. Two settings are not used on this mint: an optional auditor key, which the Confidential Balances authority can set and which decrypts transfer amounts without signing anything, and a transfer hook, which the tokenized-security template does not include." />
</div>

<Warning>
The mint authority is the exception. The freeze authority starts on the mint
authority, and Token ACL's create config instruction needs that key to sign
before it takes the freeze authority over. The same key then becomes the
authority of the Token ACL config and of the allowlist. This tutorial keeps it
on the fee payer, in all four implementations, so one key signs. A supervised
issuance would hold the mint authority on a treasury quorum, which then signs
the creation and every change to the list; see
[program and authority design](/developers/docs/tokenization/design/program-and-authority-design).
</Warning>

</Step>

<Step title="Create the mint">

Save this as `create-the-mint.ts` (in Rust, `src/bin/create-the-mint.rs`) and
run it. One transaction creates the mint with its extensions, creates the Token
ACL config for the mint, points it at the gate program, turns on
permissionless thaw, and creates the allowlist.

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

```ts
// npx tsx create-the-mint.ts
import { generateKeyPairSigner } from "@solana/kit";
import {
  createTokenizedSecurityInitTransaction,
  getListConfigPda,
  inspectToken,
} from "@solana/mosaic-sdk";
import { loadSigner, rpc, sendMessage } from "./common";

const payer = await loadSigner("tokenization-demo");
// One address per operational power, from the keys generated in step 1.
const authority = async (role: string) =>
  (await loadSigner(`demo-authorities/${role}`)).address;

const mint = await generateKeyPairSigner();

// The fee payer is also the mint authority here, so the same transaction can
// create the Token ACL config, the allowlist, and permissionless thaw.
const transaction = await createTokenizedSecurityInitTransaction(
  rpc,
  "Demo Tokenized Note",
  "DEMOTN",
  6,
  "https://example.com/demotn.json",
  payer, // mint authority
  mint,
  payer, // fee payer
  undefined,
  {
    aclMode: "allowlist",
    enableSrfc37: true,
    metadataAuthority: await authority("metadata"),
    pausableAuthority: await authority("pause"),
    permanentDelegateAuthority: await authority("delegate"),
    permissionedBurnAuthority: await authority("burn"),
  },
);
await sendMessage(transaction);

const token = await inspectToken(rpc, mint.address, "confirmed");
console.log("Mint:", mint.address);
console.log(
  "Allowlist:",
  await getListConfigPda({ authority: payer.address, mint: mint.address }),
);
console.log(
  "Freeze authority (Token ACL mint config):",
  token.authorities.freezeAuthority,
);
```

<div className="sol-run" data-run="paths/assets/gated-token/create" data-tab="Mosaic SDK">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Creating the mint, its Token ACL config, and its allowlist</span></div>
<div className="sol-run-out">

```text Output
Signature: 4EMYY9zRUAsWu7daz8t6RSSTnmn1Vu9MvY1GfPEtGFGcKc2dvGxCqLuS7vATVFAnDyqVFuMtwN6D4KQZ1HyT3nHY
Mint: 653XZoSFLEb7BuezYeLTiq5KBsdFDHZ71MfsybEzHr9G
Allowlist: 7VZfn6MWo2KxHySn7c3zvMSdm6DGbAfUh3HCcpTCAxsh
Freeze authority (Token ACL mint config): DMoNpevW1mVh6DiGGDtd6cLNsrSjsHpFjuGktGFLC1f7
```

</div>
</div>

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

```ts
// npx tsx create-the-mint.ts
import { generateKeyPairSigner, none, some } from "@solana/kit";
import { getCreateAccountInstruction } from "@solana-program/system";
import {
  AccountState,
  extension,
  getInitializeConfidentialTransferMintInstruction,
  getInitializeDefaultAccountStateInstruction,
  getInitializeMetadataPointerInstruction,
  getInitializeMintInstruction,
  getInitializePausableConfigInstruction,
  getInitializePermanentDelegateInstruction,
  getInitializePermissionedBurnInstruction,
  getInitializeScaledUiAmountMintInstruction,
  getInitializeTokenMetadataInstruction,
  getMintSize,
  TOKEN_2022_PROGRAM_ADDRESS,
} from "@solana-program/token-2022";
import {
  findMintConfigPda,
  findThawExtraMetasAccountPda,
  getCreateConfigInstructionAsync,
  getTogglePermissionlessInstructionsInstruction,
} from "@solana/token-acl-sdk";
import {
  findListConfigPda,
  getCreateListInstruction,
  getSetupExtraMetasInstruction,
  Mode,
  TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS,
} from "@solana/token-acl-gate-sdk";
import { loadSigner, rpc, send } from "./common";

const payer = await loadSigner("tokenization-demo");
// One address per operational power, from the keys generated in step 1.
const authority = async (role: string) =>
  (await loadSigner(`demo-authorities/${role}`)).address;
const metadataAuthority = await authority("metadata");
const pauseAuthority = await authority("pause");
const permanentDelegate = await authority("delegate");
const burnAuthority = await authority("burn");

const mint = await generateKeyPairSigner();
const [name, symbol, uri] = [
  "Demo Tokenized Note",
  "DEMOTN",
  "https://example.com/demotn.json",
];

// The extension set the Mosaic tokenized-security template turns on.
const extensions = [
  extension("MetadataPointer", {
    authority: some(metadataAuthority),
    metadataAddress: some(mint.address),
  }),
  extension("TokenMetadata", {
    updateAuthority: some(metadataAuthority),
    mint: mint.address,
    name,
    symbol,
    uri,
    additionalMetadata: new Map<string, string>(),
  }),
  extension("PausableConfig", {
    authority: some(pauseAuthority),
    paused: false,
  }),
  extension("DefaultAccountState", { state: AccountState.Frozen }),
  extension("ConfidentialTransferMint", {
    authority: some(payer.address),
    autoApproveNewAccounts: false,
    auditorElgamalPubkey: none(),
  }),
  extension("PermanentDelegate", { delegate: permanentDelegate }),
  extension("PermissionedBurn", { authority: some(burnAuthority) }),
  extension("ScaledUiAmountConfig", {
    authority: payer.address,
    multiplier: 1,
    newMultiplierEffectiveTimestamp: 0n,
    newMultiplier: 1,
  }),
];

// Rent covers the full size including metadata. The account is allocated
// without the metadata bytes, because initializing metadata reallocates it.
const space = getMintSize(
  extensions.filter((ext) => ext.__kind !== "TokenMetadata"),
);
const rent = await rpc
  .getMinimumBalanceForRentExemption(BigInt(getMintSize(extensions)))
  .send();

const mintInstructions = [
  getCreateAccountInstruction({
    payer,
    newAccount: mint,
    lamports: rent,
    space,
    programAddress: TOKEN_2022_PROGRAM_ADDRESS,
  }),
  // Extension configs are initialized before the mint itself.
  getInitializeMetadataPointerInstruction({
    mint: mint.address,
    authority: metadataAuthority,
    metadataAddress: mint.address,
  }),
  getInitializePausableConfigInstruction({
    mint: mint.address,
    authority: pauseAuthority,
  }),
  getInitializeDefaultAccountStateInstruction({
    mint: mint.address,
    state: AccountState.Frozen,
  }),
  getInitializeConfidentialTransferMintInstruction({
    mint: mint.address,
    authority: payer.address,
    autoApproveNewAccounts: false,
    auditorElgamalPubkey: null,
  }),
  getInitializePermanentDelegateInstruction({
    mint: mint.address,
    delegate: permanentDelegate,
  }),
  getInitializePermissionedBurnInstruction({
    mint: mint.address,
    authority: burnAuthority,
  }),
  getInitializeScaledUiAmountMintInstruction({
    mint: mint.address,
    authority: payer.address,
    multiplier: 1,
  }),
  // The freeze authority starts on the payer: Token ACL's create config needs
  // the current freeze authority to sign, then moves it to the mint config.
  getInitializeMintInstruction({
    mint: mint.address,
    decimals: 6,
    mintAuthority: payer.address,
    freezeAuthority: payer.address,
  }),
  getInitializeTokenMetadataInstruction({
    metadata: mint.address,
    updateAuthority: metadataAuthority,
    mint: mint.address,
    mintAuthority: payer,
    name,
    symbol,
    uri,
  }),
];

// The Token ACL config plus the gate program's allowlist. Permissionless thaw
// lets anyone open an allowlisted holder's account by paying the fee.
const gate = TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS;
const [mintConfig] = await findMintConfigPda({ mint: mint.address });
const [listConfig] = await findListConfigPda({
  authority: payer.address,
  seed: mint.address,
});
const [extraMetas] = await findThawExtraMetasAccountPda(
  { mint: mint.address },
  { programAddress: gate },
);
const gateInstructions = [
  await getCreateConfigInstructionAsync({
    payer: payer.address,
    authority: payer,
    mint: mint.address,
    gatingProgram: gate,
  }),
  getTogglePermissionlessInstructionsInstruction({
    authority: payer,
    mintConfig,
    freezeEnabled: false,
    thawEnabled: true,
  }),
  getCreateListInstruction({
    authority: payer,
    payer,
    listConfig,
    mode: Mode.Allow,
    seed: mint.address,
  }),
  getSetupExtraMetasInstruction({
    authority: payer,
    payer,
    tokenAclMintConfig: mintConfig,
    mint: mint.address,
    extraMetas,
    addresses: [listConfig],
  }),
];

await send(payer, [...mintInstructions, ...gateInstructions]);
console.log("Mint:", mint.address);
console.log("Allowlist:", listConfig);
console.log("Freeze authority (Token ACL mint config):", mintConfig);
```

<div className="sol-run" data-run="paths/assets/gated-token/create" data-tab="Kit">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Creating the mint, its Token ACL config, and its allowlist</span></div>
<div className="sol-run-out">

```text Output
Signature: 5uPXQpSacA2NcFEMHbfQyy34L191KtVN5GvNvnRJJnE799U4KtQprbFR8Y94nhYW81kP3EgfmAvMmpMgxmwYrx2y
Mint: 8ComqBcog3Aig4hYN9PcCQHcK4rCCUhv7QoxUfrVVB66
Allowlist: 4jLUb27keHXA2T99sudNRN4ohynsPw4zjaAowhFDpkmN
Freeze authority (Token ACL mint config): UUNTF54aKsEw57DmFS1SE2v6ARQnAXt7cGTZV1xY79P
```

</div>
</div>

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

```ts
// npx tsx create-the-mint.ts
import { none, some } from "@solana/kit";
import { Keypair } from "@solana/web3.js";
import { getCreateAccountInstruction } from "@solana-program/system";
import {
  AccountState,
  extension,
  getInitializeConfidentialTransferMintInstruction,
  getInitializeDefaultAccountStateInstruction,
  getInitializeMetadataPointerInstruction,
  getInitializeMintInstruction,
  getInitializePausableConfigInstruction,
  getInitializePermanentDelegateInstruction,
  getInitializePermissionedBurnInstruction,
  getInitializeScaledUiAmountMintInstruction,
  getInitializeTokenMetadataInstruction,
  getMintSize,
  TOKEN_2022_PROGRAM_ADDRESS,
} from "@solana-program/token-2022";
import {
  findMintConfigPda,
  findThawExtraMetasAccountPda,
  getCreateConfigInstructionAsync,
  getTogglePermissionlessInstructionsInstruction,
} from "@solana/token-acl-sdk";
import {
  findListConfigPda,
  getCreateListInstruction,
  getSetupExtraMetasInstruction,
  Mode,
  TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS,
} from "@solana/token-acl-gate-sdk";
import { connection, loadKeypair, send } from "./common";

const payer = await loadKeypair("tokenization-demo");
// One address per operational power, from the keys generated in step 1.
const authority = async (role: string) =>
  (await loadKeypair(`demo-authorities/${role}`)).publicKey.toBase58();
const metadataAuthority = await authority("metadata");
const pauseAuthority = await authority("pause");
const permanentDelegate = await authority("delegate");
const burnAuthority = await authority("burn");

const mint = await Keypair.generate();
const mintAddress = mint.publicKey.toBase58();
const payerAddress = payer.publicKey.toBase58();
const [name, symbol, uri] = [
  "Demo Tokenized Note",
  "DEMOTN",
  "https://example.com/demotn.json",
];

// The extension set the Mosaic tokenized-security template turns on.
const extensions = [
  extension("MetadataPointer", {
    authority: some(metadataAuthority),
    metadataAddress: some(mintAddress),
  }),
  extension("TokenMetadata", {
    updateAuthority: some(metadataAuthority),
    mint: mintAddress,
    name,
    symbol,
    uri,
    additionalMetadata: new Map<string, string>(),
  }),
  extension("PausableConfig", {
    authority: some(pauseAuthority),
    paused: false,
  }),
  extension("DefaultAccountState", { state: AccountState.Frozen }),
  extension("ConfidentialTransferMint", {
    authority: some(payerAddress),
    autoApproveNewAccounts: false,
    auditorElgamalPubkey: none(),
  }),
  extension("PermanentDelegate", { delegate: permanentDelegate }),
  extension("PermissionedBurn", { authority: some(burnAuthority) }),
  extension("ScaledUiAmountConfig", {
    authority: payerAddress,
    multiplier: 1,
    newMultiplierEffectiveTimestamp: 0n,
    newMultiplier: 1,
  }),
];

// Rent covers the full size including metadata. The account is allocated
// without the metadata bytes, because initializing metadata reallocates it.
const space = getMintSize(
  extensions.filter((ext) => ext.__kind !== "TokenMetadata"),
);
const rent = BigInt(
  await connection.getMinimumBalanceForRentExemption(getMintSize(extensions)),
);

const mintInstructions = [
  getCreateAccountInstruction({
    payer,
    newAccount: mint,
    lamports: rent,
    space,
    programAddress: TOKEN_2022_PROGRAM_ADDRESS,
  }),
  // Extension configs are initialized before the mint itself.
  getInitializeMetadataPointerInstruction({
    mint: mintAddress,
    authority: metadataAuthority,
    metadataAddress: mintAddress,
  }),
  getInitializePausableConfigInstruction({
    mint: mintAddress,
    authority: pauseAuthority,
  }),
  getInitializeDefaultAccountStateInstruction({
    mint: mintAddress,
    state: AccountState.Frozen,
  }),
  getInitializeConfidentialTransferMintInstruction({
    mint: mintAddress,
    authority: payerAddress,
    autoApproveNewAccounts: false,
    auditorElgamalPubkey: null,
  }),
  getInitializePermanentDelegateInstruction({
    mint: mintAddress,
    delegate: permanentDelegate,
  }),
  getInitializePermissionedBurnInstruction({
    mint: mintAddress,
    authority: burnAuthority,
  }),
  getInitializeScaledUiAmountMintInstruction({
    mint: mintAddress,
    authority: payerAddress,
    multiplier: 1,
  }),
  // The freeze authority starts on the payer: Token ACL's create config needs
  // the current freeze authority to sign, then moves it to the mint config.
  getInitializeMintInstruction({
    mint: mintAddress,
    decimals: 6,
    mintAuthority: payerAddress,
    freezeAuthority: payerAddress,
  }),
  getInitializeTokenMetadataInstruction({
    metadata: mintAddress,
    updateAuthority: metadataAuthority,
    mint: mintAddress,
    mintAuthority: payer,
    name,
    symbol,
    uri,
  }),
];

// The Token ACL config plus the gate program's allowlist. Permissionless thaw
// lets anyone open an allowlisted holder's account by paying the fee.
const gate = TOKEN_ACL_GATE_PROGRAM_PROGRAM_ADDRESS;
const [mintConfig] = await findMintConfigPda({ mint: mintAddress });
const [listConfig] = await findListConfigPda({
  authority: payerAddress,
  seed: mintAddress,
});
const [extraMetas] = await findThawExtraMetasAccountPda(
  { mint: mintAddress },
  { programAddress: gate },
);
const gateInstructions = [
  await getCreateConfigInstructionAsync({
    payer: payerAddress,
    authority: payer,
    mint: mintAddress,
    gatingProgram: gate,
  }),
  getTogglePermissionlessInstructionsInstruction({
    authority: payer,
    mintConfig,
    freezeEnabled: false,
    thawEnabled: true,
  }),
  getCreateListInstruction({
    authority: payer,
    payer,
    listConfig,
    mode: Mode.Allow,
    seed: mintAddress,
  }),
  getSetupExtraMetasInstruction({
    authority: payer,
    payer,
    tokenAclMintConfig: mintConfig,
    mint: mintAddress,
    extraMetas,
    addresses: [listConfig],
  }),
];

await send([payer, mint], [...mintInstructions, ...gateInstructions]);
console.log("Mint:", mintAddress);
console.log("Allowlist:", listConfig);
console.log("Freeze authority (Token ACL mint config):", mintConfig);
```

<div className="sol-run" data-run="paths/assets/gated-token/create" data-tab="Web3.js v3">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Creating the mint, its Token ACL config, and its allowlist</span></div>
<div className="sol-run-out">

```text Output
Signature: 5SHgFtAihn2Q5hVhXBbs21K2B2HjsuLXUNXcTp1hjTYMC3LPY36DnLepG7Z54MdpFoXJu7tNxzm6AmaR6vaCdXU8
Mint: 8xDpQoKEXGrtCm5JwseD2v7KHCNnXv8kQmm61Cjozn7o
Allowlist: DPVXMbK2kckwTeGXDntCyDNpnKHzaSboEMJeeYq5nTvJ
Freeze authority (Token ACL mint config): GM28GNtb2Wmj4sPqpvV7aAxxWy78JqSNVnksdndFJNna
```

</div>
</div>

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

```rust
// cargo run --release --bin create-the-mint
use anyhow::{anyhow, Result};
use gated_token::{acl, load_keypair, rpc, send, TOKEN_2022};
use solana_sdk::signature::{Keypair, Signer};
use solana_system_interface::instruction::create_account;
use spl_token_2022_interface::{
    extension::{
        confidential_transfer, default_account_state, metadata_pointer, pausable,
        permissioned_burn, scaled_ui_amount, ExtensionType,
    },
    instruction::{initialize_mint2, initialize_permanent_delegate},
    state::{AccountState, Mint},
};
use spl_token_metadata_interface::{
    instruction::initialize as initialize_metadata, state::TokenMetadata,
};

#[tokio::main]
async fn main() -> Result<()> {
    let rpc = rpc();
    let payer = load_keypair("tokenization-demo")?;
    // One address per operational power, from the keys generated in step 1.
    let authority = |role: &str| -> Result<_> {
        Ok(load_keypair(&format!("demo-authorities/{role}"))?.pubkey())
    };
    let metadata_authority = authority("metadata")?;
    let pause_authority = authority("pause")?;
    let permanent_delegate = authority("delegate")?;
    let burn_authority = authority("burn")?;

    let mint = Keypair::new();
    let metadata = TokenMetadata {
        update_authority: Some(metadata_authority)
            .try_into()
            .map_err(|_| anyhow!("authority"))?,
        mint: mint.pubkey(),
        name: "Demo Tokenized Note".to_string(),
        symbol: "DEMOTN".to_string(),
        uri: "https://example.com/demotn.json".to_string(),
        additional_metadata: vec![],
    };

    // The extension set the Mosaic tokenized-security template turns on. Rent
    // covers the metadata too; the account is allocated without it because
    // initializing metadata reallocates it.
    let space = ExtensionType::try_calculate_account_len::<Mint>(&[
        ExtensionType::MetadataPointer,
        ExtensionType::Pausable,
        ExtensionType::DefaultAccountState,
        ExtensionType::ConfidentialTransferMint,
        ExtensionType::PermanentDelegate,
        ExtensionType::PermissionedBurn,
        ExtensionType::ScaledUiAmount,
    ])?;
    let rent = rpc
        .get_minimum_balance_for_rent_exemption(space + metadata.tlv_size_of()?)
        .await?;

    let (payer_key, mint_key) = (payer.pubkey(), mint.pubkey());
    let instructions = vec![
        create_account(&payer_key, &mint_key, rent, space as u64, &TOKEN_2022),
        // Extension configs are initialized before the mint itself.
        metadata_pointer::instruction::initialize(
            &TOKEN_2022,
            &mint_key,
            Some(metadata_authority),
            Some(mint_key),
        )?,
        pausable::instruction::initialize(&TOKEN_2022, &mint_key, &pause_authority)?,
        default_account_state::instruction::initialize_default_account_state(
            &TOKEN_2022,
            &mint_key,
            &AccountState::Frozen,
        )?,
        confidential_transfer::instruction::initialize_mint(
            &TOKEN_2022,
            &mint_key,
            Some(payer_key),
            false,
            None,
        )?,
        initialize_permanent_delegate(&TOKEN_2022, &mint_key, &permanent_delegate)?,
        permissioned_burn::instruction::initialize(&TOKEN_2022, &mint_key, &burn_authority)?,
        scaled_ui_amount::instruction::initialize(&TOKEN_2022, &mint_key, Some(payer_key), 1.0)?,
        // The freeze authority starts on the payer: Token ACL's create config
        // needs the current freeze authority to sign, then moves it to the
        // mint config.
        initialize_mint2(&TOKEN_2022, &mint_key, &payer_key, Some(&payer_key), 6)?,
        initialize_metadata(
            &TOKEN_2022,
            &mint_key,
            &metadata_authority,
            &mint_key,
            &payer_key,
            metadata.name.clone(),
            metadata.symbol.clone(),
            metadata.uri.clone(),
        ),
        // The Token ACL config plus the gate program's allowlist. Permissionless
        // thaw lets anyone open an allowlisted holder's account by paying the fee.
        acl::create_config(&payer_key, &payer_key, &mint_key),
        acl::enable_permissionless_thaw(&payer_key, &mint_key),
        acl::create_allowlist(&payer_key, &mint_key),
        acl::setup_extra_metas(&payer_key, &mint_key),
    ];

    send(&rpc, &[&payer, &mint], &instructions).await?;
    println!("Mint: {mint_key}");
    println!("Allowlist: {}", acl::list_config(&payer_key, &mint_key));
    println!(
        "Freeze authority (Token ACL mint config): {}",
        acl::mint_config(&mint_key)
    );
    Ok(())
}
```

<div className="sol-run" data-run="paths/assets/gated-token/create" data-tab="Rust">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Creating the mint, its Token ACL config, and its allowlist</span></div>
<div className="sol-run-out">

```text Output
Signature: 4NSnEnmWzgMYV8DtmtNPdoii2b7Xksy7Dtk3ZevzMxGueumBhMULhkA4fLmdp6batpLRRCGQeU8Mzf78egsAfMUV
Mint: 3zsS4p5aDBiqLmCynUBayqCM9WWR35jr51tT4maAT1P1
Allowlist: Bos4ACRw2FtEH2jfCRuJjkgkNdV8KJynbur3gmMJ3kDT
Freeze authority (Token ACL mint config): BQkScxP9wTPTtAbmpMsfpd5SuJwtAKcq1xUVrQty12ze
```

</div>
</div>

</Tab>
</Tabs>

Two settings make the mint usable as a gated token:

- **The freeze authority moves to Token ACL.** In the Mosaic SDK this is
  `enableSrfc37: true`; the Kit, Web3.js v3, and Rust scripts send Token ACL's
  create config instruction, signed by the current freeze authority. It hands
  the freeze authority to the Token ACL mint config for this mint, a
  program-derived address, which is then the only party that can thaw a frozen
  account. **Without it, the mint creates frozen accounts but nothing can thaw
  them through a gate.**
- **The gate is an allowlist.** `aclMode: "allowlist"` (mode `Allow` in the
  other scripts) fails closed: nobody holds the token until they are added. A
  blocklist fails open.

The script prints three addresses you need for the rest of the tutorial: the
mint, the allowlist, and the Token ACL mint config. Export them:

```bash Terminal
export MINT=<the mint>
export LIST=<the allowlist>
export MINT_CONFIG=<the freeze authority>
```

</Step>

<Step title="Review the extensions">

The mint carries the extension set of Mosaic's `tokenized-security` template:

| Extension             | Effect                                                                                                                                       | Reference                                                                          |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| Default Account State | Every new token account is created frozen                                                                                                    | [Default state](/developers/docs/tokens/extensions/default-state)                  |
| Metadata              | Name, symbol, and URI stored onchain                                                                                                         | [Metadata](/developers/docs/tokens/extensions/metadata)                            |
| Pausable              | One action halts mint, burn, and transfer                                                                                                    | [Pausable](/developers/docs/tokens/extensions/pausable)                            |
| Permanent Delegate    | Forced transfer and forced burn from any account                                                                                             | [Permanent delegate](/developers/docs/tokens/extensions/permanent-delegate)        |
| Permissioned Burn     | A holder's burn needs the burn authority's co-signature                                                                                      | [Permissioned burn](/developers/docs/tokens/extensions/permissioned-burn)          |
| Scaled UI Amount      | A multiplier applied to displayed balances; the [DvP program](/developers/docs/defi/dvp-program) does not accept mints with it               | [Scaled UI Amount](/developers/docs/tokens/extensions/scaled-ui-amount)            |
| Confidential Balances | Balances and amounts can be hidden from the public ledger                                                                                    | [Confidential Balances](/developers/docs/tokens/extensions/confidential-transfer)  |

**Permissioned burn** makes redemption a two-party operation: a holder cannot
extinguish their own balance without the burn authority signing alongside
them. It suits a redemption process with an offchain settlement leg. It can
only be added at creation. Clearing its authority later lets holders burn
alone, and the authority cannot be set again. If holders must be able to burn
on their own from the start, leave it out.

**Scaled UI Amount** lets an accrual or a corporate action change every
holder's displayed balance without a transfer. It can only be enabled when the
mint is created. Carrying it unused does not change any balance, but it does
appear on the mint, so include it in the extension-by-extension support check
described in
[custody integration](/developers/docs/tokenization/custody/custody-integration).
The template always adds it, with the multiplier authority on the mint
authority. To create a mint without it, remove it from the Kit, Web3.js v3, or
Rust script.

**Confidential Balances** is configured but not active for any holder until
that holder configures their account and the Confidential Balances authority
approves it. Using it requires zero-knowledge proofs on every confidential
operation, and it changes what the permanent delegate can reach;
[privacy and transfer controls](/developers/docs/tokenization/compliance/privacy-and-transfer-controls)
covers both.

Authorities are assigned when the mint is created. Decide your authority
layout before you run the script: rotating an authority afterwards is a
separate `SetAuthority` transaction for each one.

</Step>

<Step title="Confirm what you built">

Read the mint back and check the extensions and authorities against what you
intended. Save this as `inspect-mint.ts` (in Rust, `src/bin/inspect-mint.rs`)
and run it.

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

```ts
// npx tsx inspect-mint.ts
import { address } from "@solana/kit";
import { inspectToken } from "@solana/mosaic-sdk";
import { env, rpc } from "./common";

const mint = address(env("MINT"));
const token = await inspectToken(rpc, mint, "confirmed");
console.log({
  mint: token.address,
  supply: token.supplyInfo.supply.toString(),
  decimals: token.supplyInfo.decimals,
  authorities: token.authorities,
  extensions: token.extensions.map((extension) => extension.name),
  aclMode: token.aclMode,
  tokenAcl: token.enableSrfc37,
  patterns: token.detectedPatterns,
});
```

<div className="sol-run" data-run="paths/assets/gated-token/inspect" data-tab="Mosaic SDK">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Reading the new mint back</span></div>
<div className="sol-run-out">

```text Output
{
  mint: '653XZoSFLEb7BuezYeLTiq5KBsdFDHZ71MfsybEzHr9G',
  supply: '0',
  decimals: 6,
  authorities: {
    mintAuthority: 'Grr9mjov4Ao553eJfERUuGK7GPv2BmJsnsS7xxdcWjXF',
    freezeAuthority: 'DMoNpevW1mVh6DiGGDtd6cLNsrSjsHpFjuGktGFLC1f7',
    pausableAuthority: 'BNL3DECi2YsDCkhg8MSqMYkvoHncWUR9xxwEeHFNyYv7',
    confidentialBalancesAuthority: 'Grr9mjov4Ao553eJfERUuGK7GPv2BmJsnsS7xxdcWjXF',
    permanentDelegate: '7Vpi5P32QzTShW5D8DnDbbb5xnVMqW5n9oWAYdbX59ju',
    permanentDelegateAuthority: '7Vpi5P32QzTShW5D8DnDbbb5xnVMqW5n9oWAYdbX59ju',
    permissionedBurnAuthority: 'Ht46xPMfVDnN6en1kcnfa2TPofBdikvJY29vRAFnERzx',
    metadataAuthority: '444HCYWfhhGmQu17upGCkAWEi6q1nRBhaGzcPQVkCgue',
    updateAuthority: '444HCYWfhhGmQu17upGCkAWEi6q1nRBhaGzcPQVkCgue'
  },
  extensions: [
    'MetadataPointer',
    'PausableConfig',
    'DefaultAccountState',
    'ConfidentialTransferMint',
    'PermanentDelegate',
    'PermissionedBurn',
    'ScaledUiAmountConfig',
    'TokenMetadata'
  ],
  aclMode: 'allowlist',
  tokenAcl: true,
  patterns: [ 'tokenized-security', 'stablecoin' ]
}
```

</div>
</div>

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

```ts
// npx tsx inspect-mint.ts
import { address, type Option } from "@solana/kit";
import { fetchMint } from "@solana-program/token-2022";
import { fetchMaybeMintConfig, findMintConfigPda } from "@solana/token-acl-sdk";
import { env, rpc } from "./common";

const mint = address(env("MINT"));
const unwrap = <T>(option: Option<T>) =>
  option.__option === "Some" ? option.value : null;

// The mint account carries the extensions. The Token ACL config is a separate
// account, derived from the mint, that holds the gate program and the
// permissionless-thaw flag.
const { data } = await fetchMint(rpc, mint, { commitment: "confirmed" });
const [mintConfigAddress] = await findMintConfigPda({ mint });
const mintConfig = await fetchMaybeMintConfig(rpc, mintConfigAddress);
const extensions = unwrap(data.extensions) ?? [];

console.log({
  mint,
  supply: data.supply.toString(),
  decimals: data.decimals,
  mintAuthority: unwrap(data.mintAuthority),
  freezeAuthority: unwrap(data.freezeAuthority),
  tokenAcl:
    mintConfig.exists && unwrap(data.freezeAuthority) === mintConfigAddress,
  gatingProgram: mintConfig.exists ? mintConfig.data.gatingProgram : null,
  permissionlessThaw: mintConfig.exists
    ? mintConfig.data.enablePermissionlessThaw
    : false,
  extensions: extensions.map((ext) => ext.__kind),
});
```

<div className="sol-run" data-run="paths/assets/gated-token/inspect" data-tab="Kit">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Reading the new mint back</span></div>
<div className="sol-run-out">

```text Output
{
  mint: '8ComqBcog3Aig4hYN9PcCQHcK4rCCUhv7QoxUfrVVB66',
  supply: '0',
  decimals: 6,
  mintAuthority: 'BK9pK1NZKR3jfmhCmU6tKPj14ZtCcvPW8KgfzKaB7Q2U',
  freezeAuthority: 'UUNTF54aKsEw57DmFS1SE2v6ARQnAXt7cGTZV1xY79P',
  tokenAcl: true,
  gatingProgram: 'GATEzzqxhJnsWF6vHRsgtixxSB8PaQdcqGEVTEHWiULz',
  permissionlessThaw: true,
  extensions: [
    'MetadataPointer',
    'PausableConfig',
    'DefaultAccountState',
    'ConfidentialTransferMint',
    'PermanentDelegate',
    'PermissionedBurn',
    'ScaledUiAmountConfig',
    'TokenMetadata'
  ]
}
```

</div>
</div>

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

```ts
// npx tsx inspect-mint.ts
import type { Option } from "@solana/kit";
import { PublicKey } from "@solana/web3.js";
import { getMintDecoder } from "@solana-program/token-2022";
import { findMintConfigPda, getMintConfigDecoder } from "@solana/token-acl-sdk";
import { addressOf, connection, env } from "./common";

const mint = addressOf(env("MINT"));
const unwrap = <T>(option: Option<T>) =>
  option.__option === "Some" ? option.value : null;

// The mint account carries the extensions. The Token ACL config is a separate
// account, derived from the mint, that holds the gate program and the
// permissionless-thaw flag.
const mintAccount = await connection.getAccountInfo(new PublicKey(mint));
const data = getMintDecoder().decode(mintAccount!.data);
const [mintConfigAddress] = await findMintConfigPda({ mint });
const configAccount = await connection.getAccountInfo(
  new PublicKey(mintConfigAddress),
);
const mintConfig = configAccount
  ? getMintConfigDecoder().decode(configAccount.data)
  : null;
const extensions = unwrap(data.extensions) ?? [];

console.log({
  mint,
  supply: data.supply.toString(),
  decimals: data.decimals,
  mintAuthority: unwrap(data.mintAuthority),
  freezeAuthority: unwrap(data.freezeAuthority),
  tokenAcl:
    mintConfig !== null && unwrap(data.freezeAuthority) === mintConfigAddress,
  gatingProgram: mintConfig?.gatingProgram ?? null,
  permissionlessThaw: mintConfig?.enablePermissionlessThaw ?? false,
  extensions: extensions.map((ext) => ext.__kind),
});
```

<div className="sol-run" data-run="paths/assets/gated-token/inspect" 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 new mint back</span></div>
<div className="sol-run-out">

```text Output
{
  mint: '8xDpQoKEXGrtCm5JwseD2v7KHCNnXv8kQmm61Cjozn7o',
  supply: '0',
  decimals: 6,
  mintAuthority: 'xZfpSyksW1VT3CSKDCfY7imda2aeHcxfudasCVctk6s',
  freezeAuthority: 'GM28GNtb2Wmj4sPqpvV7aAxxWy78JqSNVnksdndFJNna',
  tokenAcl: true,
  gatingProgram: 'GATEzzqxhJnsWF6vHRsgtixxSB8PaQdcqGEVTEHWiULz',
  permissionlessThaw: true,
  extensions: [
    'MetadataPointer',
    'PausableConfig',
    'DefaultAccountState',
    'ConfidentialTransferMint',
    'PermanentDelegate',
    'PermissionedBurn',
    'ScaledUiAmountConfig',
    'TokenMetadata'
  ]
}
```

</div>
</div>

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

```rust
// cargo run --release --bin inspect-mint
use anyhow::Result;
use gated_token::{acl, env, rpc};
use solana_sdk::pubkey::Pubkey;
use spl_token_2022_interface::{
    extension::{BaseStateWithExtensions, StateWithExtensions},
    state::Mint,
};

#[tokio::main]
async fn main() -> Result<()> {
    let rpc = rpc();
    let mint = env("MINT")?;

    // The mint account carries the extensions. The Token ACL config is a
    // separate account, derived from the mint: discriminator (1), bump (1),
    // thaw flag (1), freeze flag (1), mint (32), authority (32), gate (32).
    let data = rpc.get_account_data(&mint).await?;
    let state = StateWithExtensions::<Mint>::unpack(&data)?;
    let config_address = acl::mint_config(&mint);
    let config = rpc
        .get_account_with_commitment(&config_address, rpc.commitment())
        .await?
        .value;
    let mint_authority: Option<Pubkey> = state.base.mint_authority.into();
    let freeze_authority: Option<Pubkey> = state.base.freeze_authority.into();

    println!("mint: {mint}");
    println!("supply: {}", state.base.supply);
    println!("decimals: {}", state.base.decimals);
    println!("mintAuthority: {mint_authority:?}");
    println!("freezeAuthority: {freeze_authority:?}");
    println!(
        "tokenAcl: {}",
        config.is_some() && freeze_authority == Some(config_address)
    );
    if let Some(config) = &config {
        println!(
            "gatingProgram: {}",
            Pubkey::try_from(&config.data[68..100])?
        );
        println!("permissionlessThaw: {}", config.data[2] == 1);
    }
    println!("extensions: {:?}", state.get_extension_types()?);
    Ok(())
}
```

<div className="sol-run" data-run="paths/assets/gated-token/inspect" data-tab="Rust">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Reading the new mint back</span></div>
<div className="sol-run-out">

```text Output
mint: 3zsS4p5aDBiqLmCynUBayqCM9WWR35jr51tT4maAT1P1
supply: 0
decimals: 6
mintAuthority: Some(G5YVqc5e5wG4WBCcJwK1BhHE8hLWX5W4bu3uksoENBG8)
freezeAuthority: Some(BQkScxP9wTPTtAbmpMsfpd5SuJwtAKcq1xUVrQty12ze)
tokenAcl: true
gatingProgram: GATEzzqxhJnsWF6vHRsgtixxSB8PaQdcqGEVTEHWiULz
permissionlessThaw: true
extensions: [MetadataPointer, Pausable, DefaultAccountState, ConfidentialTransferMint, PermanentDelegate, PermissionedBurn, ScaledUiAmount, TokenMetadata]
```

</div>
</div>

</Tab>
</Tabs>

Check three things:

1. **The freeze authority is `$MINT_CONFIG`**, the Token ACL mint config for
   this mint, and not your own key or none. `tokenAcl` is `true`. If it is
   anything else, Token ACL did not take the freeze authority; see
   [confirm the gate is in place](/developers/docs/tokenization/tutorials/issuing/gate-the-holders#confirm-the-gate-is-in-place)
   for when that can be fixed.
2. **The gate is the gate program with permissionless thaw on.** The Kit,
   Web3.js v3, and Rust scripts print `gatingProgram`
   (`GATEzzqxhJnsWF6vHRsgtixxSB8PaQdcqGEVTEHWiULz`) and
   `permissionlessThaw: true`; the Mosaic SDK prints `aclMode: 'allowlist'`.
3. **Each authority is the key you passed.** The Mosaic SDK lists them under
   `authorities` (`pausableAuthority`, `permanentDelegate`,
   `permissionedBurnAuthority`, and `updateAuthority` for metadata). The mint
   authority is your fee payer, as noted above.

The SDK's `patterns` field lists `tokenized-security`, and also `stablecoin`:
in Mosaic SDK 0.2.0, `inspectToken` reports `stablecoin` for any mint with
metadata, a permanent delegate, a default account state, and Confidential
Balances, and this mint has all four.

If an operational authority came back as your fee payer rather than the key
you passed, create a new mint rather than correcting it; on devnet or a local
network the cost is negligible.

</Step>

</Steps>

## Next steps

- [Gate the holders](/developers/docs/tokenization/tutorials/issuing/gate-the-holders):
  decide who is allowed to hold the token
