Jetton-with-governance FunC smart contracts.
This project was created to allow users to exchange and buy assets in the TON DeFi ecosystem for a jetton (token or currency) that is not subject to volatile fluctuations. To meet regulatory requirements, the issuer of the tokens must have additional control over the tokens.
Thus this jetton represents a standard TON jetton smart contracts with additional functionality:
-
Admin of jetton can make transfers from user's jetton wallet.
-
Admin of jetton can burn user's jettons.
-
Admin of jetton can lock/unlock user's jetton wallet (
set_status
). Admin can make transfer and burn even if wallet locked. -
Admin of jetton can change jetton-minter code and it's full data.
upgrade
message, so it is possible to brick the contract if you send invalid data or code. Therefore you should always check the upgrade in the testnet.
npm install
npm run build
npm run test
npx blueprint run
or yarn blueprint run
use Toncenter API:
npx blueprint run --custom https://testnet.toncenter.com/api/v2/ --custom-version v2 --custom-type testnet --custom-key <API_KEY>
API_KEY can be obtained on https://toncenter.com or https://testnet.toncenter.com
⚠️ Important notice: The jetton wallet in this project makes use of library cell for code storage. And execution guarantee is ONLY valid if wallet is deployed as library. If deployed otherwise, execution guarantee is a matter of current network configuration.
Library deployment reduces the cont of the wallet storage and deployment stage, as the code cell in StateInit is represented by it's hash instead of full content.
However, certain conditions must be satisfied for this to work:
- The library has to be deployed on the network.
- Jetton minter must have wallet code as a library cell to utilize it.
The library for the current code is deployed by the TON Core team and would last for 100 year of storage.
This means that if no modifications applied to the current code, developers can utilize publicly available library without needing to deploy a new one.
If ANY changes are made to the jetton-wallet code, or source files it includes developer has two options:
- Deploy a new library to the network
- Re-calculate gas constants for usage without library cell
In order to deploy a library to the network, librarian contract is used along with deployLibrary script.
The current default library storage duration is set to 100 years and would cost roughly about 1200 TON depending on the resulting code size.
Developers are free to change the duration directly in the librarian contract, however, it is crucial to understand the implications of library expiry.
If library cell storage expires, the wallet code becomes inaccessible, meaning wallets will not be able to process any further transactions. Therefore, it is the developer responsibility to deploy the library for a reasonable time period and monitor it's expiration date.
To extend the library storage, top-up the previous librarian address or repeat the library deployment procedure.
In current repository setup minter is deployed with library wallet code automatically by the deployMinter script. However, some developers may use the contract code in a different environment, so it's important to ensure that the minter wallet code configuration is valid.
Process of deploying minter with wallet code as library is fairly straightforward:
- Get library cell from the ordinary code cell
- Pass it as a wallet code to your minter constructor
- Deploy the minter
For the first step, refer this
chapter of documentation, which illustrates how to accomplish this
using @ton/ton
or Fift language.
Use the provided examples to adapt it to the environment of choice.
In order to determine if library has been deployed successfully:
- Find your librarian contract address in the explorer of choice
- Check that account status is active and balance is positive. If deployment failed, contract should return all incoming value to the sender
- Check that account code and data are set empty cell
x{}
or96a296d224f285c67bee93c30f8a309157f0daa35dc5b87e410b78630a09cfc7
in hash view - Take your RAW code hash, and pass it in upper case to get_lib
get_lib
result should be non-empty
⚠️ Important notice Before performing any token mint, it is highly recommended to perform wallet code check right after the minter deployment, regardless of the deployment environment
In order to do so, run
npx blueprint run checkWalletLib
Please refer to DEVELOPMENT.md for the information on gas constats.
-
The jetton-wallet contract does not include functionality that allows the owner to withdraw Toncoin funds from jetton-wallet Toncoin balance.
-
The contract prices gas based on the current blockchain configuration. It is worth keeping in mind the situation when the configuration has changed at the moment when the message goes from one jetton-wallet to another. Reducing fees in a blockchain configuration does not require additional actions. However, increasing fees in a blockchain configuration requires preliminary preparation - e.g. wallets and services must start sending Toncoins for gas in advance based on future parameters.
-
If you set the status of Jetton Wallet to prohibit receiving jettons - there is no guarantee that when you send jettons to such a jetton-wallet, jettons will bounce back and be credited to the sender. In case of gas shortage they can be lost. Toncoin for gas and forward will also not be returned to the sender but will remain on the sender’s jetton-wallet.
The stablecoin contract has been created by TON Core team and audited by security companies:
- Trail of Bits: Audit Report
Feel free to review these reports for a detailed understanding of the contract's security measures.