From eafcb3044a0ea036b29f39578b6d7c505b4fcb30 Mon Sep 17 00:00:00 2001 From: b4cksl4sh Date: Mon, 2 Dec 2024 18:02:51 +0300 Subject: [PATCH 01/10] Added README.md --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d491c26..d4a5f7b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,66 @@ -# TACT template project +# TACT Jetton (Fungible Token) Implementation -This project has ready to use TACT compiler, typescript + jest with ton-contract-executor, example how to do tests. +## Overview -## Licence +This project includes a complete setup for working with TACT-based smart contracts for Jettons. It provides: -MIT \ No newline at end of file +- A preconfigured TACT compiler. +- Smart contracts written in the TACT language. +- TypeScript + Jest testing environment with `@ton/sandbox`. + +## Goals + +This implementation is fully compatible with the following TON standards: +- [TEP-64](https://github.com/ton-blockchain/TEPs/blob/master/text/0064-token-data-standard.md), +- [TEP-74](https://github.com/ton-blockchain/TEPs/blob/master/text/0074-jettons-standard.md), +- [TEP-89](https://github.com/ton-blockchain/TEPs/blob/master/text/0089-jetton-wallet-discovery.md). + +You can use this implementation as an alternative to the official Jetton contracts available in the [TON Blockchain repository](https://github.com/ton-blockchain/token-contract). + +## Getting Started + +### 1. Install Dependencies + +Run the following command to install all required dependencies: + +```bash +yarn install +``` + +### 2. Build Contracts + +Compile the smart contracts with: + +```bash +yarn build +``` + +### 3. Deploy Contracts + +Customize your Jetton by editing the `contract.deploy.ts` file. This file also includes a detailed deployment guide. Deploy the contracts with: + +```bash +yarn deploy +``` + +### 4. Test Contracts + +Run tests in the `@ton/sandbox` environment: + +```bash +yarn test +``` + +## Jetton Architecture + +If you’re new to Jettons, refer to the [TON Jettons Processing](https://docs.ton.org/develop/dapps/asset-processing/jettons) + +## Best Practices + +- For guidance on interacting with Jettons using TACT, check the [Jetton Cookbook](https://docs.tact-lang.org/cookbook/jettons/). +- Be cautious of fake messages sent by scammers. Read the [Security Best Practices](https://docs.tact-lang.org/book/security-best-practices/) for protection against fraudulent activities. +- Always consult the [official TACT documentation](https://docs.tact-lang.org/) for additional resources and support. + +## License + +This project is licensed under the MIT License. From 5735d3f7cb2c689369b71f9a428cb6671b3b2d95 Mon Sep 17 00:00:00 2001 From: b4cksl4sh Date: Mon, 2 Dec 2024 18:11:06 +0300 Subject: [PATCH 02/10] Updated misti, so CI works now --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e5882cf..3d358fe 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dependencies": { "@aws-crypto/sha256-js": "^5.2.0", "@nowarp/misti": "~0.5.0", - "@tact-lang/compiler": "~1.5.0", + "@tact-lang/compiler": "^1.5.3", "@tact-lang/deployer": "^0.2.0", "@tact-lang/ton-abi": "^0.0.3", "@tact-lang/ton-jest": "^0.0.4", @@ -26,6 +26,7 @@ "dotenv": "^16.4.5", "enquirer": "^2.3.6", "jest": "^29.3.1", + "misti": "^0.0.21", "open": "^8.4.0", "prando": "^6.0.1", "prettier": "^2.5.1", From b603ed194a6a143701a9438102a2c9dad7656832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A8=D0=B2=D0=B5=D1=86=20=D0=90=D0=BD=D0=B4=D1=80=D0=B5?= =?UTF-8?q?=D0=B9=20=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D1=8C=D0=B5=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= <91282981+Shvandre@users.noreply.github.com> Date: Tue, 3 Dec 2024 12:31:31 +0300 Subject: [PATCH 03/10] Update README.md Co-authored-by: Anton Trunov --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d4a5f7b..06ead50 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ This implementation is fully compatible with the following TON standards: - [TEP-74](https://github.com/ton-blockchain/TEPs/blob/master/text/0074-jettons-standard.md), - [TEP-89](https://github.com/ton-blockchain/TEPs/blob/master/text/0089-jetton-wallet-discovery.md). -You can use this implementation as an alternative to the official Jetton contracts available in the [TON Blockchain repository](https://github.com/ton-blockchain/token-contract). +You can use this implementation as an alternative to the reference Jetton contracts available in the [TON Blockchain repository](https://github.com/ton-blockchain/token-contract). ## Getting Started From 9c17c380578556a9c6d51b85fc19f6c8609d1335 Mon Sep 17 00:00:00 2001 From: b4cksl4sh Date: Tue, 3 Dec 2024 13:03:05 +0300 Subject: [PATCH 04/10] Added Project Structure in README.md --- README.md | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 06ead50..6025b5c 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# TACT Jetton (Fungible Token) Implementation +# Tact Jetton (Fungible Token) Implementation ## Overview -This project includes a complete setup for working with TACT-based smart contracts for Jettons. It provides: +This project includes a complete setup for working with Tact-based smart contracts for Jettons. It provides: -- A preconfigured TACT compiler. -- Smart contracts written in the TACT language. +- A preconfigured Tact compiler. +- Smart contracts written in the Tact language. - TypeScript + Jest testing environment with `@ton/sandbox`. ## Goals @@ -50,16 +50,43 @@ Run tests in the `@ton/sandbox` environment: ```bash yarn test ``` - ## Jetton Architecture If you’re new to Jettons, refer to the [TON Jettons Processing](https://docs.ton.org/develop/dapps/asset-processing/jettons) +## Project Structure + +Smart contracts themselves are located in the `sources/` directory. +``` +sources/ + jetton_minter.tact + jetton_wallet.tact + messages.tact +``` + + +Tests are locates in `sources/` directory. +``` +sources/ + contrtact.spec.ts +``` + +Deployment script is located in `sources/` directory. +``` +sources/ + contract.deploy.ts +``` + +Note, that tests and deployment script require the compiled contracts to be present in the `sources/output/` directory. +Also, additional utils from `sources/utils/` are used in tests and deployment script. + +`tact.config.json` contains the configuration for the Tact compiler. In most cases, you don't need to modify this file. + ## Best Practices -- For guidance on interacting with Jettons using TACT, check the [Jetton Cookbook](https://docs.tact-lang.org/cookbook/jettons/). +- For guidance on interacting with Jettons using Tact, check the [Jetton Cookbook](https://docs.tact-lang.org/cookbook/jettons/). - Be cautious of fake messages sent by scammers. Read the [Security Best Practices](https://docs.tact-lang.org/book/security-best-practices/) for protection against fraudulent activities. -- Always consult the [official TACT documentation](https://docs.tact-lang.org/) for additional resources and support. +- Always consult the [official Tact documentation](https://docs.tact-lang.org/) for additional resources and support. ## License From b336ed6f54306d549b08f55674b7264c134b53de Mon Sep 17 00:00:00 2001 From: b4cksl4sh Date: Tue, 3 Dec 2024 13:12:55 +0300 Subject: [PATCH 05/10] Added Project Structure in README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 6025b5c..dea1ec3 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,16 @@ Also, additional utils from `sources/utils/` are used in tests and deployment sc `tact.config.json` contains the configuration for the Tact compiler. In most cases, you don't need to modify this file. +## Smart-Contracts Structure + +Main smart contract is `jetton_minter.tact`. It imports `messages.tact` and `jetton_wallet.tact`, so they will be compiled automatically, when setting `jetton_minter.tact` as target in `tact.config.json`. +### Traits +Jetton minter is using *OwnableTransferable* and *Deployable* trait. Actually, you can remove *Deployable* trait. It is used only for more convenient deployment in tests. + +Jetton wallet is using only *Ownable* trait. + +You can learn more about traits in the [Tact standard library](https://docs.tact-lang.org/ref/standard-libraries/). + ## Best Practices - For guidance on interacting with Jettons using Tact, check the [Jetton Cookbook](https://docs.tact-lang.org/cookbook/jettons/). From 042d004a6caf224ac991134af180616a687d19e0 Mon Sep 17 00:00:00 2001 From: b4cksl4sh Date: Fri, 6 Dec 2024 15:53:03 +0300 Subject: [PATCH 06/10] Removed Deployable trait. Added Mermaid diagram. Slightly adjusted deployment in tests --- README.md | 20 +++++++++++++++++++- sources/contract.spec.ts | 9 ++++++--- sources/jetton_minter.tact | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index dea1ec3..00ad608 100644 --- a/README.md +++ b/README.md @@ -86,10 +86,28 @@ Also, additional utils from `sources/utils/` are used in tests and deployment sc Main smart contract is `jetton_minter.tact`. It imports `messages.tact` and `jetton_wallet.tact`, so they will be compiled automatically, when setting `jetton_minter.tact` as target in `tact.config.json`. ### Traits -Jetton minter is using *OwnableTransferable* and *Deployable* trait. Actually, you can remove *Deployable* trait. It is used only for more convenient deployment in tests. +Jetton minter is using only *OwnableTransferable* which is inherited from *Ownable* trait. Jetton wallet is using only *Ownable* trait. +**Note: These traits are implemented in stdlib.** + +Scheme of inheritance and imports: +```mermaid +graph LR + B[jetton_minter.tact] -->|import| A[messages.tact] + C[jetton_wallet.tact] -->|import| A[messages.tact] + B[jetton_minter.tact] -->|import| C[jetton_wallet.tact] + + C[jetton_wallet.tact] -->|uses| E[ownable] + B[jetton_minter.tact] -->|uses| F[ownableTransferable] + F[ownableTransferable] -->|inherits| E[ownable] + + class E,F ownableStyle; + + classDef ownableStyle stroke-width:2,rx:25,ry:25; + +``` You can learn more about traits in the [Tact standard library](https://docs.tact-lang.org/ref/standard-libraries/). ## Best Practices diff --git a/sources/contract.spec.ts b/sources/contract.spec.ts index 3af2c15..c5dd0e6 100644 --- a/sources/contract.spec.ts +++ b/sources/contract.spec.ts @@ -146,13 +146,16 @@ describe("JettonMinter", () => { notDeployer = await blockchain.treasury('notDeployer'); defaultContent = beginCell().endCell(); - let msg: Deploy = { - $$type: "Deploy", - queryId: 0n, + let msg: TokenUpdateContent = { + $$type: "TokenUpdateContent", + content: defaultContent, } jettonMinter = blockchain.openContract(await JettonMinter.fromInit(deployer.address, defaultContent)); + + //We send Update content to deploy the contract, because it is not automatically deployed after blockchain.openContract + //And to deploy it we should send any message. But update content message with same content does not affect anything. That is why I chose it. const deployResult = await jettonMinter.send(deployer.getSender(), {value: toNano("0.1")}, msg); expect(deployResult.transactions).toHaveTransaction({ diff --git a/sources/jetton_minter.tact b/sources/jetton_minter.tact index 562c1b7..36a9af8 100644 --- a/sources/jetton_minter.tact +++ b/sources/jetton_minter.tact @@ -13,7 +13,7 @@ struct JettonMasterState { jettonWalletCode: Cell; } -contract JettonMinter with OwnableTransferable, Deployable { +contract JettonMinter with OwnableTransferable { totalSupply: Int as coins; mintable: Bool; owner: Address; From cf865b512759dc76b885c084439abfe8292d902b Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Sun, 8 Dec 2024 18:58:32 +0100 Subject: [PATCH 07/10] chore: minor edits --- README.md | 65 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 00ad608..d1d4966 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# Tact Jetton (Fungible Token) Implementation +# Jetton (Fungible Token) Implementation in Tact ## Overview -This project includes a complete setup for working with Tact-based smart contracts for Jettons. It provides: +This project includes a complete setup for working with Tact-based Jetton smart contracts. It provides: -- A preconfigured Tact compiler. +- A pre-configured Tact compiler. - Smart contracts written in the Tact language. - TypeScript + Jest testing environment with `@ton/sandbox`. @@ -50,49 +50,49 @@ Run tests in the `@ton/sandbox` environment: ```bash yarn test ``` + ## Jetton Architecture -If you’re new to Jettons, refer to the [TON Jettons Processing](https://docs.ton.org/develop/dapps/asset-processing/jettons) +If you’re new to Jettons, read the [TON Jettons Processing](https://docs.ton.org/develop/dapps/asset-processing/jettons). ## Project Structure -Smart contracts themselves are located in the `sources/` directory. -``` -sources/ - jetton_minter.tact - jetton_wallet.tact - messages.tact -``` - +Smart contracts, their tests and the deployment script are located in the `sources/` directory: -Tests are locates in `sources/` directory. ``` sources/ - contrtact.spec.ts +│ +│ # Contracts and auxiliary Tact code +├── jetton_minter.tact +├── jetton_wallet.tact +├── messages.tact +│ +│ # Tests +├── contract.spec.ts +│ +│ # Deployment script +├── contract.deploy.ts +│ +│ # Miscellaneous utility things +│ # used for tests and deployments +├── contract.read.ts +└── utils/ ``` -Deployment script is located in `sources/` directory. -``` -sources/ - contract.deploy.ts -``` +Note, that tests and the deployment script require the compiled contracts to be present in the `sources/output/` directory. -Note, that tests and deployment script require the compiled contracts to be present in the `sources/output/` directory. -Also, additional utils from `sources/utils/` are used in tests and deployment script. +The configuration for the Tact compiler is in `tact.config.json` in the root of the repository. In most cases you won't need to change this file. -`tact.config.json` contains the configuration for the Tact compiler. In most cases, you don't need to modify this file. +## Smart Contracts Structure -## Smart-Contracts Structure +The main smart contract is `jetton_minter.tact`, it imports `messages.tact` and `jetton_wallet.tact`. With the default configuration of `tact.config.json` targeting `jetton_minter.tact`, they're all compiled automatically. -Main smart contract is `jetton_minter.tact`. It imports `messages.tact` and `jetton_wallet.tact`, so they will be compiled automatically, when setting `jetton_minter.tact` as target in `tact.config.json`. -### Traits -Jetton minter is using only *OwnableTransferable* which is inherited from *Ownable* trait. +### Inherited traits -Jetton wallet is using only *Ownable* trait. +Jetton Minter uses only *OwnableTransferable*, which is inherited from the *Ownable* trait. Jetton Wallet only uses the *Ownable* trait. All these traits come from the Tact's [standard libraries](https://docs.tact-lang.org/ref/standard-libraries/). -**Note: These traits are implemented in stdlib.** +Schemes of inheritance and imports: -Scheme of inheritance and imports: ```mermaid graph LR B[jetton_minter.tact] -->|import| A[messages.tact] @@ -108,12 +108,13 @@ graph LR classDef ownableStyle stroke-width:2,rx:25,ry:25; ``` -You can learn more about traits in the [Tact standard library](https://docs.tact-lang.org/ref/standard-libraries/). + +Read more about those traits in the [Tact standard library](https://docs.tact-lang.org/ref/standard-libraries/). ## Best Practices -- For guidance on interacting with Jettons using Tact, check the [Jetton Cookbook](https://docs.tact-lang.org/cookbook/jettons/). -- Be cautious of fake messages sent by scammers. Read the [Security Best Practices](https://docs.tact-lang.org/book/security-best-practices/) for protection against fraudulent activities. +- For guidance on interacting with Jettons using Tact, read the [Jetton cookbook](https://docs.tact-lang.org/cookbook/jettons/). +- Be cautious of fake messages sent by scammers. Read [security best practices](https://docs.tact-lang.org/book/security-best-practices/) to protect yourself from fraudulent activities. - Always consult the [official Tact documentation](https://docs.tact-lang.org/) for additional resources and support. ## License From 52026ddee7f09698f17061de1627b5b437828888 Mon Sep 17 00:00:00 2001 From: b4cksl4sh Date: Tue, 10 Dec 2024 11:42:51 +0300 Subject: [PATCH 08/10] Removed unnecessary "printTransactionFees" --- sources/contract.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/contract.spec.ts b/sources/contract.spec.ts index c5dd0e6..1496acf 100644 --- a/sources/contract.spec.ts +++ b/sources/contract.spec.ts @@ -556,7 +556,7 @@ describe("JettonMinter", () => { let sendResult = await deployerJettonWallet.sendTransfer(deployer.getSender(), sentAmount, sentAmount, someAddress, deployer.address, null, forwardAmount, forwardPayload); - printTransactionFees(sendResult.transactions); + expect(sendResult.transactions).toHaveTransaction({ from: deployer.address, to: deployerJettonWallet.address, From 07014fd776c24d8c73f38ba0b63bf1ec7e6fd6e9 Mon Sep 17 00:00:00 2001 From: b4cksl4sh Date: Tue, 10 Dec 2024 11:44:27 +0300 Subject: [PATCH 09/10] Downgraded @tact-lang/compiler version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3d358fe..fb1062a 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dependencies": { "@aws-crypto/sha256-js": "^5.2.0", "@nowarp/misti": "~0.5.0", - "@tact-lang/compiler": "^1.5.3", + "@tact-lang/compiler": "~1.5.0", "@tact-lang/deployer": "^0.2.0", "@tact-lang/ton-abi": "^0.0.3", "@tact-lang/ton-jest": "^0.0.4", From 12ec7cc8ded4f809bce6193fab2e54bf99f09de3 Mon Sep 17 00:00:00 2001 From: b4cksl4sh Date: Tue, 10 Dec 2024 11:44:27 +0300 Subject: [PATCH 10/10] Downgraded @tact-lang/compiler version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fb1062a..ecc684d 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dependencies": { "@aws-crypto/sha256-js": "^5.2.0", "@nowarp/misti": "~0.5.0", - "@tact-lang/compiler": "~1.5.0", + "@tact-lang/compiler": "^1.5.0", "@tact-lang/deployer": "^0.2.0", "@tact-lang/ton-abi": "^0.0.3", "@tact-lang/ton-jest": "^0.0.4",