import "solana";import "./spl_token_minter.sol";function transferTokensFromUserToContract(address user, uint256 amount, address signerAccount) internal { uint64 amount64 = uint64(amount); AccountMeta[3] metas = [ AccountMeta({pubkey: user, is_writable: false, is_signer: false}), // User's token account AccountMeta({pubkey: contractTokenAccount, is_writable: false, is_signer: false}), // Contract's token account AccountMeta({pubkey: signerAccount, is_writable: true, is_signer: true}) // SplTokenMinter program ]; spl_token_minter.transferTokens{accounts: metas}( amount64 ); }
Trying to transfer token in my Solidity Smart contract via CPI call(creating and importing the interface generated of the spl file https://solang.readthedocs.io/en/v0.3.3/targets/solana.html#calling-anchor-programs-from-solidity as stated in official docs )in anchor, all but the token balances are unchanged.Token Transfer function implemented in spltokenMinter file:
@mutableAccount(from) // token account to transfer from @mutableAccount(to) // token account to transfer to @mutableSigner(owner) function transferTokens( uint64 amount // amount to transfer ) external { print("inside the transfer token function"); SplToken.transfer( tx.accounts.from.key, tx.accounts.to.key, tx.accounts.owner.key, amount ); }