I have the following scenario:
- Wallet A: Sender = Contains some SOL and Tokens
- Wallet B: Receiver = Only contains SOL (for rent)
- Wallet C: Fee-Payer = Only contains SOL
What I’m trying to do is pretty straight-forward: Send some Tokens from Wallet A to Wallet B, while Wallet C pays for the fees.
I’m using the SOLNET
.NET Library to use the Solana RPC.
This is the Code that creates and sends the transaction:
“` public static string GetTokenWallet(string publicKey) => AssociatedTokenAccountProgram.DeriveAssociatedTokenAccount(new PublicKey(publicKey), TOKEN_MINT);
public static async Task SendTokenAsync(Account fromAccount, string to, ulong amount) { PublicKey fromTokenKey = new(GetTokenWallet(fromAccount.PublicKey)); PublicKey toTokenKey = new(GetTokenWallet(to));
RequestResult<ResponseValue> blockHashResult = await rpc.GetLatestBlockHashAsync(); string blockHash = blockHashResult.Result.Value.Blockhash; TransactionInstruction instruction = TokenProgram.Transfer( source: fromTokenKey, destination: toTokenKey, amount: amount * 1_000_000, authority: fromAccount.PublicKey, signers: [fromAccount]); byte[] transaction = new TransactionBuilder() .SetRecentBlockHash(blockHash) .SetFeePayer(feePayer) .AddInstruction(instruction) .Build([fromAccount, feePayer]); RequestResult<ResponseValue> logResult = await rpc.SimulateTransactionAsync(transaction); if (!logResult.WasSuccessful) return null; RequestResult result = await rpc.SendTransactionAsync(transaction); return result.Result;
} “`
The Simulation is successful. When I send the actual transaction though, it fails with the message Transaction signature verification failure
.
Am I signing it wrong or something? I sign it with both the Sender and Fee-Payer accounts, so I thought that should do the trick.
submitted by /u/speyck
[link] [comments]
Join The SmashBotAI Telegram Community Now! Get trade alerts, smashable token trade ideas, and more!
https://t.me/smashbotcommunity
Start Trading Now:
SmashBotAI Telegram Bot