We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
func Test_getMintName_GMT(t *testing.T) { mintName, erc := getMintName(context.TODO(), caseSolana.client2, "7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx", "unknown") require.Nil(t, erc) t.Log(mintName) } func getMintName(ctx context.Context, client *client.Client, mintAddress string, defaultName string) (string, *cerror.CError) { metadata, ok, erc := getMintMeta(ctx, client, mintAddress) if erc != nil { return "", erc } if !ok { return defaultName, nil } return metadata.Data.Symbol, nil } func getMintMeta(ctx context.Context, client *client.Client, mintAddress string) (*token_metadata.Metadata, bool, *cerror.CError) { meta, err := token_metadata.GetTokenMetaPubkey(common.PublicKeyFromString(mintAddress)) if err != nil { return nil, false, cerror.NewError(cerror.CODE_THIRD_REQ_ERROR, "获得 token meta 错误") } res, err := client.GetAccountInfo(ctx, meta.ToBase58()) if err != nil { return nil, false, cerror.NewError(cerror.CODE_THIRD_REQ_ERROR, "获得 account 信息错误") } if res.Data == nil { return nil, false, nil } metadata, err := token_metadata.MetadataDeserialize(res.Data) if err != nil { return nil, false, cerror.NewError(cerror.CODE_THIRD_REQ_ERROR, "解析 metadata 错误", err.Error()) } return &metadata, true, nil }
The text was updated successfully, but these errors were encountered:
curl 'https://api.solscan.io/token/meta?token=7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx&cluster=' \ -H 'authority: api.solscan.io' \ -H 'accept: application/json, text/plain, */*' \ -H 'accept-language: zh,zh-CN;q=0.9' \ -H 'if-none-match: W/"118-Fo0YcKx0NxCVMD0HmXG5Yx3H1mM"' \ -H 'origin: https://solscan.io' \ -H 'referer: https://solscan.io/' \ -H 'sec-ch-ua: "Not/A)Brand";v="99", "Google Chrome";v="115", "Chromium";v="115"' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'sec-ch-ua-platform: "macOS"' \ -H 'sec-fetch-dest: empty' \ -H 'sec-fetch-mode: cors' \ -H 'sec-fetch-site: same-site' \ -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36' \ --compressed {"succcess":true,"data":{"symbol":"GMT","address":"7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx","name":"GMT","icon":"https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx/logo.png","decimals":9,"holder":392134}}%
Sorry, something went wrong.
you can check https://github.com/solana-labs/token-list/blob/main/src/tokens/solana.tokenlist.json if you can't get a metadata from a mint.
thank you! you are the best go developer. very nice.
No branches or pull requests
The text was updated successfully, but these errors were encountered: