Sui apps often need to fetch CoinMetadata objects, which determine how coin amounts get displayed to the user, because they contain info like the coin decimals, ticker, and logo.
While CoinMetadata objects can be fetched from a Sui RPC with SuiClient.getCoinMetadata(), this has drawbacks that can lead to bad UX:
- If your app needs metadata for many coin types, it will make an RPC request for each of them, which is slow.
- The coin logo is often missing from CoinMetadata. And the image may be huge, or stored in a slow web server.
What is CoinMeta 🪙 and how does it help?
Simple, it provides pre-fetched CoinMetadata for Sui coins, and web-optimized logos.
The top 60+ coins on Sui were selected and pre-fetched. The logos are served from CloudFlare, compressed and resized, so they load quickly in your app.
If your app needs a CoinMetadata that's not already pre-fetched, CoinMeta falls back to SuiClient.getCoinMetadata(), and caches the response.
How to use it?
You can access the data in different ways:
- In plain JS/TS, the @ polymedia/coinmeta package provides the helper functions getCoinMeta() and getCoinMetas()
- In React apps, the @ polymedia/coinmeta-react package provides the React hooks useCoinMeta() and useCoinMetas()
- You can also fetch all data with a REST API request