CSPLTokenService
SIP Protocol API Reference v0.7.4
SIP Protocol API Reference / CSPLTokenService
Class: CSPLTokenService
Section titled “Class: 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
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CSPLTokenService(
config?):CSPLTokenService
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21456
Create a new C-SPL Token Service
Parameters
Section titled “Parameters”config?
Section titled “config?”Service configuration
Returns
Section titled “Returns”CSPLTokenService
Methods
Section titled “Methods”initialize()
Section titled “initialize()”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.
Returns
Section titled “Returns”Promise<void>
wrap()
Section titled “wrap()”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.
Parameters
Section titled “Parameters”params
Section titled “params”Wrap parameters
Returns
Section titled “Returns”Promise<WrapResult>
Wrap result with success status
Example
Section titled “Example”const result = await service.wrap({ mint: 'So11111111111111111111111111111111111111112', amount: 1_000_000_000n, owner: wallet,})
// CORRECT: Check success firstif (!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 assertionunwrap()
Section titled “unwrap()”unwrap(
params):Promise<UnwrapResult>
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21498
Unwrap C-SPL tokens back to SPL
Parameters
Section titled “Parameters”params
Section titled “params”Unwrap parameters
Returns
Section titled “Returns”Promise<UnwrapResult>
Unwrap result with success status
transfer()
Section titled “transfer()”transfer(
params):Promise<ConfidentialTransferResult>
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21505
Execute a confidential transfer
Parameters
Section titled “Parameters”params
Section titled “params”Transfer parameters
csplMint
Section titled “csplMint”string
string
string
encryptedAmount
Section titled “encryptedAmount”Uint8Array
string
Returns
Section titled “Returns”Promise<ConfidentialTransferResult>
Transfer result with success status
getBalance()
Section titled “getBalance()”getBalance(
csplMint,owner):Promise<ConfidentialBalance|null>
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21519
Get confidential balance for an account
Parameters
Section titled “Parameters”csplMint
Section titled “csplMint”string
C-SPL token mint address
string
Account owner address
Returns
Section titled “Returns”Promise<ConfidentialBalance | null>
Confidential balance or null if not found
approve()
Section titled “approve()”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.
Parameters
Section titled “Parameters”params
Section titled “params”Approval parameters
Returns
Section titled “Returns”Promise<ApproveResult>
Approval result
revoke()
Section titled “revoke()”revoke(
csplMint,_delegate,_owner):Promise<ApproveResult>
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21537
Revoke a delegate’s approval
Parameters
Section titled “Parameters”csplMint
Section titled “csplMint”string
C-SPL token mint address
_delegate
Section titled “_delegate”string
_owner
Section titled “_owner”string
Returns
Section titled “Returns”Promise<ApproveResult>
Revoke result
estimateCost()
Section titled “estimateCost()”estimateCost(
operation):Promise<bigint>
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21544
Estimate cost for an operation
Parameters
Section titled “Parameters”operation
Section titled “operation”Operation type (‘wrap’, ‘unwrap’, ‘transfer’, ‘approve’)
"transfer" | "wrap" | "unwrap" | "approve"
Returns
Section titled “Returns”Promise<bigint>
Estimated cost in lamports
getSupportedTokens()
Section titled “getSupportedTokens()”getSupportedTokens():
CSPLToken[]
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21550
Get all supported/registered tokens
Returns
Section titled “Returns”CSPLToken[]
Array of registered C-SPL tokens
registerToken()
Section titled “registerToken()”registerToken(
token):void
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21556
Register a token for use with the service
Parameters
Section titled “Parameters”CSPLToken
Token to register
Returns
Section titled “Returns”void
getStatus()
Section titled “getStatus()”getStatus():
CSPLServiceStatus
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21562
Get service status
Returns
Section titled “Returns”Service status information
disconnect()
Section titled “disconnect()”disconnect():
Promise<void>
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:21566
Disconnect and cleanup
Returns
Section titled “Returns”Promise<void>