Enum safe_token_2022::extension::confidential_transfer::instruction::ConfidentialTransferInstruction
source · #[repr(u8)]
pub enum ConfidentialTransferInstruction {
Show 16 variants
InitializeMint,
UpdateMint,
ConfigureAccount,
ApproveAccount,
EmptyAccount,
Deposit,
Withdraw,
Transfer,
ApplyPendingBalance,
EnableConfidentialCredits,
DisableConfidentialCredits,
EnableNonConfidentialCredits,
DisableNonConfidentialCredits,
WithdrawWithheldTokensFromMint,
WithdrawWithheldTokensFromAccounts,
HarvestWithheldTokensToMint,
}
Expand description
Confidential Transfer extension instructions
Variants§
InitializeMint
Initializes confidential transfers for a mint.
The ConfidentialTransferInstruction::InitializeMint
instruction requires no signers
and MUST be included within the same Transaction as TokenInstruction::InitializeMint
.
Otherwise another party can initialize the configuration.
The instruction fails if the TokenInstruction::InitializeMint
instruction has already
executed for the mint.
Note that the withdraw_withheld_authority_encryption_pubkey
cannot be updated after it is
initialized.
Accounts expected by this instruction:
[writable]
The SPL Token mint.
Data expected by this instruction:
InitializeMintData
UpdateMint
Updates the confidential transfer mint configuration for a mint.
Use TokenInstruction::SetAuthority
to update the confidential transfer mint authority.
The withdraw_withheld_authority_encryption_pubkey
and withheld_amount
ciphertext are
not updatable.
Accounts expected by this instruction:
[writable]
The SPL Token mint.[signer]
Confidential transfer mint authority.
Data expected by this instruction:
UpdateMintData
ConfigureAccount
Configures confidential transfers for a token account.
The instruction fails if the confidential transfers are already configured, or if the mint was not initialized with confidential transfer support.
The instruction fails if the TokenInstruction::InitializeAccount
instruction has not yet
successfully executed for the token account.
Upon success, confidential and non-confidential deposits and transfers are enabled. Use the
DisableConfidentialCredits
and DisableNonConfidentialCredits
instructions to disable.
In order for this instruction to be successfully processed, it must be accompanied by the
VerifyPubkey
instruction of the zk_token_proof
program in the same transaction.
Accounts expected by this instruction:
- Single owner/delegate
[writeable]
The SPL Token account.[]
The corresponding SPL Token mint.[]
Instructions sysvar.[signer]
The single source account owner.
- Multisignature owner/delegate
[writeable]
The SPL Token account.[]
The corresponding SPL Token mint.[]
The multisig source account owner.[]
Instructions sysvar. 4..[signer]
Required M signer accounts for the SPL Token Multisig account.
Data expected by this instruction:
ConfigureAccountInstructionData
ApproveAccount
Approves a token account for confidential transfers.
Approval is only required when the ConfidentialTransferMint::approve_new_accounts
field is set in the SPL Token mint. This instruction must be executed after the account
owner configures their account for confidential transfers with
ConfidentialTransferInstruction::ConfigureAccount
.
Accounts expected by this instruction:
[writable]
The SPL Token account to approve.[]
The SPL Token mint.[signer]
Confidential transfer auditor authority.
Data expected by this instruction: None
EmptyAccount
Prepare a token account for closing. The account must not hold any confidential tokens in
its pending or available balances. Use
ConfidentialTransferInstruction::DisableConfidentialCredits
to block balance credit
changes first if necessary.
Note that a newly configured account is always empty, so this instruction is not required
prior to account closing if no instructions beyond
ConfidentialTransferInstruction::ConfigureAccount
have affected the token account.
In order for this instruction to be successfully processed, it must be accompanied by the
VerifyCloseAccount
instruction of the zk_token_proof
program in the same transaction.
- Single owner/delegate
[writable]
The SPL Token account.[]
Instructions sysvar.[signer]
The single account owner.
- Multisignature owner/delegate
[writable]
The SPL Token account.[]
Instructions sysvar.[]
The multisig account owner. 3..[signer]
Required M signer accounts for the SPL Token Multisig account.
Data expected by this instruction:
EmptyAccountInstructionData
Deposit
Deposit SPL Tokens into the pending balance of a confidential token account.
The account owner can then invoke the ApplyPendingBalance
instruction to roll the deposit
into their available balance at a time of their choosing.
Fails if the source or destination accounts are frozen.
Fails if the associated mint is extended as NonTransferable
.
Accounts expected by this instruction:
- Single owner/delegate
[writable]
The SPL Token account.[]
The token mint.[signer]
The single account owner or delegate.
- Multisignature owner/delegate
[writable]
The SPL Token account.[]
The token mint.[]
The multisig account owner or delegate. 3..[signer]
Required M signer accounts for the SPL Token Multisig account.
Data expected by this instruction:
DepositInstructionData
Withdraw
Withdraw SPL Tokens from the available balance of a confidential token account.
Fails if the source or destination accounts are frozen.
Fails if the associated mint is extended as NonTransferable
.
In order for this instruction to be successfully processed, it must be accompanied by the
VerifyWithdraw
instruction of the zk_token_proof
program in the same transaction.
Accounts expected by this instruction:
- Single owner/delegate
[writable]
The SPL Token account.[]
The token mint.[]
Instructions sysvar.[signer]
The single source account owner.
- Multisignature owner/delegate
[writable]
The SPL Token account.[]
The token mint.[]
Instructions sysvar.[]
The multisig source account owner. 4..[signer]
Required M signer accounts for the SPL Token Multisig account.
Data expected by this instruction:
WithdrawInstructionData
Transfer
Transfer tokens confidentially.
In order for this instruction to be successfully processed, it must be accompanied by
either the VerifyTransfer
or VerifyTransferWithFee
instruction of the zk_token_proof
program in the same transaction.
Fails if the associated mint is extended as NonTransferable
.
- Single owner/delegate
[writable]
The source SPL Token account.[writable]
The destination SPL Token account.[]
The token mint.[]
Instructions sysvar.[signer]
The single source account owner.
- Multisignature owner/delegate
[writable]
The source SPL Token account.[writable]
The destination SPL Token account.[]
The token mint.[]
Instructions sysvar.[]
The multisig source account owner. 6..[signer]
Required M signer accounts for the SPL Token Multisig account.
Data expected by this instruction:
TransferInstructionData
ApplyPendingBalance
Applies the pending balance to the available balance, based on the history of Deposit
and/or Transfer
instructions.
After submitting ApplyPendingBalance
, the client should compare
ConfidentialTransferAccount::expected_pending_balance_credit_counter
with
ConfidentialTransferAccount::actual_applied_pending_balance_instructions
. If they are
equal then the ConfidentialTransferAccount::decryptable_available_balance
is consistent
with ConfidentialTransferAccount::available_balance
. If they differ then there is more
pending balance to be applied.
Account expected by this instruction:
- Single owner/delegate
[writable]
The SPL Token account.[signer]
The single account owner.
- Multisignature owner/delegate
[writable]
The SPL Token account.[]
The multisig account owner. 2..[signer]
Required M signer accounts for the SPL Token Multisig account.
Data expected by this instruction:
ApplyPendingBalanceData
EnableConfidentialCredits
Configure a confidential extension account to accept incoming confidential transfers.
Accounts expected by this instruction:
- Single owner/delegate
[writable]
The SPL Token account.[signer]
Single authority.
- Multisignature owner/delegate
[writable]
The SPL Token account.[]
Multisig authority. 2..[signer]
Required M signer accounts for the SPL Token Multisig account.
Data expected by this instruction: None
DisableConfidentialCredits
Configure a confidential extension account to reject any incoming confidential transfers.
If the allow_non_confidential_credits
field is true
, then the base account can still
receive non-confidential transfers.
This instruction can be used to disable confidential payments after a token account has already been extended for confidential transfers.
Accounts expected by this instruction:
- Single owner/delegate
[writable]
The SPL Token account.[signer]
The single account owner.
- Multisignature owner/delegate
[writable]
The SPL Token account.[]
The multisig account owner. 2..[signer]
Required M signer accounts for the SPL Token Multisig account.
Data expected by this instruction: None
EnableNonConfidentialCredits
Configure an account with the confidential extension to accept incoming non-confidential transfers.
Accounts expected by this instruction:
- Single owner/delegate
[writable]
The SPL Token account.[signer]
The single account owner.
- Multisignature owner/delegate
[writable]
The SPL Token account.[]
The multisig account owner. 2..[signer]
Required M signer accounts for the SPL Token Multisig account.
Data expected by this instruction: None
DisableNonConfidentialCredits
Configure an account with the confidential extension to reject any incoming non-confidential transfers.
This instruction can be used to configure a confidential extension account to exclusively receive confidential payments.
Accounts expected by this instruction:
- Single owner/delegate
[writable]
The SPL Token account.[signer]
The single account owner.
- Multisignature owner/delegate
[writable]
The SPL Token account.[]
The multisig account owner. 2..[signer]
Required M signer accounts for the SPL Token Multisig account.
Data expected by this instruction: None
WithdrawWithheldTokensFromMint
Transfer all withheld confidential tokens in the mint to an account. Signed by the mint’s withdraw withheld tokens authority.
In order for this instruction to be successfully processed, it must be accompanied by the
VerifyWithdrawWithheldTokens
instruction of the zk_token_proof
program in the same
transaction.
Accounts expected by this instruction:
- Single owner/delegate
[writable]
The token mint. Must include theTransferFeeConfig
extension.[writable]
The fee receiver account. Must include theTransferFeeAmount
andConfidentialTransferAccount
extensions.[]
Instructions sysvar.[signer]
The mint’swithdraw_withheld_authority
.
- Multisignature owner/delegate
[writable]
The token mint. Must include theTransferFeeConfig
extension.[writable]
The fee receiver account. Must include theTransferFeeAmount
andConfidentialTransferAccount
extensions.[]
Instructions sysvar.[]
The mint’s multisigwithdraw_withheld_authority
.- ..3+M
[signer]
M signer accounts.
Data expected by this instruction: WithdrawWithheldTokensFromMintData
WithdrawWithheldTokensFromAccounts
Transfer all withheld tokens to an account. Signed by the mint’s withdraw withheld tokens
authority. This instruction is susceptible to front-running. Use
HarvestWithheldTokensToMint
and WithdrawWithheldTokensFromMint
as an alternative.
Note on front-running: This instruction requires a zero-knowledge proof verification
instruction that is checked with respect to the account state (the currently withheld
fees). Suppose that a withdraw withheld authority generates the
WithdrawWithheldTokensFromAccounts
instruction along with a corresponding zero-knowledge
proof for a specified set of accounts, and submits it on chain. If the withheld fees at any
of the specified accounts change before the WithdrawWithheldTokensFromAccounts
is
executed on chain, the zero-knowledge proof will not verify with respect to the new state,
forcing the transaction to fail.
If front-running occurs, then users can look up the updated states of the accounts,
generate a new zero-knowledge proof and try again. Alternatively, withdraw withheld
authority can first move the withheld amount to the mint using
HarvestWithheldTokensToMint
and then move the withheld fees from mint to a specified
destination account using WithdrawWithheldTokensFromMint
.
In order for this instruction to be successfully processed, it must be accompanied by the
VerifyWithdrawWithheldTokens
instruction of the zk_token_proof
program in the same
transaction.
Accounts expected by this instruction:
- Single owner/delegate
[]
The token mint. Must include theTransferFeeConfig
extension.[writable]
The fee receiver account. Must include theTransferFeeAmount
andConfidentialTransferAccount
extensions.[]
Instructions sysvar.[signer]
The mint’swithdraw_withheld_authority
.- ..3+N
[writable]
The source accounts to withdraw from.
- Multisignature owner/delegate
[]
The token mint. Must include theTransferFeeConfig
extension.[writable]
The fee receiver account. Must include theTransferFeeAmount
andConfidentialTransferAccount
extensions.[]
Instructions sysvar.[]
The mint’s multisigwithdraw_withheld_authority
.- ..4+M
[signer]
M signer accounts. 4+M+1. ..3+M+N[writable]
The source accounts to withdraw from.
Data expected by this instruction: WithdrawWithheldTokensFromAccountsData
HarvestWithheldTokensToMint
Permissionless instruction to transfer all withheld confidential tokens to the mint.
Succeeds for frozen accounts.
Accounts provided should include both the TransferFeeAmount
and
ConfidentialTransferAccount
extension. If not, the account is skipped.
Accounts expected by this instruction:
[writable]
The mint.- ..1+N
[writable]
The source accounts to harvest from.
Data expected by this instruction: None
Trait Implementations§
source§impl Clone for ConfidentialTransferInstruction
impl Clone for ConfidentialTransferInstruction
source§fn clone(&self) -> ConfidentialTransferInstruction
fn clone(&self) -> ConfidentialTransferInstruction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more