惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
博客园_首页
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
小众软件
小众软件
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
有赞技术团队
有赞技术团队
WordPress大学
WordPress大学
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
V
V2EX
酷 壳 – CoolShell
酷 壳 – CoolShell
IT之家
IT之家
量子位
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Recent Announcements
Recent Announcements
M
MIT News - Artificial intelligence
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How Solana Transactions Are Different from REST API Calls...
Lymah · 2026-05-10 · via DEV Community

The Problem: Your Mental Model Is Broken

You know how to build APIs. You understand request/response cycles. You know that a successful POST returns 200 OK, and a failed request returns 400 Bad Request. You've never been charged for a 400.

Solana transactions will break every one of those assumptions.

Last week, I sent a transaction that failed due to insufficient funds. The validator still charged me a fee. A 400 Bad Request just cost me real money. That's when I realized: I was thinking about blockchain like it was an API, and it's not.

In this post, I'm going to show you exactly how Solana transactions work, how they differ from REST APIs, and why understanding those differences will make you a better blockchain developer.

Web2: Request/Response

Here's how you think about HTTP today:

POST /transfer
{
  "recipient": "alice",
  "amount": 100
}

→ Process on server
→ Return result

200 OK: Transfer succeeded
400 Bad Request: Invalid amount
401 Unauthorized: Not authenticated

Enter fullscreen mode Exit fullscreen mode

Key properties:

  • Stateless (each request is independent)
  • Synchronous (you wait for a response)
  • Validated on the server
  • Failed requests are free (no charge for 400s)
  • No signature needed (the server trusts TLS)

Web3: Signed State Transitions

Solana transactions are fundamentally different. They're not requests to a server. They're cryptographically signed instructions to change on-chain state.

// Build a transaction
const transaction = new Transaction({
  recentBlockhash: blockhash,
  feePayer: sender.publicKey
});

// Add an instruction
transaction.add(
  SystemProgram.transfer({
    fromPubkey: sender.publicKey,
    toPubkey: recipient,
    lamports: amount
  })
);

// Sign with private key
transaction.sign(sender);

// Send to network
const signature = await connection.sendRawTransaction(
  transaction.serialize()
);

Enter fullscreen mode Exit fullscreen mode

Key differences:

  • Stateful (changes on-chain state)
  • Asynchronous (sign locally, then wait for validators)
  • Validated by the network
  • Failed transactions still cost fees
  • Must be signed by the payer's private key

The Fee Problem

Here's the biggest shock: you pay whether the transaction succeeds or fails.

I tried to transfer 3.20 SOL with only 2.20 SOL balance. On an API, that would be a 400:

POST /transfer
400: Insufficient funds
Cost: $0.00

Enter fullscreen mode Exit fullscreen mode

On Solana:

solana transfer 2iHFnuzv... 3.2
Error: Insufficient lamports (need 3.2, have 2.2)
Cost: 0.000005 SOL (~$0.0000005 on mainnet)

Enter fullscreen mode Exit fullscreen mode

I got charged for a transaction that didn't execute.

Why? Because validators did work to process my transaction. They:

  1. Deserialized the signed bytes
  2. Loaded accounts from storage
  3. Executed the System Program instruction
  4. Checked preconditions (balance, signatures, etc.)
  5. Determined it would fail and rejected it

All of that costs compute resources. So they charge a fee. It's economically rational, and it's completely different from REST APIs.

The Three Commitment Levels

With HTTP, you get one response: 200 or error. Solana has three.

When I send a transaction, it moves through these stages:

1. Processed (~400ms)

A validator included my transaction in a recent block.

Waiting for processed... Transaction processed by validator

Enter fullscreen mode Exit fullscreen mode

What it means: A single validator saw your transaction. Not yet secured by consensus.
Risk level: High (1-2% chance it gets forked away)

2. Confirmed (~800ms)

66%+ of validators voted on the block containing my transaction.

Waiting for confirmation from supermajority... Transaction confirmed by network

Enter fullscreen mode Exit fullscreen mode

