[0:00]Earlier this year, online payments changed forever, and you probably didn't even notice. Every internet user has heard of the HTTP status code 404 not found. But if you're a web developer, you might have nightmares about status code 500 internal server error, which happens when your shotty deployed code breaks in production. But there's one HTTP status code that's just been sitting there since 1997, waiting for its moment to shine. 402 payment required. It was reserved for future use back when the web was young and optimistic, but now three decades later, we're still figuring out how to handle money on the internet without giving platforms like Stripe a 3% cut for the privilege of pressing some buttons. Well, that's about to change thanks to a new protocol developed by Coinbase called X402. that enables micropayments that can turn every API request into a tiny cash register with zero fees. And what's especially crazy is that these payments are instantaneous, frictionless, and open the door for machine-to-machine payments. Like imagine an entire A economy where AI agents are paying other AI agents to do whatever AI agents do. What could possibly go wrong? In today's video, we'll find out by taking a closer look at X402 and its promise to revolutionize the way money moves on the internet. It is November 26, 2025, and you're watching the Code Report. One thing that sucks about platforms like Stripe is that they charge a 30 cent fee per transaction, which makes them overly complex for certain use cases. Like if you have an API where you charge one penny per request, you'd be running at a negative 3,000% profit margin. That's not acceptable even by Silicon Valley standards, so the solution is to force users to authenticate with OAuth, verify a credit card, then either buy subscriptions or credits on your platform for a higher dollar amount, and then replenish them when they run out. It's complicated, but X402 dramatically simplifies this workflow. In fact, it only takes one line of middleware code in Node.js to get up and running. If a buyer makes a request to a paid API endpoint, the server responds with an HTTP 402 code, which means a payment is required to complete the request. The user would then see a page like this asking them to connect a wallet, at which point the transaction can be completed without subscriptions, authentication, or any other friction. In addition, the process can be done programmatically on the buyer side, using hand-written code or even AI agents. Pretty cool, but now let's actually deploy our own monetized API from scratch. Before doing that, though, we need a reliable backend server to run our code, like Hostinger, the sponsor of today's video. Their virtual private servers give you the power and flexibility to run whatever you want without locking you in to someone else's platform. And for less than 10 bucks a month, you get a respectable two CPUs and 8 gigabytes of RAM. And right now, you can save a ton of money with their Black Friday deal, and then save even more money after that by stacking it with the Fireship discount code. In this demo, we'll build both client and server apps, so I'm choosing a Docker VPS. What's especially awesome about this VPS is its Docker Compose manager, where you can deploy, run, and monitor multiple apps with a highly efficient, streamlined interface, which is provided free of charge from Hostinger. But now that we have a server lined up, let's take a look at the code. Here I have a dead simple Node.js app using Hono to build a restful API. When someone navigates to this protected route, it will give them some highly secret esoteric knowledge only known to 33rd degree freemasons. This knowledge is so valuable that we must require a payment of exactly one Bitcoin to access it. Although with X402, you can handle payments of less than one cent and use stable coins like USDC. Right now, anybody can access this route, but we can change that by simply installing the X402 SDK from NPM. Most importantly, it contains a middleware function that will put a paywall in front of this route. The first argument to this function is your wallet address where the funds will be sent. Then the second argument contains an object with some configuration values. Like the route you want to protect, the price, the amount of time allowed to complete the purchase, and the decentralized network that will handle the transaction. And as a seller, that's basically all there is to it. If we now open up the app on localhost as a potential customer and hit that URL, we get a 402 response that will require us to make a payment. In a web app, the end user can use a wallet extension like Metamask or Coinbase wallet to complete the transaction. Then once that's complete, they'll receive a response with the knowledge of a 33rd degree Freemason. That's cool and all, but buyers can also make payments programmatically. If we go back to the code, we can use the X402 fetch library, which can do all sorts of things, including handle the payment request automatically. And that's pretty awesome if you're building a paid API where AI agents can access paid resources on someone else's behalf. And now we can deploy everything together by dockerizing it, pushing it to GitHub, and then let our Hostinger VPS run it in production. I'm not sure I'm ready to let AI make live payments for me, but hey, at least when it drains my bank account, it'll do it efficiently. Huge thanks to Hostinger for sponsoring, and make sure to lock in the discount while there's still time. This has been the Code Report. Thanks for watching, and I will see you in the next one.
Transcript source
YouTube auto captions
This transcript was extracted from YouTube's auto-generated caption track. The transcript below is server-rendered so it can be read, searched, cited, and shared without opening the original YouTube player.
Pull quotes
[0:00]Earlier this year, online payments changed forever, and you probably didn't even notice.
[0:00]But if you're a web developer, you might have nightmares about status code 500 internal server error, which happens when your shotty deployed code breaks in production.
[0:00]But there's one HTTP status code that's just been sitting there since 1997, waiting for its moment to shine.
[0:00]Well, that's about to change thanks to a new protocol developed by Coinbase called X402.
Use this transcript
Related transcript hubs
Watch on YouTube
Share
MORE TRANSCRIPTS



