Start Building on TON | The Open Network

·

The Open Network (TON) is revolutionizing blockchain development with its high-speed transactions, scalable architecture, and developer-friendly tools. Whether you're new to programming or an experienced coder, this hands-on guide will walk you through creating your first application on TON—complete with wallet setup, smart contract interaction, and mining your very own NFT.

This beginner-friendly tutorial spans five core modules and takes approximately 45 minutes to complete. By the end, you'll not only understand the fundamentals of blockchain development but also earn a permanent NFT achievement as one of TON’s pioneering builders.


🛳 What You’ll Learn

In this step-by-step journey, you’ll discover how to interact with the TON blockchain using JavaScript and TypeScript. No prior blockchain experience? No problem. We’ll keep it simple, intuitive, and engaging.

Here’s what you’ll accomplish:

👉 Discover how easy it is to start building on TON today.

And yes—you’re going to mine an NFT rocket achievement! This digital collectible will be permanently tied to your wallet, even when minted on the mainnet—for just 0.05 TON.

While TON has transitioned from Proof-of-Work (PoW) to Proof-of-Stake (PoS), this NFT mining process simulates the original PoW mechanism as a fun, educational experience for developers.

🦄 Getting Started: Essential Tools

Before diving into code, every developer needs three foundational components:

  1. Wallet: A non-custodial wallet to store your testnet and mainnet assets
  2. Repository: A pre-built GitHub template to accelerate development
  3. Development Environment: Choose between cloud-based or local setup

Let’s break these down.

Download and Set Up Your Wallet

You’ll need a TON-compatible wallet that supports testnet mode. We recommend Tonkeeper, a secure and user-friendly mobile wallet.

Steps:

  1. Install the Tonkeeper app from your device’s app store
  2. Enable Testnet Mode in settings (refer to official docs)

Once configured, your wallet is ready to receive test tokens and confirm transactions.

Project Setup Using GitHub Template

To streamline development, we’ll use a ready-made template:
ton-on-boarding-challenge

How to Clone:

  1. Click "Use this template"
  2. Select "Create a new repository"
  3. Name your project and initialize it

You now have a fully structured codebase—your foundation for building the NFT miner.


💻 Choose Your Development Environment

You can develop either locally or in the cloud. Both are valid; choose based on your comfort level.

Option 1: Cloud Development (Recommended for Beginners)

Using GitHub Codespaces gives you instant access to a full development environment without installing anything.

Steps:

  1. Open your cloned repository
  2. Go to the Code tab
  3. Click "Create codespace on main"

GitHub spins up a VS Code-powered cloud workspace within seconds—preloaded with Node.js, Git, and all necessary tools.

Option 2: Local Development (For Advanced Users)

If you prefer working on your machine, ensure these tools are installed:

Then clone your repo:

git clone https://github.com/your-username/ton-onboarding-challenge.git

Open the folder in your IDE and install dependencies:

npm install

🎯 Connecting to the TON Blockchain

Now comes the exciting part: connecting your app to the live blockchain.

You’ll need three key elements:

  1. Smart Contract Address: The target where your NFT will be minted
  2. API Provider: To query blockchain data (we’ll use TON Center)
  3. JavaScript SDK: To parse addresses and build transactions (@ton/ton)

Step 1: Define Smart Contract Addresses

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

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

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

Step 2: Connect to API Provider

We’ll use TON Center’s Testnet API endpoint:

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

This allows your script to read data directly from the blockchain.

Step 3: Fetch 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:

We convert these values using readBigNumber() for accurate comparison:

const complexity = stack.readBigNumber();
const lastSuccess = stack.readBigNumber();
const seed = stack.readBigNumber();

👉 See real-time blockchain data in action—start querying TON now.


🛠 Building Your NFT Miner

Your miner’s job is simple: find a hash smaller than the given complexity.

Prepare the Mining Message

Use predefined parameters to construct the transaction body:

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

let msg = Queries.mine(mineParams);

Mine Until Success

Loop until a valid hash is found:

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

Add visual feedback for better UX:

console.clear();
console.log(`⛏ Mined ${++progress} hashes!`);

When complete, you’ll see:

💎 Mission completed: msg_hash less than pow_complexity found!

🎨 Send the Transaction via Wallet

Now it’s time to submit your mined result to the blockchain.

Fund Your Wallet

Get free test tokens from the TON Testnet Faucet.

Use Blueprint to Send Transaction

Update the run() function:

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

Run with:

npm start

Follow prompts to connect Tonkeeper via QR code and confirm the transaction.


⛏ Mine Your NFT: Testnet vs Mainnet

Testnet Mining (Free & Safe)

Perfect for learning:

  1. Use Testnet Mode in Tonkeeper
  2. Input testnet addresses
  3. Run miner → Scan QR → Confirm

Mainnet Mining (Real TON)

Ready for production?

  1. Switch Tonkeeper to Mainnet
  2. Use mainnet addresses
  3. Update endpoint:

    const endpoint = "https://toncenter.com/api/v2/jsonRPC";
  4. Pay 0.05 TON gas fee
Note: Due to competition, you may need multiple attempts.

🧙 What’s Next?

Congratulations—you’ve just become a TON developer!

Explore more:


❓ Frequently Asked Questions

Q: Do I need real TON coins to start?
A: No! Use testnet tokens for free during development.

Q: Can I lose money while testing?
A: Not on testnet. Only mainnet transactions involve real value.

Q: Is coding knowledge required?
A: Basic JavaScript helps, but beginners can follow along step-by-step.

Q: Will my NFT work on mainnet?
A: Yes! The same process applies—just switch networks and pay a small fee.

Q: Why does mining take 30–60 seconds?
A: The algorithm adjusts difficulty dynamically for educational pacing.

Q: Can I reuse this miner for other projects?
A: Absolutely! This pattern applies to many decentralized applications.


👉 Unlock advanced tools and resources for TON developers here.