https://github.com/shiny-lua/capsule-miniapp
https://github.com/shiny-lua/capsule-miniapp
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/shiny-lua/capsule-miniapp
- Owner: shiny-lua
- Created: 2024-11-14T16:25:15.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-14T16:27:52.000Z (over 1 year ago)
- Last Synced: 2025-04-10T04:34:21.958Z (about 1 year ago)
- Language: TypeScript
- Size: 302 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Capsule Telegram Mini-App

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](https://capsule-org.github.io/capsule-telegram-miniapp/))
Then, make a telegram bot [(See Telegram's Guide Here)](https://core.telegram.org/bots/tutorial) and point it to open
this link
## Try it out

A Telegram mini-app linked to this app is [here](https://t.me/capsule_miniapp_bot)