Skip to content
Italiano

​How to create a mint with Confidential Balances

Confidential Balances enables private token transfers by adding extra state to the mint account. This section explains how to create a token mint with the required extension enabled. The following diagram shows the steps involved in creating a mint with the Confidential Balances extension:
Create Mint with Confidential BalancesCreate Mint with Confidential Balances

Create Mint with Confidential Balances

​Confidential Balances Mint State

The extension adds the ConfidentialTransferMint state to the mint account:
Confidential Mint State
The ConfidentialTransferMint contains three configuration fields:
  • authority: The account that has permission to change Confidential Balances settings for the mint and approve new confidential accounts if auto-approval is disabled.
  • auto_approve_new_accounts: When set to true, users can create token accounts with Confidential Balances enabled by default. When false, the authority must approve each new token account before it can be used for confidential transfers.
  • auditor_elgamal_pubkey: An optional auditor that can decrypt transfer amounts in confidential transactions, providing a compliance mechanism while maintaining privacy from the general public.

​Required Instructions

Creating a mint with Confidential Balances enabled requires three instructions in a single transaction:
  1. Create the Mint Account: Invoke the System Program’s CreateAccount instruction to create the mint account.
  2. Initialize Confidential Balances: Invoke the Token Extension Program’s ConfidentialTransferInstruction::InitializeMint instruction to configure the ConfidentialTransferMint state for the mint.
  3. Initialize Mint: Invoke the Token Extension Program’s Instruction::InitializeMint instruction to initialize the standard mint state.
The spl_token_client crate’s create_mint method can build and send all three in one call. The examples below build the three instructions directly, so you can see each one.

​Example Code

The following code demonstrates how to create a mint with Confidential Balances enabled. Confidential Balances depends on the ZK ElGamal Proof program, which is enabled on mainnet and devnet. The Token-2022 program bundled with solana-test-validator is built without confidential-transfer support, so Deposit and the steps after it fail with InvalidInstructionData. Run the examples on devnet (the code’s default; get devnet SOL from the Solana faucet) or on a mainnet-forking local validator such as Surfpool. The payer is the wallet at ~/.config/solana/id.json, and the example creates its own mint, so there are no addresses to replace. The mint’s auditor key comes from a second wallet. Create it before you run the example:
Terminal

​Rust

​Typescript