ThisCalculator

Everyday

Verify Solana Transaction Offline Before Signing

Updated · Standard formula, shown below

This guide walks you through verifying a Solana transaction offline before signing it, a critical step for anyone using an air-gapped wallet or hardware wallet. You’ll learn how to decode the transaction details, confirm the recipient, amount, and fees, and then sign it safely without exposing your private key to a connected device.

What You’ll Need

  • A Solana wallet that supports offline signing (e.g., Phantom, Solflare, or a hardware wallet like Ledger).
  • The transaction data (base58-encoded message) that you intend to sign, usually provided by a dApp or a trusted source.
  • A way to decode the transaction—either a command-line tool like solana CLI or an online decoder (use one that you trust and that works offline if possible).
  • Access to the Solana network’s current fee parameters (if you want to verify fees) and the account’s recent blockhash (if you want to check freshness).

Step-by-Step

  1. Obtain the transaction message. The transaction you need to sign is usually presented as a base58-encoded string (often starting with a few characters that look like a Solana address). Copy it exactly. For example, from a dApp you might see a prompt like “Sign this transaction: 5Uu...xyz“—copy that entire string.
  2. Decode the transaction. Use the Solana CLI or an offline decoder to parse the message. With the CLI installed, run: solana transaction decode <base58-string>. This will output a JSON representation of the transaction, including the instructions, accounts, and signatures (if any). If you don’t have the CLI, you can use an online tool like the Solana Explorer’s “Transaction Inspector” (but be aware that pasting a transaction online may leak metadata; for sensitive transactions, prefer offline tools).
  3. Verify the recipient and amount. Look at the decoded instructions. For a simple SOL transfer, you’ll see a Transfer instruction with from and to accounts. Confirm the to address matches the intended recipient exactly. For SPL token transfers, the instruction will be Transfer within the Token program; check the amount field (in base units, e.g., lamports for SOL, or the token’s smallest unit). Convert to human-readable units if needed (1 SOL = 1,000,000,000 lamports).
  4. Check the fee. The decoded transaction will show a fee field (in lamports). This is the network fee that will be deducted from the signer’s account. Verify it is reasonable (typically a few thousand lamports, but it can vary with network congestion). If the fee seems unusually high, it might be a sign of a malicious transaction.
  5. Verify the recent blockhash. The transaction includes a recent_blockhash. This ensures the transaction is fresh and prevents replay attacks. Check that this blockhash is recent—you can compare it with the current blockhash from a trusted source (e.g., the Solana CLI’s solana blockhash command). If the blockhash is old (more than a few minutes), the transaction may be rejected or could be a replay attempt.
  6. Review all instructions. For complex transactions (e.g., interacting with a DeFi protocol), the decoded JSON will list multiple instructions. Examine each one: what program is being called, what accounts are involved, and what data is passed. Ensure you understand the effect of each instruction. If anything looks unexpected (e.g., an extra transfer to an unknown address), do not sign.
  7. Sign the transaction offline. Once you’ve verified the details, use your offline wallet to sign the transaction. For a hardware wallet, connect it to a computer that is not connected to the internet (or use a wallet that supports offline signing). For a software wallet, you can use a signing tool that works offline, such as the Solana CLI with a keypair file on an air-gapped machine. The signing process will produce a signature that you can then attach to the transaction.
  8. Broadcast the signed transaction. After signing, you’ll have a fully signed transaction. You can then broadcast it to the network using a connected device. This step does not require your private key, only the signed transaction data.

Common Mistakes

  • Not verifying the recipient address character-by-character. A single typo can send funds to the wrong address. Always double-check, especially the first few and last few characters.
  • Ignoring the fee. Some malicious transactions might include an exorbitant fee that drains your account. Always verify the fee is within the normal range.
  • Signing without checking the recent blockhash. An old blockhash can cause the transaction to be invalid or be replayed, leading to unexpected outcomes.
  • Assuming all instructions are benign. A transaction might look like a simple transfer but actually contains a hidden instruction that approves a token spend or changes account ownership. Review every instruction.
  • Using an online decoder for sensitive transactions. Pasting a transaction into a web tool can leak metadata (like your IP address) and potentially expose the transaction to third parties. For high-value transactions, use offline tools.

Tips

  • Use a dedicated offline machine. If you frequently sign transactions offline, set up a computer that never connects to the internet. Install the Solana CLI and your wallet software there.
  • Cross-verify with a second source. If possible, decode the transaction using two different tools (e.g., CLI and a trusted online explorer) and compare the outputs. This reduces the risk of a compromised decoder.
  • Understand SPL token transfers. For tokens, the amount is often in the token’s smallest unit (e.g., 6 decimals for USDC). Make sure you convert correctly to know how much you’re actually sending.
  • Keep your signing key secure. The whole point of offline signing is to keep your private key away from the internet. Never enter your key on a connected device.
  • Test with a small amount first. If you’re new to offline signing, practice with a small transaction to ensure you understand the process before handling larger amounts.

Troubleshooting

  • Decoding fails. If the CLI or decoder throws an error, the base58 string might be corrupted or truncated. Double-check that you copied the entire string. Also ensure you’re using the correct CLI version that supports the transaction format.
  • The transaction shows an unexpected error. If the decoded transaction has a status of “error” or “failed,” it might be because the blockhash is expired or the accounts don’t have sufficient funds. Check the blockhash and account balances.
  • You see more instructions than expected. Some dApps include extra instructions for fees or routing. This is normal, but you must understand each one. If you don’t recognize an instruction, search for the program ID to see what it does.
  • Your hardware wallet doesn’t show the details. Some hardware wallets only display a hash of the transaction, not the full details. In that case, you must verify the transaction on your computer before confirming on the device. Never confirm a transaction on your hardware wallet unless you’ve verified it elsewhere.
  • The fee seems too high. If the fee is higher than expected, it could be due to network congestion. Check the current fee rate (e.g., via solana fees). If the fee is abnormally high, it might be a malicious transaction—do not sign.

Frequently Asked Questions

Can I verify a transaction without a CLI?

Yes, you can use online tools like the Solana Explorer’s transaction inspector, but be cautious about privacy. For maximum security, use an offline decoder or a trusted open-source tool.

How do I know if a transaction is a simple SOL transfer?

Look for an instruction with program ID 11111111111111111111111111111111 (the system program) and instruction type Transfer. It will have from and to fields.

What is a recent blockhash and why does it matter?

A recent blockhash is a recent hash of a Solana block that is included in the transaction to prevent replay attacks. If it’s too old, the network will reject the transaction.

Can I sign a transaction without a hardware wallet?

Yes, you can use an air-gapped computer with the Solana CLI and a keypair file. The keypair must never be on a connected device.

What if the decoded transaction shows an amount in lamports?

Lamports are the smallest unit of SOL (1 SOL = 1,000,000,000 lamports). For SPL tokens, the amount is in the token’s smallest unit, which varies by token (e.g., 6 decimals for USDC).

Is it safe to use an online decoder for a small transaction?

It’s generally safe for small amounts, but it’s a good habit to use offline tools for all transactions to protect your privacy and reduce the risk of phishing.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.