{"id":21489076,"url":"https://github.com/tact-lang/jetton","last_synced_at":"2025-04-23T08:33:40.062Z","repository":{"id":262279017,"uuid":"886211324","full_name":"tact-lang/jetton","owner":"tact-lang","description":"Jetton implementation in Tact compatible with TEP-74","archived":false,"fork":false,"pushed_at":"2025-04-17T10:17:20.000Z","size":468,"stargazers_count":11,"open_issues_count":21,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-18T00:47:33.069Z","etag":null,"topics":["fungible-token","jetton","smart-contracts","tact","tact-lang","ton"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tact-lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-10T13:50:06.000Z","updated_at":"2025-04-16T12:09:41.000Z","dependencies_parsed_at":"2025-01-12T21:24:01.997Z","dependency_job_id":"43d355c3-f92b-44b5-a314-0600562f5161","html_url":"https://github.com/tact-lang/jetton","commit_stats":null,"previous_names":["shvandre/jetton-implementation","tact-lang/jetton-implementation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tact-lang%2Fjetton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tact-lang%2Fjetton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tact-lang%2Fjetton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tact-lang%2Fjetton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tact-lang","download_url":"https://codeload.github.com/tact-lang/jetton/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250399960,"owners_count":21424266,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fungible-token","jetton","smart-contracts","tact","tact-lang","ton"],"created_at":"2024-11-23T14:13:58.057Z","updated_at":"2025-04-23T08:33:40.054Z","avatar_url":"https://github.com/tact-lang.png","language":"TypeScript","funding_links":[],"categories":["Smart contracts [↑](#contents)"],"sub_categories":["Debugging"],"readme":"# Jetton (Fungible Token) Implementation in Tact\n\n[![Testnet Deploy](https://img.shields.io/github/actions/workflow/status/tact-lang/jetton/deploy-test.yml?branch=main\u0026style=for-the-badge\u0026logo=stackblitz\u0026label=Testnet%20Deploy)](https://gist.github.com/Kaladin13/3d2f2d0b3e2f5a81f77d8e490e3b2807#file-deploy-result-json)\n\n## Overview\n\nThis project includes a complete setup for working with Tact-based Jetton smart contracts. It provides:\n\n- A pre-configured Tact compiler.\n- Smart contracts written in the Tact language.\n- TypeScript + Jest testing environment with `@ton/sandbox`.\n- Gas usage benchmarks throughout different versions\n\n## Goals\n\nThis implementation is fully compatible with the following TON standards:\n\n- [TEP-64](https://github.com/ton-blockchain/TEPs/blob/master/text/0064-token-data-standard.md),\n- [TEP-74](https://github.com/ton-blockchain/TEPs/blob/master/text/0074-jettons-standard.md),\n- [TEP-89](https://github.com/ton-blockchain/TEPs/blob/master/text/0089-jetton-wallet-discovery.md).\n\nYou 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).\n\nYou can read [Specification](./SPEC.md), that goes into the design choices and differences between this and other implementations\n\n## Improvements and additional features\n\nThis implementation also includes new features, that will allow developers and users on TON to easier integrate and work with Jettons in their applications\n\n### Balance on-chain API\n\nThis additional receiver provides functionality similar to [TEP-89](https://github.com/ton-blockchain/TEPs/blob/master/text/0089-jetton-wallet-discovery.md), but with wallet balance. You can request and then receive balance from any Jetton wallet with possible additional info for transaction verification\n\n#### Transaction scheme\n\n```mermaid\nsequenceDiagram\n    participant D as Any Account\n    participant C as Jetton Wallet\n\n    D -\u003e\u003e+ C: ProvideWalletBalance\u003cBR /\u003e(0x7ac8d559)\n    C -\u003e\u003e+ D: TakeWalletBalance\u003cBR /\u003e(0xca77fdc2)\n```\n\n#### TLB\n\n```tlb\nprovide_wallet_balance#7ac8d559 receiver:MsgAddress include_verify_info:Bool = InternalMsgBody;\n\nverify_info$_ owner:MsgAddress minter:MsgAddress code:^Cell = VerifyInfo;\ntake_wallet_balance#ca77fdc2 balance:Coins verify_info:(Maybe VerifyInfo) = InternalMsgBody;\n```\n\n### Claim TON from Jetton Wallet/Minter\n\nThese receivers both on Jetton Wallet and Jetton Minter allow to claim stale TON coins from contracts, leaving just enough balance for them to not freeze and function properly. Message body includes `receiver` field, that allows to specify funds receiver\n\n#### Transaction scheme\n\n```mermaid\nsequenceDiagram\n    participant D as Owner\n    participant C as Jetton Wallet/Minter\n    participant F as msg.receiver\n\n    D -\u003e\u003e+ C: ClaimTON\u003cBR /\u003e(0x0393b1ce)\n    C -\u003e\u003e+ F: TON's\u003cBR /\u003e(empty body)\n```\n\n#### TLB\n\n```tlb\nclaim_ton#0393b1ce receiver:MsgAddress = InternalMsgBody;\n```\n\n## Getting Started\n\n### 1. Install Dependencies\n\nRun the following command to install all required dependencies:\n\n```bash\nyarn install\n```\n\n### 2. Build Contracts\n\nCompile the smart contracts with:\n\n```bash\nyarn build\n```\n\n### 3. Deploy Contracts\n\nCustomize your Jetton by editing the `contract.deploy.ts` file. This file also includes a detailed deployment guide. Deploy the contracts with:\n\n```bash\nyarn deploy\n```\n\n#### 4. Deployment Verification\n\nTo verify that your Jetton contract was deployed correctly, you can use the built-in verification test:\n\nRun the verification test:\n\n```bash\nyarn verify-deployment\n```\n\nThis verification test will check:\n\n- If the contract is active\n- If the contract parameters match what you specified\n- If the contract metadata is correctly set up\n\n### 5. Read Contract Data\n\nYou can read on-chain data for the minter from its address using script `src/scripts/contract.read.ts`\n\n```bash\nyarn read\n```\n\nExample output:\n\n```shell\n❯ yarn read\nyarn run v1.22.22\n$ ts-node ./src/scripts/contract.read.ts\nEnter minter address: kQC58H9FUaJ0XUBKq9lXJxF_JBQZIy0dC4_7y4ggr9PEKClM\n\nMinter data\nTotal supply: 1000000000000000000\nOwner: EQD2ZeBj70MzYZll7HVTT4cNSn62-P0VCL4ncCd-08-4alAY\nIs mintable: Yes\nToken name: TactJetton\nDescription: This is description of Jetton #41 (Run at 14171609974 - 1)\nImage: https://raw.githubusercontent.com/tact-lang/tact/refs/heads/main/docs/public/logomark-light.svg\nDone in 5.03s.\n```\n\n### 6. Test Contracts\n\nRun tests in the `@ton/sandbox` environment:\n\n```bash\nyarn test\n```\n\n### 6. Benchmark Contracts\n\nTo run gas usage benchmarks and get them printed in the table, use\n\n```bash\nyarn bench\n```\n\nExample output\n\n```shell\n❯ yarn bench\nyarn run v1.22.22\n$ cross-env PRINT_TABLE=true ts-node ./src/benchmarks/benchmarks.ts\nGas Usage Results:\n┌────────────────────────────────────────────────────────────────────┬────────────────┬────────────────┬────────────────┬───────────────┬───────────────┬─────────────┬────────────────┬──────┐\n│ Run                                                                │ transfer       │ mint           │ burn           │ discovery     │ reportBalance │ claimWallet │ Summary        │ PR # │\n├────────────────────────────────────────────────────────────────────┼────────────────┼────────────────┼────────────────┼───────────────┼───────────────┼─────────────┼────────────────┼──────┤\n│ Initial                                                            │ 16319          │ 18811          │ 12558          │ 6655          │ -             │ -           │ 54343          │ 77   │\n├────────────────────────────────────────────────────────────────────┼────────────────┼────────────────┼────────────────┼───────────────┼───────────────┼─────────────┼────────────────┼──────┤\n│ With Tact-lang changes (selector hack and basechain optimizations) │ 15511 (-4.95%) │ 18027 (-4.17%) │ 12390 (-1.34%) │ 6557 (-1.47%) │ -             │ -           │ 52485 (-3.42%) │ 83   │\n├────────────────────────────────────────────────────────────────────┼────────────────┼────────────────┼────────────────┼───────────────┼───────────────┼─────────────┼────────────────┼──────┤\n│ With Report Balance                                                │ 15511 same     │ 18027 same     │ 12408 (+0.15%) │ 6557 same     │ 4537 (new)    │ -           │ 57040 (+8.68%) │ 84   │\n├────────────────────────────────────────────────────────────────────┼────────────────┼────────────────┼────────────────┼───────────────┼───────────────┼─────────────┼────────────────┼──────┤\n│ Set selector-hack flag to default value                            │ 15651 (+0.90%) │ 18195 (+0.93%) │ 12576 (+1.35%) │ 6655 (+1.49%) │ 4607 (+1.54%) │ -           │ 57684 (+1.13%) │ 86   │\n├────────────────────────────────────────────────────────────────────┼────────────────┼────────────────┼────────────────┼───────────────┼───────────────┼─────────────┼────────────────┼──────┤\n│ With Ton Claim                                                     │ 15651 same     │ 17799 (-2.18%) │ 12944 (+2.93%) │ 6612 (-0.65%) │ 4440 (-3.62%) │ 4030 (new)  │ 61476 (+6.57%) │ 90   │\n└────────────────────────────────────────────────────────────────────┴────────────────┴────────────────┴────────────────┴───────────────┴───────────────┴─────────────┴────────────────┴──────┘\n\nComparison with Tact Jetton implementation:\nTransfer: 95.91% of Tact Jetton gas usage\nMint: 94.62% of Tact Jetton gas usage\nBurn: 103.07% of Tact Jetton gas usage\nDiscovery: 99.35% of Tact Jetton gas usage\nReportBalance: new! of Tact Jetton gas usage\nClaimWallet: new! of Tact Jetton gas usage\nDone in 2.17s.\n```\n\nIf you want to modify the contracts and benchmark your implementation, you can run\n\n```bash\n# add to add new entry\nyarn bench:add\n# or update to replace latest\nyarn bench:update\n```\n\nAfter that, use `yarn bench` to pretty-print the difference table with your results in it\n\n## Jetton Architecture\n\nIf you're new to Jettons, read the [TON Jettons Processing](https://docs.ton.org/develop/dapps/asset-processing/jettons).\n\n## Project Structure\n\nSmart contracts, their tests, and the deployment script are located in the `src` directory:\n\n```\nsrc/\n│\n│   # Contracts and auxiliary Tact code\n├── contracts/\n│   ├── jetton-minter.tact\n│   ├── jetton-wallet.tact\n│   ├── messages.tact\n│   └── constants.tact\n│\n│   # Tests\n├── tests/\n│   ├── extended.spec.ts\n│   └── jetton.spec.ts\n│\n│   # Deployment script\n├── scripts/\n│   ├── contract.deploy.ts\n│   └── contract.read.ts\n│\n│   # Miscellaneous utility things\n└── utils/\n```\n\nNote that tests and the deployment script require the compiled contracts to be present in the `src/output` directory.\n\nThe 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.\n\n## Smart Contracts Structure\n\nThe main smart contract is `jetton-minter.tact`, it imports `messages.tact`, `constants.tact` and `jetton-wallet.tact`. With the default configuration of `tact.config.json` targeting `jetton-minter.tact`, they're all compiled automatically.\n\nScheme of imports:\n\n```mermaid\ngraph LR\n    B[jetton-minter.tact] --\u003e|import| A[messages.tact]\n    C[jetton-wallet.tact] --\u003e|import| A[messages.tact]\n    B[jetton-minter.tact] --\u003e|import| C[jetton-wallet.tact]\n\n    C[jetton-wallet.tact] --\u003e|import| E[constants.tact]\n    B[jetton-minter.tact] --\u003e|import| E[constants.tact]\n```\n\nRead more about imports in the [Tact standard library](https://docs.tact-lang.org/ref/standard-libraries/).\n\n## Contributing\n\nPlease check [CONTRIBUTING.md](dev-docs/CONTRIBUTING.md)\n\n## Best Practices\n\n- For guidance on interacting with Jettons using Tact, read the [Jetton cookbook](https://docs.tact-lang.org/cookbook/jettons/).\n- 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.\n- Always consult the [official Tact documentation](https://docs.tact-lang.org/) for additional resources and support.\n- Check [Specification](dev-docs/SPEC.md) for more in-depth dive into implementation details\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftact-lang%2Fjetton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftact-lang%2Fjetton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftact-lang%2Fjetton/lists"}