How can my website know in users wallet from which token account the token is for it to be transferred?
How can my website know in users wallet from which token account the token is for it to be transferred?
Loading saved threads...
Yellow Wolf · External communityPost link
External question — Solana Stack Exchange
Author: Yellow Wolf
Original post: https://solana.stackexchange.com/questions/24509
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Hey guys so I am making a website where user can click deposit and after some fee the amount gets deposited to a global pda. But when my server passes the msg how can we knew which token account to transfer usdc from? As the user isn't the one sending it themselves know they might be much technical, in this case how can we transfer usdc out from a token account we don't know exists?
Quote
Report
Jimii · External communityPost link
External answer — Solana Stack Exchange
Author: Jimii
Original post: https://solana.stackexchange.com/a/24512
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
how can we transfer usdc out from a token account we don't know exists?
You can use the
getAccountInfo
RPC call to check if the token account exists or not
import { address, createSolanaRpc } from "@solana/kit";
const rpc_url = "https://api.devnet.solana.com";
const rpc = createSolanaRpc(rpc_url);
const publicKey = address("vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg");
const accountInfo = await rpc.getAccountInfo(publicKey).send();
console.log("Account Info:", accountInfo);
ref:
https://solana.com/docs/rpc/http/getaccountinfo
how can we knew which token account to transfer usdc from
I thinnk for this you can create an account that tracks the amount whose seed is the depositor's address
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External answer — Solana Stack Exchange Author: Jimii Source score (net votes, not local likes): 0 Original post: https://solana.stackexchange.com/a/24512 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. how can we transfer usdc out from a token account we don't know exists? You can use the getAccountInfo RPC call to check if the token account exists or not import { address, createSolanaRpc } from "@solana/kit"; const rpc_url = "https://api.devnet.solana.com"; const rpc = createSolanaRpc(rpc_url); const publicKey = address("vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"); const accountInfo = await rpc.getAccountInfo(publicKey).send(); console.log("Account Info:", accountInfo); ref: https://solana.com/docs/rpc/http/getaccountinfo how can we knew which token account to transfer usdc from I thinnk for this you can create an account that tracks the amount whose seed is the depositor's address
Checking account access…