Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Confidential Transfer Support in @solana/spl-token #6338

Open
@ixmorrow

Description

@ixmorrow

I have been messing with confidential transfers on the client side recently and ran into some issues with the @solana/spl-token API that I'd like to highlight here.

  1. getMintLen() does not return the correct byte size for a mint with the confidential transfer extension.
  • This method seems to be the suggested way for determining how much space to allocate when creating an account with extensions from the client side. Using this function with the ExtensionType.ConfidentialTransferMint type as input returns a size of 267 bytes.
  • 267 bytes does not seem to be the correct size for a mint with the ConfidentialTransfer extension. Attempting to initialize a mint account with 267 bytes allocated will result in an error when you eventually call the InitializeMint instruction on the Token22 program.
  • The correct amount of bytes is 235. Allocating a buffer of exactly 235 bytes when creating the account will pass this check.
    • You can even test this by running the commandline example in the Confidential Transfer quick start guide and inspecting the transaction in an explorer.
spl-token --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb create-token --enable-confidential-transfers auto
  1. There is virtually no support for any of the Confidential Transfer instructions or any of the relevant types in the @solana/spl-token API. I assume this is intentional, but I have begun implementing the API following the same format as the other Token Extension methods for my own use cases. Which is a bit of a pain so far and I'm not sure if this is completely viable. I am curious why they are not supported yet and if there are plans to implement them?

  2. It seems like the "Configure a token account for confidential transfers" commandline example does not even work in the Confidential Transfers quick start guide.. I get a "Transaction simulation failed: Attempt to load a program that does not exist" RPC error. I'm at least able to invoke the ConfidentialTransfer::ConfigureAccount instruction via typescript on devnet, so I thought this error response was odd. But that might be unrelated.

Commandline RPC Error:

Error: Client(Error { request: Some(SendTransaction), kind: RpcError(RpcResponseError { code: -32002, message: "Transaction simulation failed: Attempt to load a program that does not exist", data: SendTransactionPreflightFailure(RpcSimulateTransactionResult { err: Some(ProgramAccountNotFound), logs: Some([]), accounts: None, units_consumed: Some(0), return_data: None }) }) })

Repo with my code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions