0

Im using javascript and i have the mint address of a token, for example this "Ei71196o8MpDsVdXyZEewEdxP4A8n3KMZKTFE7KE2xTR" and i want to get the name which in this case is Sillybird and the symbol which is SIB. I have searched throught here and only found 1 @solana\web3.js example which didnt give me the name nor symbol, and some metaplex examples that didnt work at all. I would appreciate any help

1 Answer 1

1

I think using DAS is the best way. You can use Helius to do this. You will need to get a free API key by signing up, then paste it in the "API Key" part.

(async () => {
    const response = await fetch('https://mainnet.helius-rpc.com/?api-key=<API Key>', {
        method: 'POST',
        headers: {
            "Content-Type": "application/json"
        },
        body: JSON.stringify({
            "jsonrpc": "2.0",
            "id": "text",
            "method": "getAsset",
            "params": { id: 'Ei71196o8MpDsVdXyZEewEdxP4A8n3KMZKTFE7KE2xTR'}
        }),
    });
    const data = await response.json();
    console.log(`name = ${data.result.content.metadata.name}`);
    console.log(`symbol = ${data.result.content.metadata.symbol}`);
})();

Result:

name = Sillybird
symbol = SIB


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.