From 0d460c70e80d6aa2f9da95617fedddb5dea67191 Mon Sep 17 00:00:00 2001 From: Denis Subbotin Date: Tue, 23 Jul 2024 00:53:11 +0300 Subject: [PATCH 1/3] Add standard for mitless jettons --- text/0000-compressed-jetton-standard.md | 89 +++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 text/0000-compressed-jetton-standard.md diff --git a/text/0000-compressed-jetton-standard.md b/text/0000-compressed-jetton-standard.md new file mode 100644 index 00000000..c1cce13f --- /dev/null +++ b/text/0000-compressed-jetton-standard.md @@ -0,0 +1,89 @@ +- **TEP**: [0](https://github.com/ton-blockchain/TEPs/pull/0) +- **title**: Compressed Jetton +- **status**: Draft +- **type**: Contract Interface +- **authors**: [Emelyanenko Kirill](https://github.com/EmelyanenkoK), [Denis Subbotin](https://github.com/mr-tron) +- **created**: 7.07.2024 +- **replaces**: - +- **replaced by**: - + +# Summary + +Extension for [Jetton](https://github.com/ton-blockchain/TEPs/blob/master/text/0074-jettons-standard.md) that allows merkle-proof airdrops with mint occuring on jetton-wallet contract in decentralised manner. +Support from wallet apps will allow to show not yet claimed jettons on balance and automatically claim on first outgoing transfer. + +# Motivation + +There is a need (to create large communities, big advertising campaigns, etc) for a type of Jettons that can be simultaneously airdropped to millions of users and being deployed on demand without large costs and significant additional load to blockchain. + +# Guide + +A straightforward way to achieve properties described in [Motivation](#motivation) is using [Merkle trees](https://en.wikipedia.org/wiki/Merkle_tree) - when airdrop amount for each user is stored in a leaf of the tree and can be "claimed" by owner by providing a small proof of its presence in the tree, and the jetton itself only needs to store a single hash for all items (not per item). + +### Useful links + +1. [Reference contract implementation](https://github.com/cJetton/cJetton) +2. [Custom payload API](ttps://github.com/ton-blockchain/TEPs/blob/master/text/0000-jetton-offchain-payloads.md) + +# Specification + +> The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119. + + +## Contract + +### Storage +In addition to standard fields (like balance, owner, etc), this standard suggest to store `merkle_hash` 256-bit integer in JettonMaster and JettonWallet contracts. Additionally all JettonWallet contracts stores flag `already_claimed` whether airdrop was claimed or not. + +### Handlers + +Standard TEP-74 Jetton implements the `transfer` handler with the following scheme: + +``` +transfer#0f8a7ea5 query_id:uint64 amount:(VarUInteger 16) destination:MsgAddress + response_destination:MsgAddress custom_payload:(Maybe ^Cell) + forward_ton_amount:(VarUInteger 16) forward_payload:(Either Cell ^Cell) + = InternalMsgBody; +``` + +This standard propose to use `custom_payload` to store there _claim airdrop_ command with the following scheme: +``` +merkle_airdrop_claim proof:^Cell = CustomPayload; +``` + +Where proof is _MerkleProof_ exotic cell of `Airdrop` structure with all unused branches pruned and the following scheme: + +``` +_ amount:Coins start_from:uint48 expired_at:uint48 = AirdropItem; + +_ _(HashMap 267 AirdropItem) = Airdrop; +``` + +where 267-bit key is MsgAddressInt with `addr_std` constructor and empty `anycast`. + + +Upon receiving transfer command with attached `claim_airdrop` subcommand, jetton wallet checks: +* MerkleProof is valid and hash corresponds to stored merkle_hash +* whether airdrop is already claimed +* is now() between `start_from` and `expired_at` + +then sets internal flag `already_claimed` to True and credits amount from AirdropItem. + + +After that standard transfer operation should be executed. + +## Indexation and api + + + +### Custom payload and indexation API + +Described in [Jetton Offchain Payloads](https://github.com/ton-blockchain/TEPs/blob/master/text/0000-jetton-offchain-payloads.md) TEP. + +### GetMethods + +Method `is_minted()` for jetton wallets returns `bool` whether jetton is minted or not. + +//TODO: make better naming +Method `get_merkle_dump()` returns (int256 merkle_hash, cell uri) where `uri` is the **final** (i.e. including any postfixes) root URI +in `SnakeText` format **without a trailing slash `/`** pointed to BoC with merkle tree dump (as file or to directory with files). \ No newline at end of file From ecb7e3cc756f865a0fd0fd53c8edc9cd17bc4ccd Mon Sep 17 00:00:00 2001 From: Denis Subbotin Date: Wed, 31 Jul 2024 23:47:04 +0300 Subject: [PATCH 2/3] move to metadata --- text/0000-compressed-jetton-standard.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/text/0000-compressed-jetton-standard.md b/text/0000-compressed-jetton-standard.md index c1cce13f..b84a4a2e 100644 --- a/text/0000-compressed-jetton-standard.md +++ b/text/0000-compressed-jetton-standard.md @@ -74,16 +74,17 @@ After that standard transfer operation should be executed. ## Indexation and api - - ### Custom payload and indexation API Described in [Jetton Offchain Payloads](https://github.com/ton-blockchain/TEPs/blob/master/text/0000-jetton-offchain-payloads.md) TEP. -### GetMethods +### + +In metadate stored according to [Metadata standard](https://github.com/ton-blockchain/TEPs/blob/master/text/0064-token-data-standard.md) +should be added field "mintles_merkle_dump_uri" with `string` type in json or `ContentData` type in TL-B: + +`mintles_merkle_dump_uri` pointed to binary file contains BoC with merkle tree of all jettons wallets. -Method `is_minted()` for jetton wallets returns `bool` whether jetton is minted or not. +## GetMethods -//TODO: make better naming -Method `get_merkle_dump()` returns (int256 merkle_hash, cell uri) where `uri` is the **final** (i.e. including any postfixes) root URI -in `SnakeText` format **without a trailing slash `/`** pointed to BoC with merkle tree dump (as file or to directory with files). \ No newline at end of file +Method `is_claimed()` for jetton wallets returns `bool` whether jetton is minted or not. From 2124c1712c0b1a4f9ca2186cc91550dc369e1edf Mon Sep 17 00:00:00 2001 From: EmelyanenkoK Date: Thu, 22 Aug 2024 18:04:56 +0300 Subject: [PATCH 3/3] Rename: compressed -> mintless jettons --- ...etton-standard.md => 0177-mintless-jetton-standard.md} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename text/{0000-compressed-jetton-standard.md => 0177-mintless-jetton-standard.md} (94%) diff --git a/text/0000-compressed-jetton-standard.md b/text/0177-mintless-jetton-standard.md similarity index 94% rename from text/0000-compressed-jetton-standard.md rename to text/0177-mintless-jetton-standard.md index b84a4a2e..bc971a03 100644 --- a/text/0000-compressed-jetton-standard.md +++ b/text/0177-mintless-jetton-standard.md @@ -1,5 +1,5 @@ -- **TEP**: [0](https://github.com/ton-blockchain/TEPs/pull/0) -- **title**: Compressed Jetton +- **TEP**: [177](https://github.com/ton-blockchain/TEPs/pull/177) +- **title**: Mintless jettons - **status**: Draft - **type**: Contract Interface - **authors**: [Emelyanenko Kirill](https://github.com/EmelyanenkoK), [Denis Subbotin](https://github.com/mr-tron) @@ -22,7 +22,7 @@ A straightforward way to achieve properties described in [Motivation](#motivatio ### Useful links -1. [Reference contract implementation](https://github.com/cJetton/cJetton) +1. [Reference contract implementation](https://github.com/ton-community/mintless-jetton) 2. [Custom payload API](ttps://github.com/ton-blockchain/TEPs/blob/master/text/0000-jetton-offchain-payloads.md) # Specification @@ -48,7 +48,7 @@ transfer#0f8a7ea5 query_id:uint64 amount:(VarUInteger 16) destination:MsgAddress This standard propose to use `custom_payload` to store there _claim airdrop_ command with the following scheme: ``` -merkle_airdrop_claim proof:^Cell = CustomPayload; +merkle_airdrop_claim#0df602d6 proof:^Cell = CustomPayload; ``` Where proof is _MerkleProof_ exotic cell of `Airdrop` structure with all unused branches pruned and the following scheme: