SDK Validation Errors
Username validation
Triggered before transaction submission when username input is invalid:"Username must be between 5 and 32 characters""Username can only contain lowercase alphanumeric characters and underscores"
Delegation state errors
The SDK guards execution context for every operation:"Account is delegated to ER: ..."— a base-layer operation (modifyBalance,createPermission,initializeDeposit) was attempted on a delegated account. Undelegate first."Account is not delegated to ER: ..."— a PER operation (transferDeposit,transferToUsernameDeposit,claimUsernameDepositToDeposit) was attempted before delegation. Delegate first."Account is delegated on wrong validator: ..."— delegation authority does not match the expectedER_VALIDATOR.
Permission idempotency
createPermission and createUsernamePermission are idempotent:
- Return
nullwhen the permission account already exists. - May return
"permission-exists"if analready in userace condition is observed.
PER auth / signer capability errors
When auth is needed on hosted PER endpoints, the SDK may throw:"Wallet does not support signMessage, required for PER auth""AnchorProvider wallet does not support signMessage, required for PER auth"
signMessage support, or provide an explicit authToken in fromConfig.
On-Chain Program Errors
These are emitted by thetelegram-private-transfer program (97FzQdWi26mFNR21AbQNg4KqofiCLqQydQfAvRQMcXhV):
| Error Code | Message | When |
|---|---|---|
Unauthorized | "Unauthorized" | Session auth fails, permission mismatch, or signer does not match deposit owner |
Overflow | "Overflow" | Amount addition overflows u64 during deposit or claim |
InvalidMint | "Invalid Mint" | Token mint mismatch between accounts |
InsufficientVault | "Insufficient Vault" | Vault does not hold enough tokens for withdrawal |
InsufficientDeposit | "Insufficient Deposit" | Deposit or username deposit amount is less than the requested withdrawal/transfer |
NotVerified | "Not Verified" | Telegram session is not verified — store + verify_telegram_init_data must complete first |
ExpiredSignature | "Expired Signature" | Verification signature has expired |
Replay | "Replay" | Replay attack detected during verification |
InvalidEd25519 | "Invalid Ed25519" | Ed25519 signature verification failed |
InvalidUsername | "Invalid Username" | Username fails validation (length or character set), or username in session does not match the username deposit |
InvalidRecipient | "Invalid Recipient" | Recipient wallet does not match the expected claim target |
InvalidDepositor | "Invalid Depositor" | Depositor validation failed |
Troubleshooting Checklist
-
Delegation state mismatch — confirm the deposit is in the correct state for the method:
- Base-layer ops (
modifyBalance,createPermission,initializeDeposit): account must not be delegated - PER ops (
transferDeposit,transferToUsernameDeposit,claimUsernameDepositToDeposit): account must be delegated
- Base-layer ops (
-
Telegram session not verified — ensure the full verification flow completed:
store(validationBytes)on thetelegram-verificationprogramverify_telegram_init_data()with Ed25519 instruction- Check
session.verified === truebefore calling claim or username permission methods
- Token mint alignment — confirm all accounts (deposit, username deposit, vault, user ATA) use the same token mint
-
PER endpoint wiring — for hosted PER (
tee.magicblock.app):- Verify
ephemeralRpcEndpointandephemeralWsEndpointare set - Ensure signer supports
signMessagefor auth token acquisition, or passauthTokenexplicitly
- Verify
-
Insufficient balance —
InsufficientDepositmeans the deposit’samountis less than what you’re trying to transfer or withdraw. Check withgetBaseDeposit()orgetEphemeralDeposit() -
Username validation — usernames must be 5–32 characters, only
[a-zA-Z0-9_]. This is validated both client-side (SDK) and on-chain

