I'm able to send SOL tokens using web3.js but have been unable to do so with USDC-SPL tokens. This is my current code for sending SOL tokens:
// .......
const connection = new Connection(network);
const transaction = new Transaction()
.add(
SystemProgram.transfer({
fromPubkey: publicKey,
toPubkey: to,
lamports: Number(amount) * 1000000000,
})
);
const { blockhash } = await connection.getRecentBlockhash();
transaction.recentBlockhash = blockhash;
transaction.feePayer = publicKey;
let signedTransaction: any = null;
if ("solana" in window) {
signedTransaction = await window.solana.signTransaction(transaction)
} else if ("solflare" in window) {
signedTransaction = await window.solflare.signTransaction(transaction);
}
// .......
The answers I've seen earlier are from people sending their own custom made tokens