Start Building on TON | The Open Network

·

The Open Network (TON) is redefining the blockchain landscape with its high-speed transactions, robust infrastructure, and developer-friendly ecosystem. Whether you're new to programming or an experienced coder, this step-by-step guide will help you build your first application on TON—mining an NFT as a developer achievement. In about 45 minutes, you’ll learn the fundamentals of blockchain interaction using JavaScript and TypeScript, explore smart contracts, and execute your first transaction.

This hands-on tutorial is structured into five core modules, optimized for clarity and engagement. By the end, you’ll not only have mined your own NFT but also gained foundational skills applicable to building decentralized applications (dApps) on TON.


What You’ll Learn

In this beginner-friendly walkthrough, you'll gain practical experience in real-world blockchain development without needing prior expertise. Here's what we'll cover:

  1. Create a TON Wallet using Tonkeeper and enable testnet mode
  2. Fund your wallet via a testnet faucet for free testing tokens
  3. Understand key TON concepts like addresses, cells, and smart contracts
  4. Interact with the TON blockchain using the @ton/ton SDK and TON Center API
  5. Compile and send your first transaction to mine an NFT

👉 Get started with tools that power modern blockchain development today.

By the end of this journey, you’ll have permanently minted an NFT achievement on the TON blockchain—a symbolic milestone marking your entry into the world of decentralized innovation.

Even better? Mining this NFT on the mainnet costs just 0.05 TON, making it one of the most accessible onboarding experiences in Web3.


Understanding Mining on TON

While TON has transitioned from Proof-of-Work (PoW) to Proof-of-Stake (PoS) consensus, the concept of "mining" remains a powerful educational tool for developers. Originally, PoW Giver smart contracts allowed early contributors to mine TON tokens through computational work. Though that era ended in June 2022, the framework lives on as a way to introduce developers to core blockchain mechanics.

Today, we repurpose this system to mine an NFT achievement, simulating real mining logic while teaching you how transactions are validated, hashed, and confirmed on-chain.

This exercise mirrors Bitcoin’s original mining principles—proving work through cryptographic puzzles—but applies it to a modern, scalable blockchain environment. It's not just symbolic; it's foundational knowledge.

💡 Core Keywords: TON blockchain, NFT mining, smart contracts, JavaScript SDK, TON wallet, blockchain development, testnet faucet, API provider

Getting Started: Tools & Setup

To begin building on TON, every developer needs three essential components:

Let’s walk through each setup step.

Download and Set Up Your Wallet

You’ll need a secure wallet to receive and store your mined NFT. We recommend Tonkeeper, a mobile-first, non-custodial wallet compatible with both testnet and mainnet.

Here’s how to set it up:

  1. Install the Tonkeeper app on your smartphone
  2. Enable Testnet Mode within the app settings

Once enabled, your wallet can receive test tokens used for development and transaction simulation.

With your wallet ready, you’re one step closer to interacting with the TON blockchain.


Project Initialization Using GitHub Template

To skip boilerplate setup, we’ll use a ready-made template: ton-on-boarding-challenge.

🔐 You must be logged into GitHub to proceed.

Click “Use this template” > “Create a new repository” to generate your personal copy. This repository includes:

Congratulations—you now have a fully functional development base!


Choose Your Development Environment

You can develop locally or in the cloud. Both are supported.

Cloud Development (Recommended for Beginners)

Using GitHub Codespaces gives you instant access to a VSCode-powered online IDE—no installation required.

Steps:

  1. Go to your forked repository
  2. Click the Code tab > Create codespace on main

GitHub spins up a cloud workspace with Node.js, Git, and npm pre-installed. You’re ready to code immediately.

Local Development (For Advanced Users)

If you prefer working offline, install these tools:

Then clone your repo and open it in your IDE.

Regardless of environment, all commands run via the terminal—usually found at the bottom of your editor window.


Connecting to the TON Blockchain

Now that your environment is ready, let’s connect to TON using three key elements:

  1. Smart Contract Address – where your NFT will be minted
  2. API Provider – to query blockchain data
  3. JavaScript SDK – to parse and send transactions

We’ll use:

Adding Smart Contract Addresses

Open ./scripts/mine.ts and define two addresses:

import { Address } from '@ton/ton';

const walletAddress = Address.parse('YOUR_WALLET_ADDRESS');
const collectionAddress = Address.parse('COLLECTION_ADDRESS');

These addresses represent:

👉 Discover how leading developers streamline their workflow with integrated tools.


Initialize API Connection

Add the client configuration:

import { TonClient } from '@ton/ton';

const endpoint = "https://testnet.toncenter.com/api/v2/jsonRPC";
const client = new TonClient({ endpoint });

This connects your script directly to the TON testnet via JSON-RPC.


Retrieve Mining Data from Blockchain

Call the get_mining_data method on the smart contract:

const miningData = await client.runMethod(collectionAddress, 'get_mining_data');
console.log(miningData.stack);

