FuelLabs / fuel-indexer

🗃 The Fuel indexer is a standalone service that can be used to index various components of the Fuel blockchain.
https://docs.fuel.network/docs/indexer/
140 stars 66 forks source link

The global indexing of the minted and burned tokens #1012

Open xgreenx opened 1 year ago

xgreenx commented 1 year ago

This issue first requires finishing the https://github.com/FuelLabs/fuel-vm/issues/496.

With an upcoming feature that allows minting multi assets per contract, it is crucial for the indexer to create Mapping AssetId -> (ContractId, AssetSubId). The ability to find the mother contract for the asset by its AssetId should be a prevalent request and has many use cases in the business logic.

Besides that, with a new fuel_tx::Receipt::Mint and fuel_tx::Receipt::Burn, the indexer also can track the total amount of each asset. It could be useful later to track that bringing of assets is done correctly(the amount of specific asset in the Fuel Network is equal to the amount of bridged tokens).

ra0x3 commented 1 year ago

@deekerno Any more work to do here after #1205 ?

deekerno commented 12 months ago

There doesn't seem to be any additional work needed, but I want to make sure that I understand this correctly.

If we just want a record of every asset that has been burned or minted on the network, we could create an indexer for that fairly easily and people can make requests to that for information.

In contrast, if instead we want that information to be available to any and every indexer, we would have to process the mint/burn receipts at the same time that we process blocks so that information could be stored in the database and an indexer could make use of that.

@xgreenx, can you provide some examples of how you envision this being used?

xgreenx commented 12 months ago

The primary use case is to find what contract owns the asset and may mint/burn it. Without this information, it is impossible to work with fungible and non-fungible tokens because you can't use methods defined in the standard(you don't know which contract you need to call).

Any project that requires this kind of information can indeed create its own indexer. But it seems to me that everyone wants access to this information.

If you are okay with tracking those receipts, could you also track the supply?=)