Token Hub

Token Hub provides listings of all existing token types on Gno.land - GRC20 tokens, GRC721 NFTs, and GRC1155 multi-tokens. You can browse these listings to find available tokens, check balances, and access token metadata. If you're developing wallets or interfaces, you can query this registry to display token information to your users.

How to Register Your Tokens

You can register your tokens with the following import and function calls:

 1// Import packages
 2import (
 3	"gno.land/r/matijamarjanovic/tokenhub"
 4	"gno.land/p/demo/grc/grc20"
 5	"gno.land/p/demo/grc/grc721"
 6	"gno.land/p/demo/grc/grc1155"
 7)
 8
 9// GRC20 token
10myToken, myLedger := grc20.NewToken("My Token", "MTK", 6)
11myTokenPath := tokenhub.RegisterToken(myToken.Getter(), "my_token")
12
13// GRC721 NFT
14myNFT := grc721.NewBasicNFT("My NFT Collection", "MNFT")
15myNFT.Mint("g1your_address_here", "1")
16err := tokenhub.RegisterNFT(myNFT.Getter(), "my_collection", "1")
17
18// GRC1155 multi-token
19myMultiToken := grc1155.NewBasicGRC1155Token("https://metadata.example.com/")
20myMultiToken.SafeMint("g1your_address_here", "123", 10)
21err := tokenhub.RegisterMultiToken(myMultiToken.Getter(), "123")

Querying Token Information

You can query token information and balances using functions like:

1// Get all registered tokens
2allTokens := tokenhub.GetAllTokens()
3
4// Get token balances for a user
5balances := tokenhub.GetUserTokenBalances("g1...")
6
7// Get non-zero token balances
8nonZeroBalances := tokenhub.GetUserTokenBalancesNonZero("g1...")