# ton-emulator

> Emulation toolkit for TON Smart Contracts

Latest version **2.1.1** (published 2023-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install ton-emulator
pnpm add ton-emulator
yarn add ton-emulator
bun add ton-emulator
```

## Health

**Score 25/100 (F)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2023-02-02 |
| First published | 2022-12-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 5.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Steve Korshakov |
| Maintainers | steve.kite |

## Links

- npm: https://www.npmjs.com/package/ton-emulator
- Repository: https://github.com/ton-core/ton-emulator
- Homepage: https://github.com/ton-core/ton-emulator#readme
- Issues: https://github.com/ton-core/ton-emulator/issues
- npm.io page: https://npm.io/package/ton-emulator

## Dependencies (3)

- [zod](https://npm.io/package/zod.md) ^3.20.2
- [prando](https://npm.io/package/prando.md) ^6.0.1
- [teslabot](https://npm.io/package/teslabot.md) ^1.5.0

## Recent versions

- 2.1.1 (latest) — 2023-02-02
- 2.1.0 — 2023-02-02
- 2.0.0 — 2023-02-02
- 1.6.1 — 2023-01-26
- 1.6.0 — 2023-01-11
- 1.5.0 — 2023-01-11
- 1.4.0 — 2023-01-08
- 1.3.0 — 2023-01-04
- 1.2.0 — 2023-01-03
- 1.1.1 — 2023-01-02
- 1.1.0 — 2023-01-02
- 1.0.1 — 2023-01-01
- 1.0.0 — 2022-12-30

## README

# TON Emulator

Emulation toolkit for TON Smart Contracts

## Installation

```bash
yarn add ton-emulator ton-core ton-crypto
```

## Usage

```typescript
import { ContractSystem } from 'ton-emulator';

// Contract System is a virtual environment that emulates the TON blockchain
const system = await ContractSystem.create();

// Treasure is a contract that has 1m of TONs and is a handy entry point for your smart contracts
let treasure = await system.treasure('my-treasure');

// Track contract transactions and events
let tracker = system.track(treasure.address);

// Logger to collect VM logs from a contract
let logger = system.log(treasure.address);

// Create a random unknown address that would be treated as unititialized contract
let unknownAddress = testAddress('some-unknown-seed'); // This seed is used to generate deterministic address

// Send an empty message to the unknown address
await treasure.send({
    to: unknownAddress,
    bounce: true,
});

// Run a block
let transactions = await system.run();
console.warn(inspect(transactions, false, 10000));

// Open a contract
let wallet = system.open(WalletContractV4.create({ workchain: 0, publicKey: <some-test-key> }));

// Show contract logs
console.warn(logger.collect());

// Test events and transactions
expect(tracker.collect()).toMatchSnapshot();

```

## License

MIT

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