# @ton-api/ton-adapter

> TonApi adapter for @ton/ton

Latest version **0.4.1** (published 2025-04-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ton-api/ton-adapter
pnpm add @ton-api/ton-adapter
yarn add @ton-api/ton-adapter
bun add @ton-api/ton-adapter
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2025-04-23 |
| First published | 2024-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 40.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 86 |
| Author | Ton Apps |
| Maintainers | siandreev, mois-ilya |
| Keywords | TON, Blockchain, API, TonApi, Adapter |

## Links

- npm: https://www.npmjs.com/package/@ton-api/ton-adapter
- Repository: https://github.com/tonkeeper/tonapi-js
- Homepage: https://github.com/tonkeeper/tonapi-js/blob/main/packages/ton-adapter#readme
- Issues: https://github.com/tonkeeper/tonapi-js/issues
- npm.io page: https://npm.io/package/@ton-api/ton-adapter

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.4.1 (latest) — 2025-04-23
- 0.4.0-beta.1 (beta) — 2025-03-15
- 0.4.0 — 2025-03-17
- 0.3.2-beta.0 — 2025-02-07
- 0.4.0-beta.0 — 2025-01-28
- 0.3.1 — 2025-01-09
- 0.3.0 — 2024-12-03
- 0.3.0-beta.0 — 2024-11-28
- 0.2.0 — 2024-10-18
- 0.2.0-beta.1 — 2024-10-10
- 0.2.0-beta.0 — 2024-10-09
- 0.1.0 — 2024-08-16
- 0.1.0-beta.2 — 2024-08-08
- 0.1.0-beta.1 — 2024-08-08
- 0.1.0-beta.0 — 2024-07-29
- … 8 more at https://npm.io/package/@ton-api/ton-adapter/versions

## README

# @ton-api/ton-adapter

## Overview

`@ton-api/ton-adapter` is an adapter that enables integration between
[TonApi client](https://www.npmjs.com/package/@ton-api/client) and the
[@ton/ton](https://www.npmjs.com/package/@ton/ton) and
[@ton/core](https://www.npmjs.com/package/@ton/core) libraries. This adapter allows developers to
use TonApi's functionality while maintaining compatibility with existing TON blockchain development
tools.

## Features

-   Integration with `@ton-api/client`
-   Compatibility with `@ton/ton` and `@ton/core` contract wrappers
-   Eliminates the need for additional RPC providers
-   Facilitates blockchain interactions through TonApi

## Installation

Install the package and its peer dependency using npm, yarn, or pnpm:

```sh
npm install @ton-api/client @ton-api/ton-adapter
# or
yarn add @ton-api/client @ton-api/ton-adapter
# or
pnpm add @ton-api/client @ton-api/ton-adapter
```

## Quick Start

Here's a basic example to get you started:

```typescript
import { SendMode, WalletContractV5R1, internal } from '@ton/ton';
import { mnemonicNew, mnemonicToPrivateKey } from '@ton/crypto';
import { TonApiClient } from '@ton-api/client';
import { ContractAdapter } from '@ton-api/ton-adapter';

// Initialize TonApi client
const ta = new TonApiClient({
    baseUrl: 'https://tonapi.io',
    apiKey: 'YOUR_API_KEY'
});

// Create an adapter
const adapter = new ContractAdapter(ta);

// Create and use a wallet contract
async function main() {
    const mnemonics = await mnemonicNew();
    const keyPair = await mnemonicToPrivateKey(mnemonics);
    const wallet = WalletContractV5R1.create({ workchain: 0, publicKey: keyPair.publicKey });

    // Open the contract using the adapter
    const contract = adapter.open(wallet);

    // Get balance
    const balance = await contract.getBalance();
    console.log('Balance:', balance.toString());

    // Send a transfer
    const seqno = await contract.getSeqno();
    await contract.sendTransfer({
        seqno,
        secretKey: keyPair.secretKey,
        sendMode: SendMode.PAY_GAS_SEPARATELY + SendMode.IGNORE_ERRORS,
        messages: [
            internal({
                value: '0.001',
                to: 'EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N',
                body: 'Hello world'
            })
        ]
    });
}

main().catch(console.error);
```

## Usage

1. Create a TonApi client.
2. Initialize the `ContractAdapter` with the TonApi client.
3. Use the `open` method of the adapter to work with any @ton/ton or @ton/core compatible smart
   contract wrapper.
4. Interact with the contract as you would normally, but now using TonApi under the hood.

## License

MIT

---
_Source: https://npm.io/package/@ton-api/ton-adapter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
