metadata: {"title": "Tonspack Telegram Non-custodial Wallet SDK", "logoImg": "bafkreidaks26nnzbspm3t2ujmx4wmvgvqepn6pnbf46jzilrynutc5i6ja", "website": "https://www.tonspack.com/sdk.html", "bannerImg": "bafkreibfwfsh3qoumj5teyyi2j2qy5v4amdstm5gumgaxqn2s5mnlwqdky", "createdAt": 1729165277146, "userGithub": "carzygod", "credentials": {"github": {"type": ["VerifiableCredential"], "proof": {"jws": "eyJhbGciOiJFZERTQSIsImNyaXQiOlsiYjY0Il0sImI2NCI6ZmFsc2V9..1dmMBuLhJkVF7ZfFQGDgL3dDJloGDB1vfdu61Ew2P-SOpBYyhsEb0sJyN3Hp85HaP3y3IQwn9I_7hTohGiJeCA", "type": "Ed25519Signature2018", "created": "2024-10-17T11:47:36.380Z", "proofPurpose": "assertionMethod", "verificationMethod": "did:key:z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC#z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC"}, "issuer": "did:key:z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC", "@context": ["https://www.w3.org/2018/credentials/v1"], "issuanceDate": "2024-10-17T11:47:36.380Z", "expirationDate": "2025-01-15T11:47:36.380Z", "credentialSubject": {"id": "did:pkh:eip155:1:0xf46c8982c90792F50e840Cb01eD90881D45aFF81", "hash": "v0.0.0:kiZLqa9bT/19SpUiBQdbAoIxWQgj9Sc1E7ZqKo2GJ/o=", "@context": [{"hash": "https://schema.org/Text", "provider": "https://schema.org/Text"}], "provider": "ClearTextGithubOrg#Tonspay#32446081"}}, "twitter": {"type": ["VerifiableCredential"], "proof": {"jws": "eyJhbGciOiJFZERTQSIsImNyaXQiOlsiYjY0Il0sImI2NCI6ZmFsc2V9..ieVnkOYNvsrQSW1MyxwAtmST31UtHeAPO4w9EMxIjqvQmvOQ-LwqIRflhR-QJX8nW_YEaHwJqNZnR1xrTdksDA", "type": "Ed25519Signature2018", "created": "2024-10-17T11:33:11.186Z", "proofPurpose": "assertionMethod", "verificationMethod": "did:key:z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC#z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC"}, "issuer": "did:key:z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC", "@context": ["https://www.w3.org/2018/credentials/v1"], "issuanceDate": "2024-10-17T11:33:11.185Z", "expirationDate": "2025-01-15T11:33:11.185Z", "credentialSubject": {"id": "did:pkh:eip155:1:0xf46c8982c90792F50e840Cb01eD90881D45aFF81", "hash": "v0.0.0:986xVw1uXlK1DdcLfKBpjDdKgci8EqyRajllA58Ja5E=", "@context": [{"hash": "https://schema.org/Text", "provider": "https://schema.org/Text"}], "provider": "ClearTextTwitter#tonsprotocols"}}}, "description": "# CloudStorage Wallet SDK\n\nDocs :\nhttps://docs.tonspack.com/sdk/cloudstorage-wallet-sdk\n\nDemo:\nhttps://web.telegram.org/a/#?tgaddr=tg%3A%2F%2Fresolve%3Fdomain%3Dtonspack_bot%26appname%3Dcsdemo\n\nSource Code:\n\nhttps://github.com/Tonspay/Tonspack-HD-generator\n\nhttps://github.com/Tonspay/Telegram-Webapp-CloudStorag-Multichain-Wallet-Solution\n\nNPM :\n\nhttps://www.npmjs.com/package/@tonsprotocol/telegram-cloudstorage-wallet\n\nhttps://www.npmjs.com/package/@tonsprotocol/hdwallet\n\nOverview\nThe 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\u2019s cloud storage, ensuring that users can recover their wallet in subsequent sessions.\n\nFeatures\nAutomatically generate a master keypair.\n\nSecure password setup for encryption.\n\nDerive multichain keypairs using HD wallet functionality.\n\nAutomatically store and retrieve the master keypair in Telegram\u2019s cloud storage.\n\nNon-custodial, ensuring full control for the user.\n\n\nGetting Started\nInstall the SDK: Install either the HD Wallet SDK or the Cloud Storage Wallet SDK, depending on your use case.\n\nGenerate Keypairs: Use the HD Wallet SDK to generate multichain keypairs or the Cloud Storage Wallet SDK for fully non-custodial wallet management.\n\nBuild dApps: Use the SDK\u2019s simple API to integrate wallet functionality into your Telegram webapps, allowing users to manage crypto assets seamlessly across multiple chains.\n\nHow to use it ?\nInstall the package\n\n```\npnpm i @tonsprotocol/telegram-cloudstorage-wallet\nNow try use it in your font-end\n```\n```\nimport CloudStorageWallet from \"@tonsprotocol/telegram-cloudstorage-wallet\" \n\n```\nawait CloudStorageWallet.init(\"mywallet\")\n\n# HD Wallet SDK\n\nDocs: \nhttps://docs.tonspack.com/sdk/hd-wallet-sdk\n\nA wallet to generate master keypair for multichians stander.\n\nOverview\nThis 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.\n\nFeatures\nGenerate a master keypair.\n\nDerive keypairs for different blockchain networks.\n\nCompliant with the BIP-44 standard for HD wallets.\n\nSupport for multiple chains.\n\nCurrently Tonspack HD wallet sdk support follow chains\nEVM\n\nTON\n\nSOLANA\n\nNow working on chains support TODO :\nTRON\n\nBTC\n\nSUI\n\nAPTOS\n\nCOSMOS\n\nHow to use this SDK ?\nTonsprotocol/HDwallet SDK support many actions including\n\nGenerate new wallet\n\nGenerate keypairs for different chains stander\n\nSign message in different stander\n\nSign and get the signed transaction (Limited chains)\n\nGenerate the keypair\n\nYou can create a wallet by new it .\n\n```\nimport { HDWallet } from \"@tonsprotocol/hdwallet\";\n\nnew HDWallet()\n```\n\nOr you can add password\n\n```\nimport { HDWallet } from \"@tonsprotocol/hdwallet\";\n\nnew HDWallet(\n  {\n    pwd:\"helloworld\", // Optional\n    path:123, //Optional . default 1 \n  }\n)\n\n```\nGet the keypairs\n\nYou will got the Keypair for the support chains :\n\n```\ninterface objKP {\n  naclKp: {\n    publicKey: Uint8Array;\n    secretKey: Uint8Array;\n  };\n  evmKp: {\n    address: string;\n    privateKey: string;\n  };\n  solKp: {\n    address: string;\n    privateKey: string;\n  };\n  tonKp: any;\n}\n```\nRecover from master keypair\n\nYou can recover your keypair with path/password via :\n\n```js\nHDWallet.fromPrivateKey(\n  {\n        sk:\"2Lte2V623NW7pafsAbpzGTQQ8y6Kbnzwop39RyybkPFessboN92d2pUfZi4Xi8KkFccqmC1zyRZ6wfRY2EKgqDu6\",\n        pwd:\"1234\",\n        path:16\n  }\n)\n```\nor\n\n```ts\nHDWallet.fromPrivateKey(\n  {\n        sk:\"2dnv6i5vLQFRFFQKpyVhxvijQHE7orgReQJVJ12PboKw\",\n  }\n)\n\n```\nHow it works ?\nYou can check the source code for details .\n\nThe core is base on BIP-44 (will add BIP-39 soon)\n\n```ts\n  private fromPk(sec:string,path:number,pwd?:string) {\n    let rawKey : Buffer;\n    if(pwd)\n    {\n      rawKey = Buffer.from(bs58.decode(\n        decryptByDES(sec,pwd)\n      ))\n    }else{\n      rawKey = Buffer.from(\n        bs58.decode(sec)\n      );\n    }\n    const master = hd.hdkey.fromMasterSeed(\n      Buffer.from(\n        bs58.decode(sec))\n      )\n      ;\n    const derive = master.deriveChild(path);\n    const evmWallet = derive.getWallet();\n    const naclKp = nacl.sign.keyPair.fromSeed(\n      Uint8Array.from(evmWallet.getPrivateKey())\n    );\n\n\n    return {\n      naclKp: naclKp,\n      evmKp: {\n        address: evmWallet.getAddressString(),\n        privateKey: evmWallet.getPrivateKeyString(),\n      },\n      solKp: {\n        address: bs58.encode(naclKp.publicKey),\n        privateKey: bs58.encode(naclKp.secretKey),\n      },\n      tonKp: ton.getTonWalletV4KeyPair(Buffer.from(naclKp.secretKey), 0),\n    } as objKP;\n  }\n```", "logoImgData": {}, "bannerImgData": {}, "projectGithub": "Tonspay", "projectTwitter": "tonsprotocols"}
name: Tonspack Telegram Non-custodial Wallet SDK