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

Support indexing xUDT #508

Closed
Keith-CY opened this issue Dec 28, 2023 · 7 comments
Closed

Support indexing xUDT #508

Keith-CY opened this issue Dec 28, 2023 · 7 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@Keith-CY
Copy link
Member

Document of xUDT: https://blog.cryptape.com/enhance-sudts-programmability-with-xudt#heading-xudt-cell

Use case of xUDT: https://omiga-core.notion.site/Omiga-Inscritption-885f9073c1a6499db08f5815b7de20d7

How to index an xUDT cell:

xUDT script info

| code hash | 0x25c29dc317811a6f6f3985a7a9ebc4838bd388d19d0feeecf0bcd60f6c0975bb |
| hash type | type |
| dep type | code |

If a cell has a type script in which the code hash and hash type match values above, it's an xUDT cell

How to display an xUDT

It depends on the business logic. In the use case of Omiga, an xUDT should be treated as an inscription, and displayed with inscription info as max supply, total supply, mint limit

@Keith-CY Keith-CY added the documentation Improvements or additions to documentation label Dec 28, 2023
@Keith-CY
Copy link
Member Author

Please prioritize this because Omiga is expected to be online next week

@Keith-CY
Copy link
Member Author

@Keith-CY
Copy link
Member Author

How to index Omiga cells

Indexing inscription info

The inscription info is a cell containing specific type script and data fields

The type script refer to inscription info contract in cell deps by

code_hash: type script of inscription info contract
hash_type: type
args: type id

So a inscription info cell can be located by the specific code_hash & hash_type

Once the cell is located, the inscription info can be parsed from its cell data with schema

// general
decimal u8
len u8
name variable max 255
len u8
symbol variable max 255

udt_hash 32bytes
// extra
expected_supply 16bytes
mint_limit 16bytes
mint_status u8

Indexing inscription cells

Each inscription cell is actually a cell containing a specific type script, the data structure of type script is as follows

code_hash: xUDT type_hash
hash_type: type
args: owner_script_hash

The code_hash and hash type are determined by xUDT script, so the key matter is the owner script hash, which is the hash of a virtual script owner script existing in the witness field with format as follows

code_hash: type hash of Omiga Inscription 
hash_type: type
args: type hash of Inscription_Info

Once the inscription info is detected, inscription cells can be located by their witnesses.

Steps are as follows

  1. If the cell is an xUDT cell, it's possibly an Omiga inscription cell;
  2. If the cell is generated with a witness, and hash of witness is equal to its type_script.args, it's possibly an Omiga inscription cell;
  3. If the witness is an owner lock, which means, the code_hash is type hash of Omiga Inscription contract, hash_type is type, it's an Omiga inscription cell;
  4. The inscription info could be located by owner_lock.args. It's expected to be synced before the inscription cell is found.

@Keith-CY
Copy link
Member Author

General operations of Omiga inscription could be found at https://github.com/duanyytop/joyid-omiga/tree/master/src/inscription

@Sven-TBD
Copy link
Contributor

Sven-TBD commented Jan 1, 2024

PRD here.
We can check and develop it this week.

@zmcNotafraid zmcNotafraid self-assigned this Jan 2, 2024
@Sven-TBD
Copy link
Contributor

Sven-TBD commented Jan 4, 2024

This whole feature should be split into some independent small features, which are :

And the way how to update these features is list here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Archived in project
Development

No branches or pull requests

4 participants