Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pls help me, how to get token metadata? #190

Open
SyugamCan opened this issue Apr 4, 2024 · 1 comment
Open

Pls help me, how to get token metadata? #190

SyugamCan opened this issue Apr 4, 2024 · 1 comment

Comments

@SyugamCan
Copy link

meta, err := tokenregistry.GetTokenRegistryEntry(context.Background(), client, mintAddress)
token: 2bjao38z4hUC1wY5yQiDhRF43TjLoBpyPSQhsikhCBEr
and err is "not found"
i guess we should interact withMetaplex
is there any new func to get meta?

@0xvbetsun
Copy link

yes @SyugamCan, you are right. It's better to take a look at this repo

to get at least something you can use the next script

package main

import (
	"context"

	"github.com/davecgh/go-spew/spew"
	"github.com/gagliardetto/solana-go"
	"github.com/gagliardetto/solana-go/programs/token"
	"github.com/gagliardetto/solana-go/rpc"
)

func main() {
	mintKey := solana.MPK("2bjao38z4hUC1wY5yQiDhRF43TjLoBpyPSQhsikhCBEr")

	client := rpc.New(rpc.MainNetBeta.RPC)

	var mint token.Mint
	client.GetAccountDataInto(context.TODO(), mintKey, &mint)

	metadataPDA, _, err := solana.FindTokenMetadataAddress(mintKey)
	if err != nil {
		panic(err)
	}

	spew.Dump(mint)
	spew.Dump(metadataPDA)
}

Output:

(token.Mint) {
 MintAuthority: (*solana.PublicKey)(<nil>),
 Supply: (uint64) 999935143218046,
 Decimals: (uint8) 6,
 IsInitialized: (bool) true,
 FreezeAuthority: (*solana.PublicKey)(<nil>)
}
(solana.PublicKey) (len=32 cap=32) GJvLsXpLttda51tBR2bFU3wd8AoJULNgjybwxAkFVUWx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants