Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 66 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,66 @@
# examples
TON JS examples
# TON JS Examples

This repository contains a collection of JavaScript examples demonstrating various functionalities of The Open Network (TON) blockchain using the `tonweb` library.

## Prerequisites

- Node.js (v14 or higher)
- npm (Node Package Manager)

## Installation

1. Clone this repository:
```bash
git clone https://github.com/yourusername/ton-examples.git
cd ton-examples
```

2. Install dependencies:
```bash
npm install
```

## Available Examples

### Deposit Examples
- `deposits.js` - Basic deposit functionality
- `deposits-multi-wallets.js` - Handling deposits with multiple wallets
- `deposits-jettons.js` - Working with Jetton deposits
- `deposits-jettons-multi-wallets.js` - Managing multiple Jetton deposits

### Withdrawal Examples
- `withdrawals.js` - Basic withdrawal functionality
- `withdrawals-highload.js` - High-load withdrawal operations
- `withdrawals-jettons.js` - Jetton withdrawal operations
- `withdrawals-jettons-highload.js` - High-load Jetton withdrawals
- `withdrawals-highload-batch.js` - Batch processing for high-load withdrawals
- `withdrawals-jettons-highload-batch.js` - Batch processing for high-load Jetton withdrawals

## Running Examples

To run any example, use Node.js with the ES modules flag:

```bash
node withdrawals.js
# or
node deposits-jettons.js
```

## Common Utilities

The `common.js` file contains shared utilities and helper functions used across different examples.

## Dependencies

- `tonweb` (v0.0.66) - TON blockchain JavaScript SDK
- `tonweb-mnemonic` (v1.0.1) - Mnemonic phrase utilities for TON

## License

This project is licensed under the ISC License - see the [LICENSE](LICENSE) file for details.

## Contributing

Feel free to submit issues and enhancement requests!


8 changes: 4 additions & 4 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const createKeyPair = async () => {
/** @type {nacl.SignKeyPair} */
const keyPair = TonWeb.utils.nacl.sign.keyPair.fromSeed(seed);

console.log(TonWeb.utils.bytesToHex(keyPair.publicKey));
console.log(TonWeb.utils.bytesToHex(keyPair.secretKey));
console.log("(1) Public key: ", TonWeb.utils.bytesToHex(keyPair.publicKey));
console.log("(1) Secret key: ", TonWeb.utils.bytesToHex(keyPair.secretKey));

// or
// 2. Generate new random key pair directly.
Expand All @@ -31,8 +31,8 @@ const createKeyPair = async () => {
/** @type {nacl.SignKeyPair} */
const keyPair2 = TonWeb.utils.nacl.sign.keyPair();

console.log(TonWeb.utils.bytesToHex(keyPair2.publicKey));
console.log(TonWeb.utils.bytesToHex(keyPair2.secretKey));
console.log("(2) Public key: ", TonWeb.utils.bytesToHex(keyPair2.publicKey));
console.log("(2) Secret key: ", TonWeb.utils.bytesToHex(keyPair2.secretKey));

}

Expand Down