I want to display tokens from user wallet when he connectes on website, and then he can convert all his tokens into a single token
1 Answer
If you want to fetch all token accounts owned by a wallet, you can use the getTokenAccountsByOwner
RPC call:
curl https://api.devnet.solana.com -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenAccountsByOwner",
"params": [
"4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F",
{
"mint": "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E"
},
{
"encoding": "jsonParsed"
}
]
}
'
Copied from https://solana.com/docs/rpc/http/gettokenaccountsbyowner