Skip to content

Latest commit

 

History

History
307 lines (245 loc) · 12.1 KB

File metadata and controls

307 lines (245 loc) · 12.1 KB

Solana Private Channels Escrow Program Overview

Program ID

GokvZqD2yP696rzNBNbQvcZ4VsLW7jNvFXU1kW9m7k83

Instructions

Instruction Description Discriminator
CreateInstance Create a new escrow instance with the specified admin 0
AllowMint Allow new token mints for the instance (admin-only) 1
BlockMint Block previously allowed mints for the instance (admin-only) 2
AddOperator Add an operator to the instance (admin-only) 3
RemoveOperator Remove an operator from the instance (admin-only) 4
SetNewAdmin Set a new admin for the instance (current admin only) 5
Deposit Deposit tokens from user ATA to instance escrow ATA (permissionless) 6
ReleaseFunds Release funds from escrow to user (operator-only) 7
ResetSmtRoot Reset the SMT root for the instance (operator-only) 8
EmitEvent Emit event via CPI 228

Instruction Details

CreateInstance

Creates a new escrow instance with the specified admin.

Discriminator: 0

Parameters:

Parameter Type Description
bump u8 PDA bump seed for instance account

Accounts:

Account Name Signer Writable Description
0 payer Transaction fee payer
1 admin Admin of Instance
2 instance_seed Instance seed signer for PDA derivation
3 instance Instance PDA to be created
4 system_program System program
5 event_authority Event authority PDA for emitting events
6 private_channel_escrow_program Current program for CPI

AllowMint

Allows new token mints for the instance (admin-only).

Discriminator: 1

Parameters:

Parameter Type Description
bump u8 PDA bump seed for allowed mint account

Accounts:

Account Name Signer Writable Description
0 payer Transaction fee payer
1 admin Admin of Instance
2 instance Instance PDA to validate admin authority
3 mint Token mint to be allowed
4 allowed_mint PDA of the Allowed Mint
5 instance_ata Instance Escrow account for specified mint
6 system_program System program
7 token_program Token program
8 associated_token_program Associated Token program
9 event_authority Event authority PDA for emitting events
10 private_channel_escrow_program Current program for CPI

BlockMint

Blocks previously allowed mints for the instance (admin-only).

Discriminator: 2

Parameters: None

Accounts:

Account Name Signer Writable Description
0 payer Transaction fee payer
1 admin Admin of Instance
2 instance Instance PDA to validate admin authority
3 mint Token mint to be blocked
4 allowed_mint Existing Allowed Mint PDA
5 system_program System program for account creation
6 event_authority Event authority PDA for emitting events
7 private_channel_escrow_program Current program for CPI

AddOperator

Adds an operator to the instance (admin-only).

Discriminator: 3

Parameters:

Parameter Type Description
bump u8 PDA bump seed for operator account

Accounts:

Account Name Signer Writable Description
0 payer Transaction fee payer
1 admin Admin of Instance
2 instance Instance PDA to validate admin authority
3 operator Operator public key to be added
4 operator_pda Operator PDA to be created
5 system_program System program
6 event_authority Event authority PDA for emitting events
7 private_channel_escrow_program Current program for CPI

RemoveOperator

Removes an operator from the instance (admin-only).

Discriminator: 4

Parameters: None

Accounts:

Account Name Signer Writable Description
0 payer Transaction fee payer
1 admin Admin of Instance
2 instance Instance PDA to validate admin authority
3 operator Operator public key to be removed
4 operator_pda Existing Operator PDA
5 system_program System program
6 event_authority Event authority PDA for emitting events
7 private_channel_escrow_program Current program for CPI

SetNewAdmin

Sets a new admin for the instance (current admin only).

Discriminator: 5

Parameters: None

Accounts:

Account Name Signer Writable Description
0 payer Transaction fee payer
1 current_admin Current admin of Instance
2 instance Instance PDA to update admin
3 new_admin New admin public key
4 event_authority Event authority PDA for emitting events
5 private_channel_escrow_program Current program for CPI

Deposit

Deposits tokens from user ATA to instance escrow ATA (permissionless).

Discriminator: 6

Parameters:

Parameter Type Description
amount u64 Amount of tokens to deposit
recipient Option<Pubkey> Optional recipient for Solana Private Channels tracking (wallet address, not the ATA; if None, defaults to user)

Accounts:

