I have been trying to transfer custom SPL tokens using @Solana\web3.js and am having issues with the instruction creation. I created the instruction using the Token.createTransferInstruction method but when the instruction is created, my wallet receives all the information added except the amount of tokens I want to send. P.S. I also added the recent blockhash and set the feepayer so those shouldn't be of issue.
var transaction = new web3.Transaction().add(
splToken.Token.createTransferInstruction(
splToken.TOKEN_PROGRAM_ID,
fromTokenAcc.address,
toTokenAcc.address,
sender,
[],
1
)
)
As seen above, I use the right parameters to my knowledge but when I send the transaction to my wallet, the amount doesn't get transferred.
I was going to add direct images but StackOverflow said I need at least 10 rep to post images, sorry about that :/
https://i.stack.imgur.com/ucDAt.png
I've also looked into the transfer data that the instruction adds to the transaction and it uses the 3 for transfer instruction but is the 1 where it should be for amount?
https://i.stack.imgur.com/uRSVS.png
Any help would be much appreciated. Thank You!
Solana USDC is a SPL-Token like other non-native token too,Here is how you transfer an existing spl-token already on the blockchain using the latest version of solana/web3.js and spl-token;