1

I am currently learning the basics of programming in solana using the different json functions and I have a question

Is there a function that gives you the contract of a token having only the address of a holder?

I have tried with functions like

GetToken, GetTransactionList

and none of them worked

The most I have achieved is obtaining the Raydium liquidity pool contract. and an address called: associated token account program, which I don't even know what exactly is

Are there functions that I don't know about that will give me what I want? I would greatly appreciate the help thanks

1 Answer 1

2

Every token on Solana is currently deployed with one of two different programs:

  • Token Program: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
  • Token-2022/Token Extensions program: TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb

What you're asking for is "how can I find the mint address of a token given a specific token account?"

Given a token account 3JpjbbqkGQEwedw7ZHcV3E2cxWrTAbuJeiWiTXW7USTq, you can find the mint by querying the account:

curl --location --request POST 'https://api.mainnet-beta.solana.com' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getAccountInfo",
    "params": [
        "3JpjbbqkGQEwedw7ZHcV3E2cxWrTAbuJeiWiTXW7USTq",
        {
            "encoding": "jsonParsed"
        }
    ]
}'

Response:

{
    "jsonrpc": "2.0",
    "result": {
        "context": {
            "apiVersion": "1.17.21",
            "slot": 254055034
        },
        "value": {
            "data": {
                "parsed": {
                    "info": {
                        "isNative": false,
                        "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
                        "owner": "NjordRPSzFs8XQUKMjGrhPcmGo9yfC9HP3VHmh8xZpZ",
                        "state": "initialized",
                        "tokenAmount": {
                            "amount": "212674332017",
                            "decimals": 6,
                            "uiAmount": 212674.332017,
                            "uiAmountString": "212674.332017"
                        }
                    },
                    "type": "account"
                },
                "program": "spl-token",
                "space": 165
            },
            "executable": false,
            "lamports": 2039280,
            "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
            "rentEpoch": 18446744073709551615,
            "space": 165
        }
    },
    "id": 1
}

You can see from this getAccountInfo RPC API call, the mint is EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v. Doing a lookup on the mint address, you'll find it is USDC.

1
  • Thanks for the response but I'm not sure that's what I'm looking for. Let's say I have this wallet 8UMwVssuymUiZ7EpMjFpyVew3ddReri2CjPSDJaNhW4g that recently made a swap in raydium for JUP, is there a way to get the contract to buy JUP through that wallet? In the tests that I am doing I get all kinds of contracts and addresses but not the contract to buy the token and I think that either I have to use other functions or there is something that I am missing or probably both haha
    – lea
    Commented Mar 14 at 5:53

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.