Account Name Signer Writable Description
0 payer Transaction fee payer
1 user User depositing tokens
2 instance Instance PDA to validate
3 mint Token mint being deposited
4 allowed_mint AllowedMint PDA to validate mint is allowed
5 user_ata User's Associated Token Account for this mint
6 instance_ata Instance's Associated Token Account (escrow) for this mint
7 system_program System program
8 token_program Token program for the mint
9 associated_token_program Associated Token program
10 event_authority Event authority PDA for emitting events
11 private_channel_escrow_program Current program for CPI

ReleaseFunds

Releases funds from escrow to user (operator-only).

Discriminator: 7

Parameters:

Parameter Type Description
amount u64 Amount of tokens to release
user Pubkey User receiving the funds (wallet address, not the ATA)
new_withdrawal_root [u8; 32] New withdrawal transactions root
transaction_nonce u64 Transaction nonce
sibling_proofs [u8; 512] Sibling proofs (flattened as 512 bytes: 16 proofs × 32 bytes each)

Accounts:

Account Name Signer Writable Description
0 payer Transaction fee payer
1 operator Operator releasing the funds
2 instance Instance PDA to validate and update
3 operator_pda Operator PDA to validate operator permissions
4 mint Token mint being released
5 allowed_mint AllowedMint PDA to validate mint is allowed
6 user_ata User's Associated Token Account for this mint
7 instance_ata Instance's Associated Token Account (escrow) for this mint
8 token_program Token program for the mint
9 associated_token_program Associated Token program
10 event_authority Event authority PDA for emitting events
11 private_channel_escrow_program Current program for CPI

ResetSmtRoot

Resets the SMT root for the instance (operator-only).

Discriminator: 8

Parameters: None

Accounts:

Account Name Signer Writable Description
0 payer Transaction fee payer
1 operator Operator resetting the SMT root
2 instance Instance PDA to reset
3 operator_pda Operator PDA to validate operator permissions
4 event_authority Event authority PDA for emitting events
5 private_channel_escrow_program Current program for CPI

EmitEvent

Invoked via CPI from another program to log event via instruction data.

Discriminator: 228

Parameters: None (event data passed via instruction data)

Accounts:

Account Name Signer Writable Description
0 event_authority Event authority PDA for emitting events

Accounts

Account Description Discriminator
Instance Escrow instance that holds token funds and manages operators 0
Operator Authorized operator for an instance that can release funds 1
AllowedMint Token mint that is allowed for deposits in an instance 2

Instance

Represents an escrow instance that holds token funds and manages operators.

PDA Derivation: ["instance", instance_seed]

Field Type Description
bump u8 PDA bump seed
version u8 Instance version
instance_seed Pubkey Unique seed for this instance
admin Pubkey Authority that controls the instance
withdrawal_transactions_root [u8; 32] Sparse Merkle Tree root for withdrawal transactions
current_tree_index u64 Current tree index to prevent double spending

Operator

Represents an authorized operator for an instance that can release funds.

PDA Derivation: ["operator", instance_pda, wallet_pubkey]

Field Type Description
bump u8 PDA bump seed

AllowedMint

Represents a token mint that is allowed for deposits in an instance.

PDA Derivation: ["allowed_mint", instance_pda, mint_pubkey]

Field Type Description
bump u8 PDA bump seed

Errors

The program defines the following custom errors:

Error Code Error Name Description
0 InvalidEventAuthority Invalid event authority provided
1 InvalidAta Invalid ATA provided
2 InvalidMint Invalid mint provided
3 InvalidInstanceId Instance ID invalid or does not respect rules
4 InvalidInstance Invalid instance provided
5 InvalidAdmin Invalid admin provided
6 TransferHookNotAllowed Transfer hook extension not allowed
7 InvalidOperatorPda Invalid operator PDA provided
8 InvalidTokenAccount Invalid token account provided
9 InvalidEscrowBalance Invalid escrow balance
10 InvalidAllowedMint Invalid allowed mint
11 InvalidSmtProof Invalid SMT proof provided
12 InvalidTransactionNonceForCurrentTreeIndex Invalid transaction nonce for current tree index

Other Constants

  • Instance Version: 1
  • Tree Height: 16
  • Max Tree Leaves: 65536
  • Empty Tree Root (Pre-computed root hash for empty Sparse Merkle Tree): [143, 230, 177, 104, 146, 86, 192, 211, 133, 244, 47, 91, 190, 32, 39, 162, 44, 25, 150, 225, 16, 186, 151, 193, 113, 211, 229, 148, 141, 233, 43, 235]
  • Empty Leaf: [0u8; 32]
  • Non-Empty Leaf Hash: SHA256 hash of [1u8; 32]