What it means: Network consensus. You won. It's almost impossible to reverse.
Risk level: Extremely low (no confirmed transaction has ever been reversed in Solana's history)

3. Finalized (~12s)

At least 31 additional confirmed blocks built on top.

Waiting for finalized... Transaction finalized

Enter fullscreen mode Exit fullscreen mode

What it means: Irreversible. Like a database commit that's replicated to disk and backed up.
Risk level: Zero

Compare this to HTTP where you get one response:

HTTP 200 OK immediately
↑
Done. State changed.

Enter fullscreen mode Exit fullscreen mode

Solana transactions are multi-stage. Different applications wait at different levels:

  • Fast-paced DEX? Wait for "confirmed" (~800ms)
  • Payment processor? Wait for "finalized" (~12s)
  • Bridge operation? Wait for even more finalization

Real Code: I Built This

Here's my transfer tool. I send 0.01 SOL to a recipient:

$ node transfer.mjs 6SSAKkUGpyuB2dg81L4d8USfXjpnUXPX6qwif7bcQKwc 0.01

============================================================
  Solana Transfer Tool
============================================================

Connected to Solana devnet
   RPC: https://api.devnet.solana.com

Checking balance...
   Balance: 2.253960000 SOL

Amount: 0.01 SOL (10,000,000 lamports)

Building transaction...
Signing transaction...
Sending to network...
Waiting for processed... Transaction processed by validator

Waiting for confirmation from supermajority... Transaction confirmed by network

Waiting for finalized... Transaction finalized

Transaction successful!

Signature: 4MNtSnAcA2JL3CgwrVqBAoqyhQVpnvog8LKc65MNjKaroTZDj8F8UhpieMnWRLhV6juAbvMypHP92YnaguRmbNGc

View on Solana Explorer:
https://explorer.solana.com/tx/4MNtSnAcA2JL3CgwrVqBAoqyhQVpnvog8LKc65MNjKaroTZDj8F8UhpieMnWRLhV6juAbvMypHP92YnaguRmbNGc?cluster=devnet

Final balance: 2.23895 SOL

Enter fullscreen mode Exit fullscreen mode

This is the Solana equivalent of an HTTP POST. But look at the differences:

  • I sign the transaction with my private key (HTTP just uses TLS)
  • I wait through three commitment stages (HTTP returns immediately)
  • I get a signature instead of a 200 OK (signatures prove finality)
  • I can view the transaction on a public explorer (no such thing in Web2)

The Secret Weapon: Simulation

Remember how I said failed transactions cost fees?

There's a way around it: simulation.

Before you send a transaction, ask the network: "If I send this, what would happen?"

The network runs your transaction in a sandbox. If it would fail, it tells you. And you don't pay.

// Simulate first (costs nothing)
const simulation = await connection.simulateTransaction(unsignedTx);

if (simulation.value.err) {
  console.log("Would fail:", simulation.value.err);
  // Don't send - you just saved a fee!
} else {
  // Safe to send
  const sig = await connection.sendTransaction(tx);
}

Enter fullscreen mode Exit fullscreen mode

This is the production pattern. Professional Solana apps always simulate before sending. It saves fees and catches errors early.

Mental Model: From Request/Response to State Transitions

Here's how I had to rethink things:

Before (HTTP Thinking)

1. Craft a request
2. Send it
3. Wait for response
4. Response tells me if it worked
5. If it failed, no penalty

Enter fullscreen mode Exit fullscreen mode

After (Solana Thinking)

1. Build a signed transaction (cryptographic proof)
2. Simulate it (does it work? costs nothing)
3. Send it (if simulation passed)
4. Wait through three commitment stages (processed → confirmed → finalized)
5. If it fails, I still paid the fee (even in a sandbox!)

Enter fullscreen mode Exit fullscreen mode

The key shift: You're not making a request to a server. You're proposing a signed change to global state that thousands of validators must agree on.

Why This Matters

Understanding these differences makes you a better blockchain developer because:

  1. You'll design better error handling

    • Can't just check for 200 vs 400
    • Must handle async multi-stage confirmations
    • Must implement retry logic for transient failures
  2. You'll write more efficient code

    • Simulate before sending (saves fees)
    • Batch multiple operations in one transaction
    • Choose the right commitment level for your use case
  3. You'll make economically rational decisions

    • Every transaction has a cost
    • Failed transactions cost the same as successful ones
    • This changes how you architect systems
  4. You'll understand why certain constraints exist

    • 1,232 byte transaction size limit (fits in UDP)
    • ~90 second blockhash window (network state needs to be fresh)
    • Fee charges for failure (validates work done by validators)

The Takeaway

REST APIs lied to you. They made state changes feel free and instantaneous. Solana is honest about it: changing state is work, it takes time, and you pay for it whether it succeeds or fails.

That honesty is uncomfortable at first. But it makes you a better engineer. You start thinking about:

  • What operations are actually necessary?
  • How can I batch work to minimize fees?
  • What happens if this fails?

These are the questions that lead to well-designed systems.

If you're coming from Web2 and feeling lost in blockchain development, this mental shift is everything. Once you stop thinking of transactions as API calls and start thinking of them as cryptographically signed state changes that require network consensus, everything else clicks into place.

Want to experiment? Try building a Solana transfer tool yourself. You'll hit the same realizations I did, and that's where real learning happens.

Further reading: