{"id":22072565,"url":"https://github.com/broxus/jetton","last_synced_at":"2025-09-14T16:43:31.694Z","repository":{"id":256416958,"uuid":"855195239","full_name":"broxus/jetton","owner":"broxus","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-21T13:36:54.000Z","size":772,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-29T02:46:47.731Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/broxus.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}},"created_at":"2024-09-10T13:28:52.000Z","updated_at":"2025-01-21T13:36:58.000Z","dependencies_parsed_at":"2024-09-10T16:25:38.020Z","dependency_job_id":"928d5470-2740-4b9b-a699-26410e46ea5c","html_url":"https://github.com/broxus/jetton","commit_stats":null,"previous_names":["broxus/jetton"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broxus%2Fjetton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broxus%2Fjetton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broxus%2Fjetton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broxus%2Fjetton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/broxus","download_url":"https://codeload.github.com/broxus/jetton/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245155477,"owners_count":20569705,"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":[],"created_at":"2024-11-30T21:13:44.694Z","updated_at":"2025-09-14T16:43:31.679Z","avatar_url":"https://github.com/broxus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bridge jetton-contracts \n\n## Build and test\n\n```shell\nnpm install\nnpm run build\nnpm run test\n```\n\nNote: if you experience issues with running the test try to test using node.js 14\n\n## Info\n\nCurrent jetton contracts extend and modify some behavior of original contracts https://github.com/ton-blockchain/minter-contract.\nBut it is fully compatible with contracts that use ordinary jettons.\n\n## Features\n\n- \u003ccode\u003ejetton-platform.fc\u003c/code\u003e contract which allows the upgrade of wallet contracts\n- on-chain jetton content encoding\n- \u003ccode\u003eon_accept_tokens_burn\u003c/code\u003e callback for integration with other contracts\n- \u003ccode\u003eupgrade_wallet\u003c/code\u003e and \u003ccode\u003eupgrade_minter\u003c/code\u003e opcodes for minter and wallet contracts upgrade\n- additional admin opcodes in root \u003ccode\u003eset_wallet_code\u003c/code\u003e and \u003ccode\u003edeploy_wallet\u003c/code\u003e\n- \u003ccode\u003eprovide_info\u003c/code\u003e and \u003ccode\u003etake_info\u003c/code\u003e to get the minter's decimals, name, and symbol for another contract\n\n## Features description\n\n### jetton-platform.fc\n\nThe platform allows for upgradable and secure contracts without breaking compatibility between wallets of different versions.\nEach contract in TVM receives a deterministic address from its code and init data: \u003ccode\u003eaddress = hash(code + init_data)\u003c/code\u003e.\nTo make upgradable jetton wallets we use jetton-platform.fc as code and address of its owner and minter as init data.\nTo check that the sender is a valid Jetton wallet we also use platform code with the owner's and minter's addresses to derive a valid address\n\n```func\ncell calculate_jetton_wallet_state_init(\n    slice owner_address,\n    slice jetton_master_address,\n    cell jetton_platform_code\n) inline {\n    cell data = pack_jetton_wallet_data(\n        0,\n        owner_address,\n        jetton_master_address,\n        begin_cell().end_cell(),\n        jetton_platform_code,\n        0\n    );\n\n    return begin_cell()\n        .store_uint(0, 2)\n        .store_dict(jetton_platform_code) ;; code\n        .store_dict(data) ;; init data\n        .store_uint(0, 1)\n        .end_cell();\n}\n```\n\nTo upgrade wallet from platform and perform \u003ccode\u003ereceive_tokens\u003c/code\u003e:\n\n```func\n    ;; update contract's code for future txs\n    set_code(wallet_code);\n\n    ;; update contract's code for current receive_tokens() call. God bless us!!!\n    set_c3(wallet_code.begin_parse().bless());\n\n    ;; for newly deployed jetton wallet only receive_tokens() call is possible\n    receive_tokens(\n        ms,\n        sender_address,\n        my_balance,\n        fwd_fee,\n        msg_value\n    );\n```\n\n### On-chain metadata\n\nJetton's metadata builds on-chain.\n\nNote: replace Jetton's icon URL with yours\n\n```func\nslice image_slice = begin_cell()\n    .store_slice(\"https://ton-tokens-api.bf.works/image/\")\n    .store_slice(my_workchain)\n    .store_slice(\":\")\n    .store_slice(my_hash)\n    .store_slice(\".svg\")\n    .end_cell()\n    .begin_parse();\n\ncell content_dict = new_dict();\n\ncontent_dict~udict_set_ref(256, \"image\"H, pack_metadata_value(image_slice));\ncontent_dict~udict_set_ref(256, \"decimals\"H, pack_metadata_value(decimals_slice));\ncontent_dict~udict_set_ref(256, \"name\"H, pack_metadata_value(name.begin_parse()));\ncontent_dict~udict_set_ref(256, \"symbol\"H, pack_metadata_value(symbol_slice));\n\ncell onchain_content = begin_cell()\n    .store_uint(0, 8)\n    .store_dict(content_dict)\n    .end_cell();\n```\n\n### op::on_accept_tokens_burn()\n\nWhen the wallet's owner burns his jettons he will receive a notification callback from the minter.\nIt needs for integration with other contracts or protocols e.a.: DEXes, lendings, bridges, etc.\n\n### op::upgrade_wallet() and op::upgrade_minter()\n\nIt's also possible to upgrade wallet and minter contracts anytime if you find vulnerabilities in contracts\nor decided to extend their interface\n\n### op::provide_info() and op::take_info()\n\nThese opcodes will provide you info about Jetton from the minter contract: decimals, name, symbol, etc.\nIt's useful if you need to identify your contracts by tokens' names or need to make price oracle,\ncurve-like DEX pools or some other useful stuff that needs Jetton's decimals, symbol, name, or your\ncustom metadata (chain ID and base token address for a bridge for example)\n\n### Changed gas management in wallet's op::internal_transfer()\n\nWhen the wallet receives a transfer it will try to keep its balance before the tx\nor at least take some message's gas to pay for its storage.\nWallet's balance can be: [min_tons_for_storage, ∞)\n\n```func\nraw_reserve(max(ton_balance_before_msg, min_tons_for_storage), 2);\n```\n\nAlso, you don't need to split your gas for \u003ccode\u003eop::transfer_notification()\u003c/code\u003e and \u003ccode\u003eop::excesses()\u003c/code\u003e.\nIn most cases, contracts want to send whole gas to notification or excesses callback.\nUse a non-zero forward amount to send the whole gas to \u003ccode\u003eop::transfer_notification()\u003c/code\u003e.\nOtherwise, the whole gas will be sent to \u003ccode\u003eop::excesses()\u003c/code\u003e\n\n## Other minor features\n\n- \u003ccode\u003eop::drain()\u003c/code\u003e in minter and wallet contracts to drain excesses from the contract's balance\n- \u003ccode\u003ejetton-wallet.fc#get_wallet_platform_data()\u003c/code\u003e getter to receive platform code and current wallet's version\n- \u003ccode\u003ejetton-minter.fc#get_jetton_meta()\u003c/code\u003e getter to receive raw metadata without dictionary\n- \u003ccode\u003ejetton-minter.fc#get_jetton_platform_data()\u003c/code\u003e getter to receive platform code and current wallet's code version\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbroxus%2Fjetton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbroxus%2Fjetton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbroxus%2Fjetton/lists"}