getProgramAccounts (15ms p50 for top dexes) & getTransactionsForAddress (signatures and transaction data in a single call). Unlock Now!In this post, we are going to generate a simple transaction and then sign it on Solana Blockchain.

There are 2 ways in which you can sign a Solana transaction:
We have deployed a small project to test out transaction signing while working with Shyft APIs. Try it out here: https://shyft-insider.vercel.app/
In this tutorial, we will cover how to sign transactions automatically without having to approve every time through a wallet.
Join Medium for free to get updates from this writer.
We will create a simple transaction instruction to transfer some SOL from account A to B. Then sign it using a code snippet.
A = GE4kh5FsCDWeJfqLsKx7zC9ijkqKpCuYQxh8FYBiTJe
B = AaYFExyZuMHbJHzjimKyQBAH1yfA9sKTxSzBc6Nr5X4s
Below is the code to generate simple transfer instructions to transfer 1 SOL, on devnet:
import {
clusterApiUrl,
Keypair,
PublicKey,
SystemProgram,
Transaction,
} from '@solana/web3.js';
async createTransferInstruction() : Promise<any> {
const fromPubKey = new PublicKey('GE4kh5FsCDWeJfqLsKx7zC9ijkqKpCuYQxh8FYBiTJe');
const tx = new Transaction().add(SystemProgram.transfer({
fromPubkey: fromPubKey,
/** Account that will receive transferred lamports */
toPubkey: new PublicKey('AaYFExyZuMHbJHzjimKyQBAH1yfA9sKTxSzBc6Nr5X4s'),
/** Amount of lamports to transfer */
lamports: 100000000,
}));
const connection = new Connection(clusterApiUrl("devnet"), 'confirmed');
const blockHash = (await connection.getLatestBlockhash('finalized')).blockhash;
tx.feePayer = fromPubKey;
tx.recentBlockhash = blockHash;
const serializedTransaction = tx.serialize({ requireAllSignatures: false, verifySignatures: true });
const transactionBase64 = serializedTransaction.toString('base64');
return {
encoded_transaction: transactionBase64
};
}
The above code snippet returns base64 the encoded version of the transaction.
Now, let’s come to the second part where we take the response from the above function, sign, and send this transaction into the blockchain. Along with the encodedTransaction string from the previous function, this function also needs private_key the sender to successfully sign the transaction. The sender’s private key is needed because while creating the transaction above we assigned them fromPubKey as the tx.feePayer.
import { clusterApiUrl, Keypair, Transaction } from '@solana/web3.js';
async signTransaction(encodedTransaction: string, fromPrivateKey: string) : Promise<any> {
try {
const connection = new Connection(clusterApiUrl("devnet"), 'confirmed');
const feePayer = Keypair.fromSecretKey(decode(fromPrivateKey));
const recoveredTransaction = Transaction.from(Buffer.from(encodedTransaction, 'base64'));
recoveredTransaction.partialSign(feePayer);
const txnSignature = await connection.sendRawTransaction(
recoveredTransaction.serialize(),
);
return txnSignature;
} catch (error) {
console.log(error);
}
}
The above function signs and sends the transaction to Solana’s devnet and return the transaction signature.
You can use the code for the above 2 functions to create a backend API to transfer SOL. This can be achieved by exposing the first function via API call, which returns the encodedTransaction. You can put the code in the second function on your client-side or FE. So that, your users never have to pass their private keys over the network.
Hope this is useful. Happy hacking.

A closer look at gPA’s two-phase scan architecture, benchmarked against a standard Solana RPC node. getProgramAcco...
July 17, 2026

A deep dive into why standard RPC nodes struggle with getProgramAccounts, and how a dedicated accounts engine built on R...
June 5, 2026

In this article you will learn how to implement a reconnect logic for your Solana gRPC streams with replay functionality...
January 24, 2026
Get in touch with our discord community and keep up with the latest feature
releases. Get help from our developers who are always here to help you take off.