Skip to main content
This project includes a repository script CLI (not a published npm binary):
  • scripts/telegram-private-transfer.ts

Command Syntax

bun scripts/telegram-private-transfer.ts <delegate|send|subscribe|claim|undelegate>

Prerequisites

  • Build Anchor artifacts so target/idl/* and target/types/* exist:
anchor build
  • Provide valid signer keypairs (SENDER_KEYPAIR, CLAIMER_KEYPAIR) or use ~/.config/solana/id.json defaults.
  • Configure base and ephemeral RPC endpoints as needed.

Commands

  • delegate: initializes/funds sender deposit, ensures username deposit, creates permissions, delegates both deposits.
  • send: executes transferToUsernameDeposit on PER.
  • subscribe: watches username deposit updates on PER until interrupted (or until TARGET_AMOUNT).
  • claim: claims from username deposit to recipient ATA using verified Telegram session.
  • undelegate: commits and undelegates sender + username deposits back to base.

Important Environment Variables

  • PROVIDER_ENDPOINT / ANCHOR_PROVIDER_URL: base RPC (default http://127.0.0.1:8899)
  • WS_ENDPOINT: base WS (default derived from base RPC)
  • EPHEMERAL_PROVIDER_ENDPOINT: PER RPC (default http://127.0.0.1:7799)
  • EPHEMERAL_WS_ENDPOINT: PER WS (default ws://127.0.0.1:7800 for local)
  • EPHEMERAL_AUTH: set true to request MagicBlock auth token for hosted PER
  • ER_VALIDATOR: validator pubkey (default from script)
  • SENDER_KEYPAIR, CLAIMER_KEYPAIR: keypair file paths
  • TOKEN_MINT: override mint; otherwise script reads/writes STATE_PATH
  • STATE_PATH: defaults to scripts/.state/telegram-private-transfer.json
  • DEPOSIT_AMOUNT, SEND_AMOUNT, CLAIM_AMOUNT, TARGET_AMOUNT: raw token amounts
  • AIRDROP: if true, request localnet airdrop when balance is low

End-to-End Example

# 1) Delegate and prepare state
bun scripts/telegram-private-transfer.ts delegate

# 2) Optional watcher (run in a separate terminal)
bun scripts/telegram-private-transfer.ts subscribe

# 3) Send on PER
bun scripts/telegram-private-transfer.ts send

# 4) Claim to recipient ATA
bun scripts/telegram-private-transfer.ts claim

# 5) Commit + undelegate
bun scripts/telegram-private-transfer.ts undelegate

Flow Mapping

The CLI commands map to SDK operations as follows:
CLI CommandSDK Operations
delegateinitializeDepositmodifyBalance(increase)initializeUsernameDepositcreatePermission / createUsernamePermissiondelegateDeposit / delegateUsernameDeposit
sendtransferToUsernameDeposit (on PER)
subscribegetEphemeralUsernameDeposit polling
claimclaimUsernameDepositToDeposit (on PER)
undelegateundelegateDeposit / undelegateUsernameDepositmodifyBalance(decrease)

Notes

  • subscribe listens for account changes and can auto-exit once TARGET_AMOUNT is reached.
  • The script uses a state file to persist mint context between commands.
  • This CLI is a repo operational tool and may evolve with program workflows.