tokenregistry

package
v2.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: BSD-2-Clause Imports: 6 Imported by: 0

README

Nibiru/token-registry

This directory implements the Nibiru Token Registry by providing a means to register offchain digital token metadata to onchain identifiers for use with applications like wallets.

Generation Script

The command to generate files from the Nibiru Token Registry is

just gen-token-registry

If you don't have the just command, run this first.

cargo install just

This produces several files:

  • dist/cosmos-assetlist.json: An external JSON file for use inside the cosmos/chain-registry GitHub repo.
  • token-registry/official_erc20s.json: Verified ERC20s for the Nibiru web app
  • token-registry/official_bank_coins.json: Bank Coins in the Nibiru web app

official_erc20s.json

This file maintains a registry of known ERC20 tokens. It's intended for use in the Nibiru web application and the Nibiru Indexer that provides data on tokens and token balances.

Fields of the official_erc20s.json configuration file
  • contractAddr: ERC20 smart contract address of the token
  • displayName: Concise display name of the token. Example: "Wrapped Ether".
  • symbol: Symbol, or ticker, of the digital asset.
    Example: "ETH", "NIBI"
  • decimals: The number of decimal places, or power of 10, that is used for the display unit of the token. Said more concretely, the smallest unit of the token, "base unit", is such that 1 TOKEN == 10^{decimals} base units.
    • Example: NIBI has 6 decimals. This means the base unit seen onchain is 10^{-6} NIBI.
    • Example: ETH has 18 decimals. This means the base unit of ETH is 10^{-18} ether.
  • logoSrc: GitHub static asset link for the logo image that will often appear inside a circular frame.
    Example: "raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/0000_nibiru.png"
  • priceInfo: (Optional)

Related Ticket: https://github.com/NibiruChain/go-heartmonitor/issues/378

Exporting for the cosmos/chain-registry

  1. Run the generation script (just gen-token-registry)
  2. Copy or move the "dist/cosmos-assetlist.json" file to replace "nibiru/assetlist.json" in the "cosmos/chain-registry" repo.

Documentation

Index

Constants

View Source
const (
	SAVE_PATH_OFFICIAL_ERC20S     = "token-registry/official_erc20s.json"
	SAVE_PATH_OFFICIAL_BANK_COINS = "token-registry/official_bank_coins.json"
)

Variables

This section is empty.

Functions

func FindRootPath added in v2.2.0

func FindRootPath() (string, error)

FindRootPath returns the absolute path of the repository root This is retrievable with: go list -m -f {{.Dir}}

func GitHubImageToLocal added in v2.2.0

func GitHubImageToLocal(githubURL string) string

GitHubImageToLocal converts a GitHub raw image URL into a local image path.

func IsGitHubImage added in v2.2.0

func IsGitHubImage(maybeGitHub *string) bool

IsGitHubImage returns true if an image URI is a GitHub raw URL from the NibiruChain/nibiru repository.

func IsLocalImage added in v2.2.0

func IsLocalImage(maybeLocal *string) bool

IsLocalImage returns true if an image URI is meant for a local file in the "token-registry/img" directory.

func LocalImageToGitHub added in v2.2.0

func LocalImageToGitHub(local string) string

LocalImageToGitHub converts a path to a local image into a GitHub download link in the NibiruChain/nibiru repository.

func ParseOfficialSaveBz added in v2.2.0

func ParseOfficialSaveBz(tokens []TokenOfficial) ([]byte, error)

func PointImagesToCosmosChainRegistry

func PointImagesToCosmosChainRegistry(assetListJson []byte) (out []byte)

Types

type AssetImage

type AssetImage struct {
	Png       *string     `json:"png,omitempty"`
	Svg       *string     `json:"svg,omitempty"`
	Theme     *ImageTheme `json:"theme,omitempty"`
	ImageSync *ImageSync  `json:"image_sync,omitempty"`
}

func (AssetImage) GitHubify

func (ai AssetImage) GitHubify() AssetImage

GitHubify replaces local image paths with GitHub raw URLs.

Example: "./img/token.png" → "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/token.png"

func (AssetImage) GitHubifyReverse added in v2.2.0

func (ai AssetImage) GitHubifyReverse() AssetImage

GitHubifyReverse replaces GitHub raw URLs with local image paths.

Example: "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/token.png" → "./img/token.png"

type AssetList

type AssetList struct {
	Schema    string  `json:"$schema"`
	ChainName string  `json:"chain_name"`
	Assets    []Token `json:"assets"`
}

func NibiruAssetList

func NibiruAssetList() AssetList

func (AssetList) String

func (a AssetList) String() string

String returns a "pretty" JSON version of the AssetList.

type Counterparty

type Counterparty struct {
	// Name of the counterparty chain
	ChainName string `json:"chain_name"`
	// Base denomination on the counterparty chain
	BaseDenom string `json:"base_denom"`
	// Channel ID used for communication (optional)
	ChannelID *string `json:"channel_id,omitempty"`
}

Counterparty represents the counterparty information for an asset trace.

type DenomUnit

type DenomUnit struct {
	Denom    string   `json:"denom"`
	Exponent int      `json:"exponent"`
	Aliases  []string `json:"aliases,omitempty"`
}

type ImageSync

type ImageSync struct {
	// Name of the chain associated with the image
	ChainName string `json:"chain_name"`
	// Base denomination of the synced asset
	BaseDenom string `json:"base_denom"`
}

ImageSync represents synchronization details for cross-chain assets.

type ImageTheme

