# How to interact with preprocessed wallet v2 (https://docs-i0yym09dy-ton-core-docs.vercel.app/llms/standard/wallets/preprocessed-v2/interact/content.md)



<Callout type="caution" title="Community implementation">
  This wallet is a community-created implementation. Use at your own risk. Always test thoroughly on testnet before using with real funds.

  * Code hash: `45ebbce9b5d235886cb6bfe1c3ad93b708de058244892365c9ee0dfe439cb7b5`
  * Source: [`pw-code.fif` on GitHub](https://github.com/pyAndr3w/ton-preprocessed-wallet-v2/blob/d95a25ef7e259c27a07e185296b57335c2b4974b/pw-code.fif)
</Callout>

<Callout type="danger" title="Funds at risk">
  This guide sends real TON. Test on testnet first. Double-check recipient addresses — blockchain transactions cannot be reversed.
</Callout>

This guide shows how to deploy Preprocessed Wallet V2 and send transfers.

<Callout type="tip">
  For technical details, see [Preprocessed Wallet V2 specification](/llms/standard/wallets/preprocessed-v2/specification/content.md).
</Callout>

## Objective [#objective]

By the end of this guide, you will:

* Create a Preprocessed Wallet V2 instance from scratch
* Deploy the wallet on-chain
* Send single and batch transfers

## Prerequisites [#prerequisites]

* Node.js 18+ or TypeScript environment
* `@ton/ton`, `@ton/core`, `@ton/crypto` packages installed
* Preprocessed Wallet V2 wrapper and compiled contract code

This guide uses TypeScript with the official wrapper. The same logic applies to other SDKs (Go/Python): generate or load a mnemonic, derive a keypair, and calculate the address.

## Step 1: Set up dependencies [#step-1-set-up-dependencies]

Install required packages:

```bash
npm install @ton/ton @ton/core @ton/crypto
```

Copy the wrapper and contract code from the [official repository](https://github.com/pyAndr3w/ton-preprocessed-wallet-v2):

```bash
# Clone the repository or download this file:
# - typescript/wrappers/PreprocessedWalletV2.ts
```

<Callout type="note" title="Why copy wrappers?">
  The official `@ton/ton` SDK does not include Preprocessed Wallet V2 wrappers yet. Copy `PreprocessedWalletV2.ts` from the repository until SDK support is added.
</Callout>

## Step 2: Generate or load a mnemonic [#step-2-generate-or-load-a-mnemonic]

A mnemonic is your wallet's master secret. It derives the private key used to sign all transactions.

### Generate a new mnemonic [#generate-a-new-mnemonic]

```typescript
import { mnemonicNew } from '@ton/crypto';

const mnemonic = await mnemonicNew(24); // Array of 24 words
```

### Load an existing mnemonic [#load-an-existing-mnemonic]

```typescript
const mnemonic = 'word1 word2 word3 ... word24'.split(' ');
```

<Callout type="danger" title="Protect your mnemonic">
  Anyone with access to your mnemonic can control your wallet and all funds. Store it securely (password manager, hardware wallet, encrypted storage). Never commit it to version control.
</Callout>

## Step 3: Derive the keypair [#step-3-derive-the-keypair]

Convert the mnemonic to an Ed25519 keypair:

```typescript
import { mnemonicToPrivateKey } from '@ton/crypto';

const keyPair = await mnemonicToPrivateKey(mnemonic);
// keyPair.publicKey  — used in contract state
// keyPair.secretKey  — used to sign external messages
```

## Step 4: Create the wallet instance [#step-4-create-the-wallet-instance]

Create a Preprocessed Wallet V2 contract instance:

```typescript
import { TonClient } from '@ton/ton';
import { Cell } from '@ton/core';
import { Wallet, walletCode } from './wrappers/PreprocessedWalletV2';

// Compiled contract code (BoC)
const CODE = walletCode; // Already included in the wrapper

const client = new TonClient({
    endpoint: 'https://testnet.toncenter.com/api/v2/jsonRPC', // This is TESTNET endpoint
    // apiKey: 'your-api-key' // Optional: get from @tonapibot or @tontestnetapibot
});

const wallet = client.open(
    Wallet.createFromPublicKey(keyPair.publicKey)
);
```

## Step 5: Get the wallet address [#step-5-get-the-wallet-address]

Calculate the wallet's address:

```typescript
// Get non-bounceable address for funding
const address = wallet.address.toString({ bounceable: false, testOnly: true });
console.log('Wallet address:', address);
// Example (truncated): 0Q... (non-bounceable, testnet)
```

This address is deterministic: it depends only on `CODE` and `publicKey`. The same parameters always produce the same address.

<Callout type="tip" title="Why non-bounceable?">
  When funding a `nonexist` account, use the non-bounceable format to prevent funds from bouncing back if the account doesn't exist yet. See [Address formats](/llms/foundations/addresses/formats/content.md) for details.
</Callout>

**Account status: [`nonexist`](/llms/foundations/status/content.md)**

The calculated address exists only as a deterministic value. No account exists on the blockchain yet — no balance, no code, no data.

***

## Step 6: Fund the wallet [#step-6-fund-the-wallet]

<Callout type="danger" title="Funds at risk">
  You will send TON to this address. Test on testnet first. Verify the wallet address carefully — blockchain transactions cannot be reversed.
</Callout>

**Required before deployment:** Send TON to your wallet address (from Step 5) to prepare it for deployment.

External messages (which deploy the wallet) require gas to execute. By funding the address, you transition the account from `nonexist` to `uninit` status and provide the balance needed for deployment. See [Account statuses](/llms/foundations/status/content.md) for details on how account states work.

Send TON using a faucet (testnet) or from another wallet (mainnet). After funding, the account transitions to `uninit` status — it has a balance and can accept external messages, but no code or data yet.

***

## Step 7: Send messages [#step-7-send-messages]

<Callout type="note" title="Automatic deployment">
  The wallet will auto-deploy on the first external message. No separate deployment step is needed.
</Callout>

### Send single transfers [#send-single-transfers]

```typescript
import { Address, toNano } from '@ton/ton';
import { beginCell } from '@ton/core';

// Get current sequence number
const currentSeqno = Number(await wallet.getSeqno());

// Send a single transfer
await wallet.sendTransfers(keyPair, [{
    to: Address.parse('EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c'), // Zero address for testing
    value: toNano('0.01'),
    bounce: false
}], currentSeqno);

console.log('Transfer sent');
```

### Send batch transfers [#send-batch-transfers]

```typescript
import { Address, toNano, comment } from '@ton/ton';

// Get current sequence number
const currentSeqno = Number(await wallet.getSeqno());

// Create multiple transfers with similar structure
const transfers = [];
for (let i = 0; i < 5; i++) {
    transfers.push({
        to: Address.parse('EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c'),
        value: toNano('0.01'),
        body: comment(`#${i}`)
    });
}

// Send batch transfers
await wallet.sendTransfers(keyPair, transfers, currentSeqno);

console.log('Batch transfers sent');
```

<Callout type="note" title="Maximum actions">
  reprocessed Wallet V2 supports up to 255 actions per transaction. This is the maximum number of out actions supported by TON blockchain.
</Callout>
