【发布时间】:2021-11-07 17:13:10
【问题描述】:
我可以使用 web3.js 发送 SOL 令牌,但无法使用 USDC-SPL 令牌发送。这是我当前发送 SOL 令牌的代码:
// .......
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);
}
// .......
我之前看到的答案来自发送自己定制令牌的人
【问题讨论】:
标签: solana