-
Notifications
You must be signed in to change notification settings - Fork 5
TS script for generate TON wallet #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8cd8e08
38b3835
bc9baa6
cd3184f
94d691c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||||||||||||||||||||
| # Generate TON wallet | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| This is a typescript that generates a TON wallets and prints the mnemonic, secret and address to the console. | ||||||||||||||||||||||||
| ## Usage | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||
| npm install | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| npm run generate | ||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
| ## Examples | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||
| Mnemonic: unfair capable drastic increase bonus pledge ridge blue cube over fine daring frozen shrimp seat universe outside pen injury dumb enact artwork ship insane | ||||||||||||||||||||||||
| Wallet Secret Key: 56cc895313f7abba1f2c6cd36d42e8737ced6138cba80f4381008a055ba9c30b135e61a6c3397e01ddf96af08d7a8f18eff8efcfc7a9ba5f7f05ce69f04a34ad | ||||||||||||||||||||||||
| Public Key: 135e61a6c3397e01ddf96af08d7a8f18eff8efcfc7a9ba5f7f05ce69f04a34ad | ||||||||||||||||||||||||
| Wallet v4 Address: EQDpKqfyCfFAmAtv7ihG2awG9psdAz1t-eFvi7gUJ13Z1GBY | ||||||||||||||||||||||||
| Wallet v5 Address: EQByKwFuc1AFjCAWdGay-kLzoOmqsg0qaX44wU3FENX6PT2n | ||||||||||||||||||||||||
|
Comment on lines
+14
to
+18
|
||||||||||||||||||||||||
| Mnemonic: unfair capable drastic increase bonus pledge ridge blue cube over fine daring frozen shrimp seat universe outside pen injury dumb enact artwork ship insane | |
| Wallet Secret Key: 56cc895313f7abba1f2c6cd36d42e8737ced6138cba80f4381008a055ba9c30b135e61a6c3397e01ddf96af08d7a8f18eff8efcfc7a9ba5f7f05ce69f04a34ad | |
| Public Key: 135e61a6c3397e01ddf96af08d7a8f18eff8efcfc7a9ba5f7f05ce69f04a34ad | |
| Wallet v4 Address: EQDpKqfyCfFAmAtv7ihG2awG9psdAz1t-eFvi7gUJ13Z1GBY | |
| Wallet v5 Address: EQByKwFuc1AFjCAWdGay-kLzoOmqsg0qaX44wU3FENX6PT2n | |
| # Example output (values below are placeholders; never share your real mnemonic or keys) | |
| Mnemonic: <your 24-word mnemonic phrase here> | |
| Wallet Secret Key: <your wallet secret key here> | |
| Public Key: <your public key here> | |
| Wallet v4 Address: <your wallet v4 address here> | |
| Wallet v5 Address: <your wallet v5 address here> |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||
| // generate-wallet.ts | ||||||
| import { mnemonicNew, mnemonicToWalletKey } from "@ton/crypto"; | ||||||
| import { WalletContractV4, WalletContractV5R1} from "@ton/ton"; | ||||||
|
|
||||||
| async function main() { | ||||||
| const mnemonic = await mnemonicNew(); | ||||||
| console.log("Mnemonic:", mnemonic.join(" ")); | ||||||
|
|
||||||
| const key = await mnemonicToWalletKey(mnemonic); | ||||||
| const walletv4 = WalletContractV4.create({ workchain: 0, publicKey: key.publicKey }); | ||||||
| const walletv5 = WalletContractV5R1.create({ workchain: 0, publicKey: key.publicKey }); | ||||||
|
|
||||||
| console.log("Wallet Secret Key:", key.secretKey.toString("hex")); // Are we storing the hex in secrets manager? | ||||||
|
||||||
| console.log("Wallet Secret Key:", key.secretKey.toString("hex")); // Are we storing the hex in secrets manager? | |
| console.log("Wallet Secret Key generated. Handle and store it securely; it is not printed to the console."); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "name": "ton-wallet-generator", | ||
| "version": "1.0.0", | ||
| "description": "Generate TON wallet addresses", | ||
| "main": "generate-wallet.ts", | ||
| "scripts": { | ||
| "generate": "npx ts-node generate-wallet.ts" | ||
| }, | ||
| "dependencies": { | ||
| "@ton/crypto": "^3.3.0", | ||
| "@ton/ton": "^15.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "ts-node": "^10.9.2", | ||
| "typescript": "^5.3.3" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2020", | ||
| "module": "commonjs", | ||
| "strict": true, | ||
| "esModuleInterop": true, | ||
| "skipLibCheck": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "outDir": "./dist", | ||
| "resolveJsonModule": true | ||
| }, | ||
| "include": ["*.ts"], | ||
| "exclude": ["node_modules"] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected grammar: 'a typescript' should be 'a TypeScript script' and 'a TON wallets' should be 'TON wallets'.