Home Web Front-end JS Tutorial TMA Wallet — a non-custodial MPC wallet for your Telegram Mini App

TMA Wallet — a non-custodial MPC wallet for your Telegram Mini App

Jan 15, 2025 am 07:25 AM

TMA Wallet — a non-custodial MPC wallet for your Telegram Mini App

JavaScript · Cryptocurrencies · Cryptography

Overview

Hello everyone! I guess you already know that for about a year now there’s been a boom of mini apps in Telegram everyone tapped on the hamster. Most of these mini apps are related to crypto. Many developers want to provide their users with a wallet inside the app (EVM, TON, Solana, etc.)—basically a virtual account that can be topped up, can withdraw funds, and most importantly, can call smart contracts.

A simple but unsafe solution is to store all the keys on your server and make transactions on behalf of the user. If someone hacks your server, all client funds are lost. It’s hard to earn people’s trust in that scenario.

A complex but inconvenient solution is a wallet that the user must write down on a piece of paper and manage by themselves. In that case, you might as well just use WalletConnect or not build a mini app at all. The problem is that your mini app’s UI could become painful: the user would have to confirm every action in an external app.

We looked for an option for our mini app that offers the security of a non-custodial wallet with the smoothest possible UX/UI. And we found it.

In this article, I’ll review TMA Wallet (npm package, website, GitHub)—an open-source, non-custodial, multi-party wallet suitable for any chain, which works using the recently introduced Telegram Cloud Storage API.

Let’s go!


Very Brief Explanation of Terms

  • Wallet = Private Key. This private key is used to sign transactions and grants its owner the right to control the funds at a specific blockchain address.

  • Custodial Wallet = Some organization owns your private key and can act on your behalf. A classic example is a crypto exchange like Binance. It’s convenient but requires great trust in the organization.

  • Non-custodial Wallet = You alone have your private key. It’s stored on your device, and all actions with your funds are done by you or with your confirmation. The main issue is that it’s easy to lose. If you lose your private key, you lose your funds.

  • MPC (multi-party computation) = An attempt to solve the “lost wallet” issue: the key is split into several parts, stored in different places, and all parts are needed to form a signature on a transaction. In this scenario, hacking one party doesn’t let you access the user’s funds. Meanwhile, the user doesn’t need to store the key entirely on their own.

So, a non-custodial MPC wallet is a wallet where the private key is split into parts stored in different locations and never fully assembled by any single party.


What Exactly Is TMA Wallet?

TMA Wallet is a non-custodial, multi-party (MPC) wallet that uses Telegram Cloud Storage for secure key storage. Everything is linked to the user’s Telegram account, so they don’t have to remember any seed phrases or set up external wallets. The flow is so smooth that your user might not even realize there’s a crypto wallet under the hood—you can build a completely friendly UI and hide the blockchain magic from the user.

Here are some of the main advantages:

  1. Easy Integration: Just install the npm package, plug it into your code, and that’s it. Every user of your mini app now has a wallet.

  2. No TON Connect or WalletConnect Workarounds: The user stays entirely in Telegram; all transactions are signed “under the hood.”

  3. MPC Technology: The private key isn’t available to anyone—not Telegram, not your server, not TMA Wallet’s servers. It’s only put together on the user’s device for a few nanoseconds (while signing a transaction) and then disappears.

  4. Easy Recovery: Lost your phone? No problem—get a new one, log into Telegram, and the wallet is automatically restored.

  5. Access from Multiple Devices: If the user opens the mini app from a desktop client with the same Telegram account, they’ll get access to the same wallet as on their phone.

  6. Open-Source: Everything is on GitHub. You can review and verify security yourself or commission an audit.

  7. Viem/Wagmi/Ethers.js Support: If you’re working on any EVM-compatible chain (Ethereum, BSC, Polygon, etc.), you can use standard libraries.

  8. Supports Any Chain: EVM chains are supported out of the box, but TMA Wallet is basically a system for separate storage of any secret. So you could store a private key for TON, Solana, or any other chain.


How Does It Work “Under the Hood”?

As I’ve mentioned, TMA Wallet is based on MPC principles, where the private key is effectively shared between multiple parties and only reassembled briefly on the client side to sign transactions. Here’s a short summary:

  1. When the user first opens your mini app, the user’s device generates a ClientPublicKey and ClientSecretKey. The ClientSecretKey is saved in Telegram Cloud Storage.

  2. The ClientPublicKey and WebApp.initData (signed by Telegram) are sent to the server.

  3. The server checks that Telegram’s signature is valid and (optionally) asks the user for extra authentication (2FA). It’s optional, and you don’t have to if you don’t want to.

  4. The server then generates an IntermediaryKey by signing (ClientPublicKey telegramUserId) with its own ServerSecretKey. Then it encrypts this IntermediaryKey before sending it back to the client.

  5. The IntermediaryKey returns to the client and is decrypted there.

  6. Finally, the client signs the IntermediaryKey with ClientSecretKey, resulting in the WalletPrivateKey (the actual private key of the wallet).