type ImageTheme struct {
	// Whether the image should appear in a circular format (optional)
	Circle *bool `json:"circle,omitempty"`
	// Primary color in hexadecimal format (optional)
	PrimaryColorHex *string `json:"primary_color_hex,omitempty"`
}

ImageTheme represents theme customization for an image.

type LogoURIs

type LogoURIs struct {
	Png *string `json:"png,omitempty"`
	Svg *string `json:"svg,omitempty"`
}

func (LogoURIs) GitHubify

func (logouris LogoURIs) GitHubify() *LogoURIs

GitHubify replaces local image paths with GitHub raw URLs.

Example: "./img/token.png" → "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/token.png"

func (LogoURIs) GitHubifyReverse added in v2.2.0

func (logouris LogoURIs) GitHubifyReverse() *LogoURIs

GitHubifyReverse replaces GitHub raw URLs with local image paths.

Example: "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/token.png" → "./img/token.png"

type PriceInfo added in v2.2.0

type PriceInfo struct {
	// "source" identifies where to get the USD price
	Source string `json:"source"`
	// "priceId" is key used to fetch the price data from the given source.
	PriceId string `json:"priceId"`
}
type SocialLinks struct {
	Website *string `json:"website,omitempty"`
	Twitter *string `json:"twitter,omitempty"`
}

type Token

type Token struct {
	// The human-readable name of the asset
	Name string `json:"name"`
	// A short description of the asset
	Description string `json:"description"`
	// Contract address for the token. Required for [TypeAsset] "erc20" and "cw20".
	Address *string `json:"address,omitempty"`
	// An extended, detailed description of the asset (optional)
	ExtendedDescription *string `json:"extended_description,omitempty"`
	// Links to social platforms and official websites (optional)
	Socials *SocialLinks `json:"socials,omitempty"`
	// Units of denomination for the asset
	DenomUnits []DenomUnit `json:"denom_units"`
	// The base denomination for the asset (canonical name)
	Base string `json:"base"`
	// The display name or symbol used in UI for the asset
	Display string `json:"display"`
	// The ticker or symbol of the asset
	Symbol string `json:"symbol"`
	// URIs for the asset's logo in different formats (optional)
	LogoURIs *LogoURIs `json:"logo_URIs,omitempty"`
	// Unique identifier for the asset on Coingecko (optional)
	CoingeckoID *string `json:"coingecko_id,omitempty"`
	// An array of image representations for the asset (optional)
	Images []AssetImage `json:"images,omitempty"`
	// Type of the asset (e.g., "sdk.coin", "ics20", "erc20")
	TypeAsset TypeAsset `json:"type_asset"`
	// Trace data for the asset (optional, for cross-chain or liquid staking assets)
	Traces []Trace `json:"traces,omitempty"`
}

func TOKENS

func TOKENS() []Token

func (Token) GitHubify

func (t Token) GitHubify() Token

GitHubify replaces local image paths with GitHub raw URLs.

Example: "./img/token.png" → "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/token.png"

func (Token) GitHubifyReverse added in v2.2.0

func (t Token) GitHubifyReverse() Token

GitHubifyReverse replaces GitHub raw URLs with local image paths.

Example: "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/token.png" → "./img/token.png"

type TokenOfficial added in v2.2.0

type TokenOfficial struct {
	ContractAddr string     `json:"contractAddr"`
	DisplayName  string     `json:"displayName"`
	Symbol       string     `json:"symbol"`
	LogoSrc      string     `json:"logoSrc"`
	PriceInfo    *PriceInfo `json:"priceInfo,omitempty"`
}

func LoadBankCoins added in v2.5.0

func LoadBankCoins() ([]TokenOfficial, error)

func LoadERC20s added in v2.5.0

func LoadERC20s() (tokens []TokenOfficial, err error)

func (*TokenOfficial) GitHubify added in v2.2.0

func (to *TokenOfficial) GitHubify() *TokenOfficial

type Trace

type Trace struct {
	// Type of trace (e.g., "ibc", "liquid-stake", "wrapped", "bridge")
	Type TraceType `json:"type"`
	// Counterparty information for the trace
	Counterparty Counterparty `json:"counterparty"`
	// Provider of the asset for liquid staking or cross-chain trace (optional)
	Provider *string `json:"provider,omitempty"`
	// Additional chain-level details (optional)
	Chain *TraceChainInfo `json:"chain,omitempty"`
}

Trace represents trace data for cross-chain or liquid staking assets.

type TraceChainInfo

type TraceChainInfo struct {
	// Channel ID on the chain
	ChannelID string `json:"channel_id"`
	// Path used for asset transfer on the chain
	Path string `json:"path"`
}

TraceChainInfo represents additional chain-level details for an asset trace.

type TraceType

type TraceType string

TraceType is an enum type for "trace.type" (e.g. "ibc", "liquid-stake", "wrapped", "bridge")

const (
	TraceType_IBC         TraceType = "ibc"
	TraceType_LiquidStake TraceType = "liquid-stake"
	TraceType_Wrapped     TraceType = "wrapped"
	TraceType_Bridge      TraceType = "bridge"
)

type TypeAsset

type TypeAsset string

TypeAsset is an enum type for "type_asset". Valid values include "sdk.coin", "ics20", and "erc20". See Examples.

const (
	TypeAsset_SDKCoin TypeAsset = "sdk.coin"
	TypeAsset_ICS20   TypeAsset = "ics20"
	TypeAsset_ERC20   TypeAsset = "erc20"
	TypeAsset_CW20    TypeAsset = "cw20"
)

Directories

Path Synopsis
/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL