Package
Main Client
LoyalPrivateTransactionsClient
The SDK client wraps both base-layer and PER (Private Ephemeral Rollup) program access. All operations route to the correct layer automatically.
Factory
Core Methods
Deposit Initialization
initializeDeposit(params): Promise<string>
Create a deposit account for a user and token mint on the base layer. No-op if the account already exists.
initializeUsernameDeposit(params): Promise<string>
Create a username-based deposit account. Validates username (5–32 chars, alphanumeric + underscore).
Balance Operations
modifyBalance(params): Promise<ModifyBalanceResult>
Deposit or withdraw real SPL tokens to/from the program vault. Requires the deposit to be not delegated.
increase: true— transfers tokens from user’s ATA to vault, increments depositamountincrease: false— transfers tokens from vault to user’s ATA, decrements depositamount
Claim
claimUsernameDepositToDeposit(params): Promise<string>
Transfer tokens from a username deposit to the recipient’s user deposit. Both accounts must be delegated. Requires a verified Telegram session matching the username.
Permission Management
createPermission(params): Promise<string | null>
Create a PER access control account for a user deposit. Returns null if the permission already exists. Deposit must be not delegated.
createUsernamePermission(params): Promise<string | null>
Create PER access control for a username deposit. Requires a verified Telegram session.
Delegation
delegateDeposit(params): Promise<string>
Delegate a user deposit to the TEE validator for PER execution. Account must be not already delegated.
delegateUsernameDeposit(params): Promise<string>
Delegate a username deposit to PER.
undelegateDeposit(params): Promise<string>
Commit PER state and return deposit ownership to the program on the base layer. Account must be delegated. Waits for ownership to change back to PROGRAM_ID on the base connection.
undelegateUsernameDeposit(params): Promise<string>
Commit and return username deposit ownership to the program.
Private Transfers
These execute on the PER layer — both source and destination accounts must be delegated.transferDeposit(params): Promise<string>
Transfer balance between two user deposits (accounting only, no token movement).
transferToUsernameDeposit(params): Promise<string>
Transfer from a user deposit to a username deposit.
Queries
Query deposit state from either the base layer or the ephemeral layer.getBaseDeposit(user, tokenMint): Promise<DepositData | null>
Fetch a user deposit from the base layer.
getEphemeralDeposit(user, tokenMint): Promise<DepositData | null>
Fetch a user deposit from PER.
getBaseUsernameDeposit(username, tokenMint): Promise<UsernameDepositData | null>
Fetch a username deposit from the base layer.
getEphemeralUsernameDeposit(username, tokenMint): Promise<UsernameDepositData | null>
Fetch a username deposit from PER.
PDA Helpers (instance)
findDepositPda(user, tokenMint): [PublicKey, number]findUsernameDepositPda(username, tokenMint): [PublicKey, number]findVaultPda(tokenMint): [PublicKey, number]
Accessors
publicKey: PublicKey— connected wallet’s public keygetBaseProgram(): Program— underlying base-layer Anchor programgetEphemeralProgram(): Program— underlying PER-layer Anchor programgetProgramId(): PublicKey— returnsPROGRAM_ID
Exported Types
Type Guards
isKeypair(signer): signer is KeypairisAnchorProvider(signer): signer is AnchorProviderisWalletLike(signer): signer is WalletLike
Exported Constants
| Constant | Value |
|---|---|
PROGRAM_ID | 97FzQdWi26mFNR21AbQNg4KqofiCLqQydQfAvRQMcXhV |
DELEGATION_PROGRAM_ID | DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh |
PERMISSION_PROGRAM_ID | ACLseoPoyC3cBqoUtkbjZ4aDrkurZW86v19pXz2XQnp1 |
ER_VALIDATOR | FnE6VJT5QNZdedZPnCoLsARgBwoE6DeJNjBs2H1gySXA |
MAGIC_PROGRAM_ID | Magic11111111111111111111111111111111111111 |
MAGIC_CONTEXT_ID | MagicContext1111111111111111111111111111111 |
PDA Seeds
| Constant | String Value |
|---|---|
DEPOSIT_SEED | "deposit_v2" |
USERNAME_DEPOSIT_SEED | "username_deposit_v2" |
VAULT_SEED | "vault" |
PERMISSION_SEED | "permission:" |
Utilities
solToLamports(sol: number): numberlamportsToSol(lamports: number): numberLAMPORTS_PER_SOL
Exported PDA Helpers (standalone)
| Function | Seeds |
|---|---|
findDepositPda(user, tokenMint) | ["deposit_v2", user, tokenMint] |
findUsernameDepositPda(username, tokenMint) | ["username_deposit_v2", username, tokenMint] |
findVaultPda(tokenMint) | ["vault", tokenMint] |
findPermissionPda(account) | ["permission:", account] (PERMISSION_PROGRAM_ID) |
findDelegationRecordPda(account) | ["delegation", account] (DELEGATION_PROGRAM_ID) |
findDelegationMetadataPda(account) | ["delegation-metadata", account] (DELEGATION_PROGRAM_ID) |
findBufferPda(account) | ["buffer", account] (PROGRAM_ID) |