This key is used to sign the transaction and is never saved anywhere long term. For each new action, that chain of steps (except step 1) is repeated.

In the end, the app’s UX looks perfect: login is seamless thanks to auto-auth in mini apps, and transactions are seamless because there’s an in-app wallet.


How to Add It to Your Mini App?

  1. Install the SDK:

1

npm install --save @tmawallet/sdk

Copy after login
  1. Initialize the key in your code:

1

2

3

4

5

6

7

8

9

10

11

import { TMAWalletClient } from '@tmawallet/sdk';

import { ethers } from 'ethers';

 

// Don't forget to sign up at dash.tmawallet.com

const myApiKey = '1234567812345678'; // Your API key

const client = new TMAWalletClient(myApiKey);

 

// Authorize the user and create/load their wallet

await client.authenticate();

 

console.log('Your wallet address: ', client.walletAddress);

Copy after login
  1. Example of making a transaction (here using Ethers.js):

1

2

3

4

5

6

7

8

9

// Use TMA Wallet as the "signer" for ethers

const provider = new ethers.JsonRpcProvider();

const signer = client.getEthersSigner(provider);

 

const tx = await signer.sendTransaction({

  to: '0x...',

  value: ethers.parseEther('1.0'),

});

console.log('Transaction hash:', tx.hash);

Copy after login

And that’s it.


FAQ

Below are questions (slightly edited) from TMA Wallet’s README, with their answers:

Is this definitely secure?

Yes, that’s the core idea. Thanks to the MPC protocol, neither TMA Wallet’s servers, Telegram, nor you have full access to the private key—only the user does.

Do I have to give you access to my bot’s token?

No. We’re one of the first to support Telegram’s new asymmetric signature scheme. We only need your bot’s ID, which is already public.

Which blockchain can be supported?

Any. EVM blockchains (Ethereum, etc.) work out of the box with ethers.js. For something custom, you can use the accessPrivateKey method.

What if the user loses their device?

As long as they have access to their Telegram account, they just log in on a new device, and the wallet is restored automatically. No seed phrase is required.

Can I back up the key?

Technically yes, but you probably don’t need to. The wallet can already be restored through Telegram. If you want, you can let the user back it up, but that’s at your own risk.


Conclusion

We used TMA Wallet in two of our own apps. One is already in production (I was a bit shy to post the link at the start, but I think it’s okay to mention here in the footer: Only100x).

It’s a great option for anyone building Telegram mini apps who wants to give users a secure wallet without messing up the UX with external connectors.

Feel free to try it and explore the documentation. All the project’s code is open on GitHub. Good luck!


Tags:

telegram mini app · crypto · non-custodial wallet · tma wallet

The above is the detailed content of TMA Wallet — a non-custodial MPC wallet for your Telegram Mini App. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What should I do if I encounter garbled code printing for front-end thermal paper receipts? What should I do if I encounter garbled code printing for front-end thermal paper receipts? Apr 04, 2025 pm 02:42 PM

Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

Demystifying JavaScript: What It Does and Why It Matters Demystifying JavaScript: What It Does and Why It Matters Apr 09, 2025 am 12:07 AM

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

Who gets paid more Python or JavaScript? Who gets paid more Python or JavaScript? Apr 04, 2025 am 12:09 AM

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

Is JavaScript hard to learn? Is JavaScript hard to learn? Apr 03, 2025 am 12:20 AM

Learning JavaScript is not difficult, but it is challenging. 1) Understand basic concepts such as variables, data types, functions, etc. 2) Master asynchronous programming and implement it through event loops. 3) Use DOM operations and Promise to handle asynchronous requests. 4) Avoid common mistakes and use debugging techniques. 5) Optimize performance and follow best practices.

How to merge array elements with the same ID into one object using JavaScript? How to merge array elements with the same ID into one object using JavaScript? Apr 04, 2025 pm 05:09 PM

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

How to achieve parallax scrolling and element animation effects, like Shiseido's official website?
or:
How can we achieve the animation effect accompanied by page scrolling like Shiseido's official website? How to achieve parallax scrolling and element animation effects, like Shiseido's official website? or: How can we achieve the animation effect accompanied by page scrolling like Shiseido's official website? Apr 04, 2025 pm 05:36 PM

Discussion on the realization of parallax scrolling and element animation effects in this article will explore how to achieve similar to Shiseido official website (https://www.shiseido.co.jp/sb/wonderland/)...

The Evolution of JavaScript: Current Trends and Future Prospects The Evolution of JavaScript: Current Trends and Future Prospects Apr 10, 2025 am 09:33 AM

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

The difference in console.log output result: Why are the two calls different? The difference in console.log output result: Why are the two calls different? Apr 04, 2025 pm 05:12 PM

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...

See all articles