Native Tokens
Native tokens on ZIGChain are created using the Token Factory module, which allows any account or smart contract to create new tokens in a permissionless manner. These tokens follow the format coin.{creator_address}.{subdenom} and are namespaced by the creator's address to ensure unique denominations.
Token Factory Overview
The Token Factory module enables:
- Permissionless token creation by any account or smart contract
- Unique denomination format:
coin.{creator_address}.{subdenom} - Admin privileges for token creators (bank admin and metadata admin)
- Full control over token behavior and metadata
How OroSwap Fetches Native Token Information
Token Metadata Source
OroSwap retrieves native token information from the on-chain metadata stored in the token's denomination metadata, which includes:
- Creation fields: subdenom, minting cap, URI, URIHash
- Metadata fields: description, symbol, name, display, denom units
Icon Fetching Process
- URI Retrieval: The system fetches the URI from the on-chain metadata
- JSON Processing:
- The URI must point to a JSON file containing token metadata
- The system extracts the image URL from the
iconfield within the JSON
Token Information Retrieved
- Symbol: Token symbol for display
- Exponent: Decimal precision from DenomUnits
- Icon: Token icon/logo from URI metadata
- Display: Display denomination
- Base: Base denomination (exponent = 0)
Token Metadata Structure
Here's an example of a real native token metadata structure:
{
"metadata": {
"description": "testtoken",
"denom_units": [
{
"denom": "coin.zig1k73kxytnf8d4cuxxhgyff54ap04ryu8rv0sz3v.testtoken",
"aliases": ["testtoken"]
},
{
"denom": "testtoken",
"exponent": 6
}
],
"base": "coin.zig1k73kxytnf8d4cuxxhgyff54ap04ryu8rv0sz3v.testtoken",
"display": "testtoken",
"name": "testtoken",
"symbol": "test",
"uri": "https://memesfun.mypinata.cloud/ipfs/bafkreiaahqlo6p4n6sr5taxoqwd4cqympxpwfb3pir5jwyaybdimd5pjky",
"uri_hash": "58a5e173316e32e48e3606ad4efb8b37bd5d7bc3c3ad7e525d6dba6c290b691f"
}
}
Key Components Explained:
- Base Denom:
coin.zig1k73kxytnf8d4cuxxhgyff54ap04ryu8rv0sz3v.testtoken(exponent = 0) - Display Denom:
testtoken(exponent = 6, used for UI display) - Symbol:
test(short symbol for trading pairs, used for UI display) - URI: Points to a JSON file containing icon URI and additional token information
- URI Hash: SHA-256 hash verifying metadata integrity
URI Metadata Structure
The URI points to a JSON file containing additional token information. Here's the structure of the metadata file:
{
"name": "test",
"description": "TestToken is a cutting-edge cryptocurrency designed for experimentation and innovation. With its versatile use cases and robust technology, TestToken is set to revolutionize the way we test new blockchain solutions. Join the future of testing with TestToken.",
"icon": "https://memesfun.mypinata.cloud/ipfs/bafybeibxxmqkbrqtbdp5c5g3kvyrjzd5apkjuc263crafy2l27merwm7gi",
"twitter": "",
"telegram": "",
"website": ""
}
Icon Field Usage
The icon field in the URI metadata is the primary source for the token logo:
- Icon URL: Contains the direct link to the token's logo image
- Logo Fetching: OroSwap extracts this URL to display the token icon in the UI
- Format Support: Supports various image formats (PNG, SVG, JPG, etc.)
- IPFS Integration: Often hosted on IPFS for decentralized storage
- Fallback: If the icon field is empty or invalid, OroSwap may use a default placeholder
This structure allows token creators to provide rich metadata including logos, descriptions, and social links while maintaining the integrity of the on-chain URI hash.
Update Denomination URI
To update the URI and URIHash of a native token:
Steps to Update denom URI of native tokens: ZIGChain Factory Documentation - Update Denom URI
Update Full Metadata
Token admins can update complete metadata including:
- Description, symbol, name, display
- DenomUnits and exponents
- URI and URIHash
Example
When a user interacts with a native token like coin.zig1k73kxytnf8d4cuxxhgyff54ap04ryu8rv0sz3v.testtoken, OroSwap:
- Queries the blockchain for the token's denomination metadata
- Extracts the URI from the metadata (
https://memesfun.mypinata.cloud/ipfs/bafkreiaahqlo6p4n6sr5taxoqwd4cqympxpwfb3pir5jwyaybdimd5pjky) - Fetches the logo from the IPFS metadata (either directly or from JSON metadata)
- Displays the token with:
- Symbol:
test - Display name:
testtoken - Decimal precision: 6 (from exponent)
- Logo from IPFS metadata
- Symbol:
This ensures that all native tokens display correctly with their official branding and metadata across the OroSwap interface.
Additional Resources
For detailed information about token creation, naming constraints, URIHash generation, and admin operations, refer to the official ZIGChain documentation: