Skip to content

Example Telegram Mini App with Capsule Pregenerated Wallets

Notifications You must be signed in to change notification settings

jlm0/twa-external-wallets

 
 

Repository files navigation

Capsule Telegram Mini-App

image

This template provides a minimal setup to get Capsule Pre-generated wallets working in a Mini-App

Key Steps

  1. Initialize the App

    • When the mini-app starts, it calls initializeApp() which checks for an existing wallet.
  2. Generate Wallet

    • If no wallet exists, generateWallet() is called to create a pre-generated wallet using capsuleClient.createWalletPreGen().
  3. Store Wallet Data

    • After wallet creation, the user share and wallet ID need to be stored.
    • Due to storage limitations, data is chunked using storeWithChunking().
    • This process runs asynchronously to avoid blocking the app.
  4. Retrieve Wallet Data

    • When the app starts, it attempts to retrieve stored data using retrieveChunkedData().
    • This function reassembles the chunked data.
  5. Sign Messages

    • Once the wallet is set up, users can sign messages using signMessage().
  6. Clear Storage

    • Users can clear all stored data using clearChunkedStorage().

Note: The app can start signing transactions as soon as the wallet is created. However, ensure the user doesn't close the app until the storage of the user share is completed.

Usage

First, deploy your app to a link (This repo is hosted here)

Then, make a telegram bot (See Telegram's Guide Here) and point it to open this link

Try it out

image

A Telegram mini-app linked to this app is here

About

Example Telegram Mini App with Capsule Pregenerated Wallets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 83.2%
  • JavaScript 9.4%
  • CSS 5.9%
  • HTML 1.5%