TLDR:
In this tutorial, we will explore how to customize the standard implementation of Jetton tokens on TON. We will guide you through the update process using the Blueprint environment and Sandbox. Specifically, we will introduce a capped supply and a mint price per token to our minter contract. Users will be able to mint tokens at the preset price until the capped supply is reached.
Start for free and get your app to production levels immediately. No credit card required. You can sign up with your GitHub, X, Google, or Microsoft account.
Let’s briefly recap what we know about fungible tokens on TON. TON fungible tokens are called Jettons. The Jetton standard is detailed in TEP74, while the specification for token metadata is outlined in TEP64. The Jetton standard (TEP74) covers:
An example of the Jetton minter and wallet contracts has been prepared by the TON core team. We will take these contracts as a starting point for our development.
Source: How to shard your TON smart contract and why - studying the anatomy of TON’s Jettons.
Clone the project from the previous tutorial into your current folder:
Next, update the blueprint.config.ts
file with your Chainstack endpoint. For this tutorial, we will use the testnet:
To ensure the contracts are set up properly, compile and run the tests using the following commands:
In this section, we will update the minter contract to include a capped supply and token price functionality.
Adding capped supply and price fields
In the contract storage, we will add two new fields, capped_supply
and price
. Here is the updated load_data
and save_data
functions:
Updating function calls
Since we have updated the mentioned functions, we now need to update their calls with the respective parameters. Here is an example of the updated getters:
Enforcing capped supply and token price in minting
To prevent minting more than the capped supply and ensure that the correct price is applied, we need to modify the recv_internal
function. We will:
Please note that we need to calculate the buy amount to reserve some TON for storage in the Jetton wallet contract.
Note that in this tutorial, we will only work with the Jetton Minter wrapper.
Next, we will update the wrapper to include the new capped supply and token price functionality. The wrapper will provide functions to retrieve and manipulate these fields.
Updating minter config
We need to update the configuration type in JettonMinter.ts
to include the new fields capped_supply
and price
.
Updating minting message
In this version, we are packing the jetton minting message within the minter contract itself. This means that our interface now composes a simple message containing the TON amount and the recipient’s address.
Updating getters
As we added new propertes, the getters also must be updated. Note that we modified getJettonData
and added getTokenPrice
.
We will add test cases to verify that the capped supply and token price functionality work as expected.
Testing minting within capped supply
This test verifies jetton minting based on the TON sent, ensuring the correct jetton amount is minted and updates both user balance and total supply accordingly.
Testing minting above capped supply
This test checks that minting beyond the capped supply fails, verifying that the transaction is aborted with the correct exit code.
To test the contracts using Sandbox, run the command:
In the scripts
folder, updatedeployJettonMinter.ts
with the capped_supply
and price
properties:
The metadata JSON must have the following format with the image data having base64-encoded value:
To deploy the contracts to the testnet, run the command:
We walked through the customization of the Jetton token standard on TON, focusing on key update steps using Blueprint and Sandbox. The process involved updating the minter contract, its wrapper, and the associated tests.
Developer Advocate @ Chainstack
Multiple years of software development and Web3 expertise. Creator of the open-source Compare Dashboard for RPC provider performance benchmarking. Core contributor to the DevEx team’s pump.fun trading bot. Author of technical tutorials on EVM blockchains, Solana, TON and Subgraphs.
TLDR:
In this tutorial, we will explore how to customize the standard implementation of Jetton tokens on TON. We will guide you through the update process using the Blueprint environment and Sandbox. Specifically, we will introduce a capped supply and a mint price per token to our minter contract. Users will be able to mint tokens at the preset price until the capped supply is reached.
Start for free and get your app to production levels immediately. No credit card required. You can sign up with your GitHub, X, Google, or Microsoft account.
Let’s briefly recap what we know about fungible tokens on TON. TON fungible tokens are called Jettons. The Jetton standard is detailed in TEP74, while the specification for token metadata is outlined in TEP64. The Jetton standard (TEP74) covers:
An example of the Jetton minter and wallet contracts has been prepared by the TON core team. We will take these contracts as a starting point for our development.
Source: How to shard your TON smart contract and why - studying the anatomy of TON’s Jettons.
Clone the project from the previous tutorial into your current folder:
Next, update the blueprint.config.ts
file with your Chainstack endpoint. For this tutorial, we will use the testnet:
To ensure the contracts are set up properly, compile and run the tests using the following commands:
In this section, we will update the minter contract to include a capped supply and token price functionality.
Adding capped supply and price fields
In the contract storage, we will add two new fields, capped_supply
and price
. Here is the updated load_data
and save_data
functions:
Updating function calls
Since we have updated the mentioned functions, we now need to update their calls with the respective parameters. Here is an example of the updated getters:
Enforcing capped supply and token price in minting
To prevent minting more than the capped supply and ensure that the correct price is applied, we need to modify the recv_internal
function. We will:
Please note that we need to calculate the buy amount to reserve some TON for storage in the Jetton wallet contract.
Note that in this tutorial, we will only work with the Jetton Minter wrapper.
Next, we will update the wrapper to include the new capped supply and token price functionality. The wrapper will provide functions to retrieve and manipulate these fields.
Updating minter config
We need to update the configuration type in JettonMinter.ts
to include the new fields capped_supply
and price
.
Updating minting message
In this version, we are packing the jetton minting message within the minter contract itself. This means that our interface now composes a simple message containing the TON amount and the recipient’s address.
Updating getters
As we added new propertes, the getters also must be updated. Note that we modified getJettonData
and added getTokenPrice
.
We will add test cases to verify that the capped supply and token price functionality work as expected.
Testing minting within capped supply
This test verifies jetton minting based on the TON sent, ensuring the correct jetton amount is minted and updates both user balance and total supply accordingly.
Testing minting above capped supply
This test checks that minting beyond the capped supply fails, verifying that the transaction is aborted with the correct exit code.
To test the contracts using Sandbox, run the command:
In the scripts
folder, updatedeployJettonMinter.ts
with the capped_supply
and price
properties:
The metadata JSON must have the following format with the image data having base64-encoded value:
To deploy the contracts to the testnet, run the command:
We walked through the customization of the Jetton token standard on TON, focusing on key update steps using Blueprint and Sandbox. The process involved updating the minter contract, its wrapper, and the associated tests.
Developer Advocate @ Chainstack
Multiple years of software development and Web3 expertise. Creator of the open-source Compare Dashboard for RPC provider performance benchmarking. Core contributor to the DevEx team’s pump.fun trading bot. Author of technical tutorials on EVM blockchains, Solana, TON and Subgraphs.