Skip to content

CSPLTokenService

SIP Protocol API Reference v0.7.4


SIP Protocol API Reference / CSPLTokenService

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21446

C-SPL Token Service

Wraps CSPLClient with:

  • Proper error handling (always check success before field access)
  • Token registration
  • Delegate approvals
  • Cost estimation

new CSPLTokenService(config?): CSPLTokenService

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21456

Create a new C-SPL Token Service

CSPLTokenServiceConfig

Service configuration

CSPLTokenService

initialize(): Promise<void>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21462

Initialize the service

Connects to Solana RPC and registers initial tokens.

Promise<void>


wrap(params): Promise<WrapResult>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21491

Wrap SPL tokens to C-SPL (encrypted tokens)

IMPORTANT: Always check result.success before accessing result.csplMint or other fields. This is the proper pattern to avoid undefined access.

WrapParams

Wrap parameters

Promise<WrapResult>

Wrap result with success status

const result = await service.wrap({
mint: 'So11111111111111111111111111111111111111112',
amount: 1_000_000_000n,
owner: wallet,
})
// CORRECT: Check success first
if (!result.success) {
console.error(result.error)
return
}
console.log(result.csplMint) // Safe to access
// INCORRECT: Don't do this!
// console.log(result.csplMint!) // Unsafe non-null assertion

unwrap(params): Promise<UnwrapResult>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21498

Unwrap C-SPL tokens back to SPL

UnwrapParams

Unwrap parameters

Promise<UnwrapResult>

Unwrap result with success status


transfer(params): Promise<ConfidentialTransferResult>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21505

Execute a confidential transfer

Transfer parameters

string

string

string

Uint8Array

string

Promise<ConfidentialTransferResult>

Transfer result with success status


getBalance(csplMint, owner): Promise<ConfidentialBalance | null>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21519

Get confidential balance for an account

string

C-SPL token mint address

string

Account owner address

Promise<ConfidentialBalance | null>

Confidential balance or null if not found


approve(params): Promise<ApproveResult>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21528

Approve a delegate to transfer C-SPL tokens

Used for DEX integrations where a contract needs to transfer on behalf of user.

ApproveParams

Approval parameters

Promise<ApproveResult>

Approval result


revoke(csplMint, _delegate, _owner): Promise<ApproveResult>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21537

Revoke a delegate’s approval

string

C-SPL token mint address

string

string

Promise<ApproveResult>

Revoke result


estimateCost(operation): Promise<bigint>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21544

Estimate cost for an operation

Operation type (‘wrap’, ‘unwrap’, ‘transfer’, ‘approve’)

"transfer" | "wrap" | "unwrap" | "approve"

Promise<bigint>

Estimated cost in lamports


getSupportedTokens(): CSPLToken[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21550

Get all supported/registered tokens

CSPLToken[]

Array of registered C-SPL tokens


registerToken(token): void

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21556

Register a token for use with the service

CSPLToken

Token to register

void


getStatus(): CSPLServiceStatus

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21562

Get service status

CSPLServiceStatus

Service status information


disconnect(): Promise<void>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21566

Disconnect and cleanup

Promise<void>