Guide
Gasless Transactions with Lazorkit
This guide shows how to send SOL on Solana without the user paying gas using Lazorkit’s passkey-based wallets.
We’ll create a transaction, sign it with useWallet(), and let Lazorkit + Kora handle the fees.
This guide assumes you’ve completed Creating Passkey-Based Wallets with Lazorkit.
Step 1 — How Gasless Transactions Work
Lazorkit exposes a signAndSendTransaction method via the useWallet() hook.
- Builds the transaction
- Signs it using passkeys
- Uses Kora as the gas paymaster
- Submits the transaction to Solana
No seed phrases. No gas popups. No wallet extensions.
Step 2 — Create the Transaction Handler
In your page or component file, create a function that builds and sends the transaction.
code
import { useWallet } from "@lazorkit/wallet";
import { PublicKey, SystemProgram, LAMPORTS_PER_SOL } from "@solana/web3.js";
import { useState } from "react";
export function useGaslessTransfer() {
const {
signAndSendTransaction,
vaultPubkey,
isSigning,
isConnected,
} = useWallet();
const [status, setStatus] = useState<"idle" | "success" | "error">("idle");
const sendSol = async (recipient: string, amount: string) => {
if (!vaultPubkey || !recipient || !amount) return;
try {
setStatus("idle");
const recipientPubkey = new PublicKey(recipient);
const lamports = parseFloat(amount) * LAMPORTS_PER_SOL;
if (isNaN(lamports) || lamports <= 0) {
throw new Error("Invalid amount");
}
const instruction = SystemProgram.transfer({
fromPubkey: vaultPubkey,
toPubkey: recipientPubkey,
lamports,
});
await signAndSendTransaction({
instructions: [instruction],
transactionOptions: {
clusterSimulation: "devnet",
},
});
setStatus("success");
} catch (err) {
console.error(err);
setStatus("error");
}
};
return { sendSol, status, isSigning, isConnected };
}Step 3 — Build the Transfer UI
Attach the handler to a simple form so users can send SOL.
code
import { useState } from "react";
import { useGaslessTransfer } from "./useGaslessTransfer";
export default function TransferForm() {
const [recipient, setRecipient] = useState("");
const [amount, setAmount] = useState("");
const { sendSol, status, isSigning, isConnected } = useGaslessTransfer();
if (!isConnected) return null;
return (
<div className="border border-gray-300 p-6 rounded-md mt-6">
<label className="block text-sm mb-2">Recipient Address</label>
<input
className="w-full border px-3 py-2 mb-4 text-sm font-mono"
value={recipient}
onChange={(e) => setRecipient(e.target.value)}
/>
<label className="block text-sm mb-2">Amount (SOL)</label>
<input
type="number"
className="w-full border px-3 py-2 mb-4 text-sm"
value={amount}
onChange={(e) => setAmount(e.target.value)}
/>
<button
onClick={() => sendSol(recipient, amount)}
disabled={isSigning}
className="w-full bg-black text-white py-3 rounded-md text-sm"
>
{isSigning ? "Sending..." : "Send SOL"}
</button>
{status === "success" && (
<p className="text-green-600 text-sm mt-4 text-center">
Transaction successful 🎉
</p>
)}
</div>
);
}Common mistakes:
- Passing SOL instead of lamports
- Not checking wallet connection
- Forgetting
clusterSimulation: "devnet" - Sending from
smartWalletPubkeyinstead ofvaultPubkey(the vault holds the funds) - Starting a second send before the first resolves.
isSigningstaystrueuntil the transaction is confirmed, and another send is refused with "Already signing"
What You Just Built
- Gasless SOL transfers
- Passkey-based signing
- No wallet extensions required
- Fully compatible with devnet
You now have a production-ready gasless transaction flow.