Build your first application on the TON blockchain from scratch and explore its fundamentals—speed, reliability, and the core concepts of asynchronous thinking.
Beginner-Friendly Guide
If you're new to programming, this guide is the perfect starting point.
This learning path consists of 5 modules and takes approximately 45 minutes.
🛳 What You’ll Learn
In this tutorial, you’ll learn how to perform blockchain transactions effortlessly using JavaScript. While you could learn without completing this guide, this method is both convenient and beginner-friendly.
- Create a TON Wallet – Use Tonkeeper to set up your own wallet.
- Fund Your Wallet – Use a Testnet faucet to receive test tokens.
- Understand Smart Contracts – Learn key TON concepts (Addresses, Cells).
- Interact with TON – Use the TypeScript SDK and API providers.
- Compile Your First Transaction – Deploy an NFT Miner console application.
You're about to mine an NFT rocket achievement!
As one of TON’s first miners, you’ll use a Proof-of-Work smart contract to uncover secret rewards for your TON wallet.
Our goal? Mine an NFT! This achievement will remain with you _forever_.
Even on the mainnet, mining this NFT costs just 0.05 TON!
Mining on the TON Blockchain
Today, we’ll teach aspiring builders how to mine on the TON blockchain. This experience will help you understand mining’s significance and how Bitcoin mining revolutionized the industry.
The PoW Giver smart contract framework laid the groundwork for TON’s initial mining phase. Although the framework was finalized upon release, the last TON was mined in June 2022, concluding TON’s Proof-of-Work (PoW) token distribution. Now, TON has transitioned to Proof-of-Stake (PoS).
👉 Explore TON’s Economic Model & Mining
Now, let's focus on becoming a TON developer and learning how to mine NFTs!
🦄 Getting Started
To begin, developers will need the following:
- Wallet – A non-custodial wallet (Tonkeeper in Testnet mode).
- Repository – A pre-built template for your miner.
- Development Environment – Choose between local or cloud-based setups.
Download & Create a Wallet
First, you need a wallet to receive and store TON. Here’s how:
- Install Tonkeeper on your smartphone (Download here).
- Enable Testnet mode (Follow this guide).
Now, let’s start developing!
Project Setup
To simplify development, we’ll use a template:
- Log in to GitHub.
- Use the ton-onboarding-challenge template to create your repository (Click "Use this template").
Congrats! You now have a high-performance repository serving as your miner’s core.
Development Environment
Choose between local or cloud-based development:
Cloud Codespace
- Click Code → Create codespace on master in your GitHub repository.
- GitHub will launch a cloud workspace with VSCode Online IDE (no local installations needed).
Local Development
Requires:
Clone the repository and open it in your IDE.
Running Scripts
Execute TypeScript scripts via the terminal:
npm run start:script 🎯 Connecting to TON
To interact with the TON blockchain, you’ll need:
- Smart Contract Address – For mining (NFT collection address).
- API Provider – Use toncenter.com API (Testnet).
- JavaScript SDK – Parse addresses and prepare API requests (
@ton/ton).
Smart Contract Address
- Wallet Address – Your Tonkeeper Testnet wallet.
- Collection Address – The NFT mining smart contract (Getgems).
Parsing Addresses
Use Address.parse() to convert addresses:
const walletAddress = Address.parse('YOUR_WALLET_ADDRESS');
const collectionAddress = Address.parse('COLLECTION_ADDRESS'); Connecting to an API Provider
Use the TONCenter API (https://testnet.toncenter.com/api/v2/jsonRPC):
const client = new TonClient({ endpoint: "https://testnet.toncenter.com/api/v2/jsonRPC" }); Retrieving Mining Data
Run get_mining_data to fetch mining parameters:
const miningData = await client.runMethod(collectionAddress, 'get_mining_data'); The response includes:
complexity(PoW difficulty)lastSuccess(Unix timestamp)seed(Unique hash value)
🛠 Building an NFT Miner
Preparing the Mining Message
Follow the Proof-of-Work Cell layout:
const mineParams: MineMessageParams = {
expire: unixNow() + 300, // 5-min expiry
mintTo: walletAddress,
data1: 0n, // Incremented during mining
seed
};
let msg = Queries.mine(mineParams); Mining Process
Find a hash lower than complexity:
while (bufferToBigInt(msg.hash()) > complexity) {
mineParams.data1 += 1n;
msg = Queries.mine(mineParams);
} Sending the Transaction
Use Blueprint to send the transaction:
await provider.sender().send({
to: collectionAddress,
value: toNano(0.05), // 0.05 TON
body: msg
}); Run the script:
npm start Scan the QR code with Tonkeeper and confirm the transaction.
⛏ Mining Your NFT
Testnet Mining
- Enable Testnet mode in Tonkeeper.
- Replace
walletAddressandcollectionAddresswith Testnet values. - Run the miner (
npm start).
Mainnet Mining
- Use Mainnet mode in Tonkeeper.
- Update
endpointtohttps://toncenter.com/api/v2/jsonRPC. - Replace addresses with Mainnet equivalents.
🧙 What’s Next?
Explore further:
Got feedback? Contact @SwiftAdviser. Happy building! 🚀