This returns a tuple containing:

{
  complexity,
  lastSuccess,
  seed,
  targetDelta,
  minCpl,
  maxCpl
}

Convert them into readable values:

const { stack } = miningData;
const complexity = stack.readBigNumber();
const lastSuccess = stack.readBigNumber();
const seed = stack.readBigNumber();

Key Parameters Explained

ParameterPurpose
complexityTarget threshold: your hash must be lower than this
lastSuccessUnix timestamp of last successful mine
seedUnique value used in hash calculation

Understanding these values is crucial—they determine whether your mining attempt succeeds.


Building Your NFT Miner

Now comes the fun part: creating a miner that finds a valid hash below the complexity threshold.

Prepare the Mining Message

Use the MineMessageParams interface to structure your transaction:

import { unixNow } from '../lib/utils';
import { MineMessageParams, Queries } from '../wrappers/NftGiver';

const mineParams: MineMessageParams = {
  expire: unixNow() + 300,
  mintTo: walletAddress,
  data1: 0n,
  seed: seed
};

let msg = Queries.mine(mineParams);

This builds a transaction cell—a fundamental data unit in TON used for storing and transmitting information.

🧠 What is a Cell?
Cells are TON’s native data structures, enabling efficient storage and execution across the blockchain. They underpin smart contracts, messages, and state transitions.

Implement the Mining Loop

Keep incrementing data1 until the message hash is less than complexity:

const bufferToBigint = (buffer: Buffer) => BigInt('0x' + buffer.toString('hex'));

while (bufferToBigint(msg.hash()) > complexity) {
  mineParams.expire = unixNow() + 300;
  mineParams.data1 += 1n;
  msg = Queries.mine(mineParams);
}

console.log('✅ Found valid hash!');

This loop simulates proof-of-work: brute-forcing until a solution is found.


Enhance User Experience

Improve output readability during mining:

let progress = 0;
while (...) {
  console.clear();
  console.log(`⛏ Mined ${++progress} hashes!`);
  console.log(`Last hash: ${bufferToBigint(msg.hash())}`);
  // ... update params
}

You’ll see live feedback showing progress—a satisfying visual cue that your miner is working.


Finalizing and Sending the Transaction

Once a valid hash is found, it’s time to send the transaction via your wallet.

Fund Your Wallet Using Testnet Faucet

Get free test tokens from the TON Testnet Faucet Bot to cover gas fees.

Then integrate Blueprint for seamless wallet connection:

import { NetworkProvider } from '@ton/blueprint';

export async function run(provider: NetworkProvider) {
  const msg = await mine();

  await provider.sender().send({
    to: collectionAddress,
    value: toNano(0.05),
    body: msg
  });
}

Run with npm start, not npm run start:script—this enables wallet interaction.

Follow prompts:

  1. Select testnet
  2. Choose Tonkeeper
  3. Scan QR code with your mobile wallet
  4. Confirm transaction

Mine Your NFT: Testnet vs Mainnet

On Testnet (Free Practice)

Steps:

  1. Enable testnet in Tonkeeper
  2. Use testnet wallet address
  3. Set collection address to testnet version
  4. Run miner → scan QR → confirm

Perfect for learning with zero cost.

On Mainnet (Real Achievement)

Steps:

  1. Switch Tonkeeper to mainnet
  2. Ensure balance ≥ 0.1 TON
  3. Update wallet and collection addresses
  4. Change endpoint:
const endpoint = "https://toncenter.com/api/v2/jsonRPC";

Cost: Only 0.05 TON per attempt.

Due to competition, you may need multiple tries—others might claim the next NFT first.

Eventually, your NFT appears in Tonkeeper: permanent proof of your developer status.

Welcome, true TON developer! 🚀


Frequently Asked Questions

Q: Is NFT mining on TON real or just symbolic?

A: It's both educational and real. While not earning tokens like classic PoW, you're executing genuine blockchain transactions and earning a verifiable NFT achievement stored permanently on-chain.

Q: Do I need prior coding experience?

A: No! This guide is designed for beginners. Basic familiarity with code editors and command lines helps, but all steps are explained clearly.

Q: Can I mine more than one NFT?

A: Yes—though each requires a new transaction and small fee (0.05 TON). However, only one "first miner" achievement exists per user.

Q: Why use Tonkeeper?

A: Tonkeeper is officially supported, secure, easy to use, and integrates seamlessly with Telegram and dApps across TON.

Q: What happens if my hash never goes below complexity?

A: The script auto-refreshes expiration and retries. As long as seed hasn’t changed, it continues searching—eventually succeeding.

Q: How fast are TON transactions?

A: Typically confirmed in under 2 seconds, thanks to TON’s sharding architecture and optimized consensus model.


What’s Next?

Take a moment—you’ve just completed a major milestone in Web3 development. But this is only the beginning.

Explore further:

The ecosystem is growing fast—and now you’re part of it.

👉 Accelerate your journey with platforms trusted by top blockchain builders.