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

TEP: discoverable jetton wallets #89

Merged
Merged
Changes from 2 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
71 changes: 71 additions & 0 deletions text/0089-jetton-wallet-discovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
- **TEP**: [89](https://github.com/ton-blockchain/TEPs/pull/89)
- **title**: Discoverable Jettons Wallets
- **status**: Draft
- **type**: Contract Interface
- **authors**: [EmelyanenkoK](https://github.com/EmelyanenkoK)
- **created**: 08.09.2022
- **replaces**: -
- **replaced by**: -

# Summary

This proposal suggest to extend standard Jetton master by adding mandatory onchain `get_wallet_address` handler.

# Motivation

Some application may want to be able to discover their or other contract wallets for some specific Jetton Master. For instance some contract may want to obtain and store it's jetton wallet for some Jetton to handle transfer notifications from it in specific way.

# Guide

Upon receiving `get_wallet_address` message with address in question, Jetton Master should response with message containing address.

# Specification

## New Jetton Master contracts
Jettom Master should handle message

`get_wallet_address#418cbb4e query_id:uint64 owner_address:MsgAddress include_address:Bool = InternalMsgBody;`

with TON amount higher than `5000 gas-units + msg_forward_prices.lump_price + msg_forward_prices.cell_price` = 0.0061 TON for current basechain settings (if amount is less than that it is not possible to send response) attached

and either throw an exception if amount of incoming value is not enough to calculate wallet address or
response with message (sent with mode 64)

`report_wallet_address#ad30f94a query_id:uint64 wallet_address:MsgAddress owner_address:(Maybe ^MsgAddress) = InternalMsgBody;`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider naming report_wallet_address return_wallet_address, because report has the context of marking an entity as malicious etc.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other potential terms instead of "report" are "return" / "query" / "get"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently we mimic names used in NFT for get_static_data.
I don't like return/query naming because I think it will looks a little bit counterintuitive to implement "return_wallet_address" method on recipient side to actually handle the response.
What about a take_static_data? Alternatively we can just use get_static_data op-code with high-bit set to true (to emphasize it is response), however we doesn't have TL-B notation for that.
Anyway, I don't think that this issue is important and any decision will work ok.

Copy link

@sasha1618 sasha1618 Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We realised that op should represent the operation that a receiver should execute.

With that in mind the best way to name our ops is: provide_wallet_address and take_wallet_address.

  • Smart-contract sends op:provide_wallet_address
  • Discoverable minter receives op:provide_wallet_address and sends op:take_wallet_address
  • Smart-contract receives op:take_wallet_address and handles the message


Note: if it is not possible to generate wallet address for address in question (for instance wrong workchain) `wallet_address` in `report_wallet_address` should be equal to `addr_none`. If `include_address` is set to `True`, `report_wallet_address` should include `owner_address` equal to `owner_address` in request (in other words response contains both owner address and associated jetton wallet address).

## Already existing Jetton Master contracts

Jettons with non-upgradable Jetton Master may spawn separate smart-contract (Jetton discovery) which implements this functionality. In this case pair of contracts (Jetton Master + Jetton Discovery) will behave the same way as new Jetton Master. For non-upgradable Jetton Master with updatable metadata it is recommended to add "wallet-discovery" key with value equal to text representaion of Jetton Discovery contract address.

## Scheme:
```
get_wallet_address query_id:uint64 owner_address:MsgAddress include_address:Bool = InternalMsgBody;
report_wallet_address query_id:uint64 wallet_address:MsgAddress owner_address:(Maybe ^MsgAddress) = InternalMsgBody;
```

```
crc32('get_wallet_address query_id:uint64 owner_address:MsgAddress include_address:Bool = InternalMsgBody') = 418cbb4e
crc32('report_wallet_address query_id:uint64 wallet_address:MsgAddress owner_address:Maybe ^MsgAddress = InternalMsgBody') = ad30f94a
```

# Drawbacks

If new applications start to heavily rely on these proposal without supporting separate Jetton Master/Jetton Discovery they may not be able to process already existing jettons.

# Rationale and alternatives

Currently it is expected that decentralised applications will work with specific wallets not with Jetton Masters. However sometimes it makes logic more complicated (especially if it is desired to create predictable contract addresses) or less straightforward for user-side checks.

# Prior art

-

# Unresolved questions

It is not possible to distinguish Jetton Discovery which consume higher than expected fee from non-Jetton Discovery contract.

# Future possibilities

-