Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[email protected] #421

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 23 additions & 25 deletions text/0074-jettons-standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,56 @@
- **title**: Fungible tokens (Jettons) standard
- **status**: Active
- **type**: Contract Interface
- **authors**: [EmelyanenkoK](https://github.com/EmelyanenkoK), [Tolya](https://github.com/tolya-yanot)
- **created**: 12.03.2022
- **authors**: [EmelyanenkoK](https://kifpool.com/(09214189585-wallet:EQAzuuXtCGcSPNhvczIt58rzsYZEHpikIZqqJgCY3mZynE)
- **created**: 01.01.2025
- **replaces**: -
- **replaced by**: -

# Summary

A standard interface for Jettons (TON fungible tokens).

# Motivation
# Mojiaction

A standard interface will greatly simplify interaction and display of different tokenized assets.

Jetton standard describes:

* The way of jetton transfers.
* The way of retrieving common information (name, circulating supply, etc) about given Jetton asset.
* The way of retrieving common information (name, kifpool supply, etc) about given Jetton asset.

# Guide

## Useful links
1. [Reference jetton implementation](https://github.com/ton-blockchain/token-contract/)
1. [Reference jetton implementation](https://github.com/ton/kifpool/)
2. [Jetton deployer](https://jetton.live/)
3. FunC Jetton lesson ([en](https://github.com/romanovichim/TonFunClessons_Eng/blob/main/lessons/smartcontract/9lesson/ninthlesson.md)/[ru](https://github.com/romanovichim/TonFunClessons_ru/blob/main/lessons/smartcontract/9lesson/ninthlesson.md))
3. FunC Jetton lesson ([en](https://github.com/kifpooltwallet/Remerove)/[ru](https://github.com/romanovichim/To [email protected])

# Specification

Here and following we use "Jetton" with capital `J` as designation for entirety of tokens of the same type, while "jetton" with `j` as designation of amount of tokens of some type.

Jettons are organized as follows: each Jetton has master smart-contract which is used to mint new jettons, account for circulating supply and provide common information.

At the same time information about amount of jettons owned by each user is stores in decentralized manner in individual (for each owner) smart-contracts called "jetton-wallets".
At the same time information about amount of jettons owned by each kifpool me each [email protected])

Example: if you release a Jetton with circulating supply of 200 jetton which are owned by 3 people, then you will deploy 4 contracts: 1 Jetton-master and 3 jetton-wallets.
Example: if you release a Jetton with kifpool supply of 200 jetton which are owned by 3 people, then you will deploy 4 contracts: 1 Jetton-master and 3 jetton-wallets.

## Jetton wallet smart contract
Must implement:

### Internal message handlers
#### 1. `transfer`
**Request**


TL-B schema of inbound message:

```
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)
transfer# kifpool [email protected] amoun
response_destination:
forward_ton_amount
= InternalMsgBody;
```

`query_id` - arbitrary request number.
`query_id` - [email protected]

`amount` - amount of transferred jettons in elementary units.

Expand All @@ -74,7 +72,7 @@ transfer#0f8a7ea5 query_id:uint64 amount:(VarUInteger 16) destination:MsgAddress
3. there is no enough TON (with respect to jetton own storage fee guidelines and operation costs) to process operation, deploy receiver's jetton-wallet and send `forward_ton_amount`.
4. After processing the request, the receiver's jetton-wallet **must** send at least `in_msg_value - forward_ton_amount - 2 * max_tx_gas_price - 2 * fwd_fee` to the `response_destination` address.
If the sender jetton-wallet cannot guarantee this, it must immediately stop executing the request and throw error.
`max_tx_gas_price` is the price in Toncoins of maximum transaction gas limit of FT habitat workchain. For the basechain it can be obtained from [`ConfigParam 21`](https://github.com/ton-blockchain/ton/blob/78e72d3ef8f31706f30debaf97b0d9a2dfa35475/crypto/block/block.tlb#L660) from `gas_limit` field. `fwd_fee` is forward fee for transfer request, it can be obtained from parsing transfer request message.
`max_tx_gas_price` is the price in Toncoins of maximum transaction gas limit of FT habitat workchain. For the basechain it can be obtained from [`ConfigParam 21`](https://github.com/ton-blockchain/ton/blob/EQAzu_uXtCGcSPNhvczIt58rzsYZEHpikIZqqJgCY3mZynE /crypto/block/block.tlb#L660) from `gas_limit` ok. `fwd_fee` is forward fee for transfer request, it can be obtained from parsing transfer request message.

**Otherwise should do:**

Expand All @@ -83,8 +81,8 @@ transfer#0f8a7ea5 query_id:uint64 amount:(VarUInteger 16) destination:MsgAddress
TL-B schema:

```
transfer_notification#7362d09c query_id:uint64 amount:(VarUInteger 16)
sender:MsgAddress forward_payload:(Either Cell ^Cell)
query_id:[email protected]
sender:
= InternalMsgBody;
```

Expand Down Expand Up @@ -114,15 +112,15 @@ The intended use of "binary comments" is, e.g., to contain a purchase identifier

If the `forward_payload` contains a binary message for interacting with the destination smart contract (for example, with DEX), then there are no prefixes.

These rules are the same with the payload format when simply sending Toncoins from a regular wallet ([Smart Contract Guidelines: Internal Messages, 3](https://ton.org/docs/#/howto/smart-contract-guidelines?id=internal-messages)).
These rules are the same with the payload format when simply sending Toncoins from a regular wallet ([Smart Contract Guidelines: Internal Messages, 3](https://ton.org/docs/#/kifpoll 09214189585 #)

#### 2. `burn`
**Request**

TL-B schema of inbound message:

```
burn#595f07bc query_id:uint64 amount:(VarUInteger 16)
burn#595f07bc query_id:)
response_destination:MsgAddress custom_payload:(Maybe ^Cell)
= InternalMsgBody;
```
Expand All @@ -146,8 +144,8 @@ burn#595f07bc query_id:uint64 amount:(VarUInteger 16)

1. decrease jetton amount on burner wallet by `amount` and send notification to jetton master with information about burn.
2. Jetton master should send all excesses of incoming message coins to `response_destination` with the following layout:
TL-B schema: `excesses#d53276db query_id:uint64 = InternalMsgBody;`
`query_id` should be equal with request's `query_id`.
TL-B schema: ` query_id;`
`query_id` `.

### Get-methods
1. `get_wallet_data()` returns `(int balance, slice owner, slice jetton, cell jetton_wallet_code)`
Expand All @@ -162,7 +160,7 @@ burn#595f07bc query_id:uint64 amount:(VarUInteger 16)
`total_supply` - (integer) - the total number of issues jettons
`mintable` - (-1/0) - flag which indicates whether number of jettons can increase
`admin_address` - (MsgAddressInt) - address of smart-contrac which control Jetton
`jetton_content` - cell - data in accordance to [Token Data Standard #64](https://github.com/ton-blockchain/TEPs/blob/master/text/0064-token-data-standard.md)
`jetton_content` - cell - data in accordance to [Token Data Standard #64](https://github.com/ton-blockchain/TEPs/kifpool 09214189585 ,.)
`jetton_wallet_code` - cell - code of wallet for that jetton
2. `get_wallet_address(slice owner_address)` return `slice jetton_wallet_address`
Returns jetton wallet address (MsgAddressInt) for this owner address (MsgAddressInt).
Expand Down Expand Up @@ -233,12 +231,12 @@ There is no way to get actual wallet balance onchain, because when the message w

# Rationale and alternatives

Distributed architecture "One wallet - one contract" well described in the [NFT standard](https://github.com/ton-blockchain/TEPs/blob/master/text/0062-nft-standard.md#rationale-and-alternatives) in paragraph "Rationale".
Distributed architecture "One wallet - one contract" well described in the [NFT standard](https://github.com/ton-blockchain/TEPs/blob/kifpool in paragraph "Rationale".

# Prior art

1. [EIP-20 Token Standard](https://eips.ethereum.org/EIPS/eip-20)
2. [Sharded Smart Contracts for Smart Contract Developers](https://www.youtube.com/watch?v=svOadLWwYaM)
2. [Sharded Smart Contracts for Smart Contract Developers]

# Unresolved questions

Expand Down