CloudStorage Wallet SDK
Docs : https://docs.tonspack.com/sdk/cloudstorage-wallet-sdk
Demo: https://web.telegram.org/a/#?tgaddr=tg%3A%2F%2Fresolve%3Fdomain%3Dtonspack_bot%26appname%3Dcsdemo
Source Code:
https://github.com/Tonspay/Tonspack-HD-generator
https://github.com/Tonspay/Telegram-Webapp-CloudStorag-Multichain-Wallet-Solution
NPM :
https://www.npmjs.com/package/@tonsprotocol/telegram-cloudstorage-wallet
https://www.npmjs.com/package/@tonsprotocol/hdwallet
Overview The Cloud Storage Wallet SDK allows developers to build fully non-custodial wallets for dApps inside Telegram webapps. The SDK automatically generates a master keypair, lets users set up a password for encryption, and derives multichain keypairs using the HD Wallet SDK. The master keypair is securely stored in Telegram’s cloud storage, ensuring that users can recover their wallet in subsequent sessions.
Features Automatically generate a master keypair.
Secure password setup for encryption.
Derive multichain keypairs using HD wallet functionality.
Automatically store and retrieve the master keypair in Telegram’s cloud storage.
Non-custodial, ensuring full control for the user.
Getting Started Install the SDK: Install either the HD Wallet SDK or the Cloud Storage Wallet SDK, depending on your use case.
Generate Keypairs: Use the HD Wallet SDK to generate multichain keypairs or the Cloud Storage Wallet SDK for fully non-custodial wallet management.
Build dApps: Use the SDK’s simple API to integrate wallet functionality into your Telegram webapps, allowing users to manage crypto assets seamlessly across multiple chains.
How to use it ? Install the package
pnpm i @tonsprotocol/telegram-cloudstorage-wallet
Now try use it in your font-end
import CloudStorageWallet from "@tonsprotocol/telegram-cloudstorage-wallet"
await CloudStorageWallet.init("mywallet")
HD Wallet SDK
Docs: https://docs.tonspack.com/sdk/hd-wallet-sdk
A wallet to generate master keypair for multichians stander.
Overview This SDK allows developers to generate hierarchical deterministic (HD) wallets following the BIP-44 standard. Using a master keypair, developers can derive keypairs for different blockchain networks, enabling support for multiple chains in a single wallet.
Features Generate a master keypair.
Derive keypairs for different blockchain networks.
Compliant with the BIP-44 standard for HD wallets.
Support for multiple chains.
Currently Tonspack HD wallet sdk support follow chains EVM
TON
SOLANA
Now working on chains support TODO : TRON
BTC
SUI
APTOS
COSMOS
How to use this SDK ? Tonsprotocol/HDwallet SDK support many actions including
Generate new wallet
Generate keypairs for different chains stander
Sign message in different stander
Sign and get the signed transaction (Limited chains)
Generate the keypair
You can create a wallet by new it .
import { HDWallet } from "@tonsprotocol/hdwallet";
new HDWallet()
Or you can add password
import { HDWallet } from "@tonsprotocol/hdwallet";
new HDWallet(
{
pwd:"helloworld", // Optional
path:123, //Optional . default 1
}
)
Get the keypairs
You will got the Keypair for the support chains :
interface objKP {
naclKp: {
publicKey: Uint8Array;
secretKey: Uint8Array;
};
evmKp: {
address: string;
privateKey: string;
};
solKp: {
address: string;
privateKey: string;
};
tonKp: any;
}
Recover from master keypair
You can recover your keypair with path/password via :
HDWallet.fromPrivateKey(
{
sk:"2Lte2V623NW7pafsAbpzGTQQ8y6Kbnzwop39RyybkPFessboN92d2pUfZi4Xi8KkFccqmC1zyRZ6wfRY2EKgqDu6",
pwd:"1234",
path:16
}
)
or
HDWallet.fromPrivateKey(
{
sk:"2dnv6i5vLQFRFFQKpyVhxvijQHE7orgReQJVJ12PboKw",
}
)
How it works ? You can check the source code for details .
The core is base on BIP-44 (will add BIP-39 soon)
private fromPk(sec:string,path:number,pwd?:string) {
let rawKey : Buffer;
if(pwd)
{
rawKey = Buffer.from(bs58.decode(
decryptByDES(sec,pwd)
))
}else{
rawKey = Buffer.from(
bs58.decode(sec)
);
}
const master = hd.hdkey.fromMasterSeed(
Buffer.from(
bs58.decode(sec))
)
;
const derive = master.deriveChild(path);
const evmWallet = derive.getWallet();
const naclKp = nacl.sign.keyPair.fromSeed(
Uint8Array.from(evmWallet.getPrivateKey())
);
return {
naclKp: naclKp,
evmKp: {
address: evmWallet.getAddressString(),
privateKey: evmWallet.getPrivateKeyString(),
},
solKp: {
address: bs58.encode(naclKp.publicKey),
privateKey: bs58.encode(naclKp.secretKey),
},
tonKp: ton.getTonWalletV4KeyPair(Buffer.from(naclKp.secretKey), 0),
} as objKP;
}
Tonspack Telegram Non-custodial Wallet SDK History
-
applied to the GG22 OSS - Developer Tooling and Libraries 3 weeks ago which was rejected