Building an x402 AI Agent: Autonomous payments with Cloudflare Workers

Devcon 8 · 5 Nov 2026 · 47:02

Haruki Kondo, a blockchain engineer who runs the UNCHAIN Web3 developer education community in Japan and is an AWS Community Builder, leads a hands-on workshop on x402, the payment protocol built on the HTTP 402 Payment Required status. Participants follow a GitHub guide to build and run a facilitator and resource server locally, deploy them with an MCP server to Cloudflare Workers, and let an AI agent in Claude Code pay for a protected weather API in USDC on the Arc testnet. The closing summary suggests trying other chains and tokens.

Speakers

Topics

From Devcon 8, hosted by Ethereum Foundation.

Transcript

Sure. [music] [music] >> Oh okay. Uh GM everyone thank you for uh joining this workshop. So uh you can find a GitHub repository uh uh today's workshop uh repository here and uh free uh for you to get start early and uh I will show you uh Q this QR code uh later uh when uh Wi-Fi is written. Yeah. Okay. Uh so uh first uh let me introduce myself.

My name is uh Haruki Kondo. Uh I'm a software engineer from Japan and uh I'm a community lead on chain. Uh it's Japanese uh blockchain engineer community and I'm a AI AWS community builder uh AI engineer category and uh I also uh love joining hackathons like uh is a global. Yep. So uh let's start uh today's uh workshop lecture. Uh today uh we build our AI agents that can pay for APIs automatically using exposure 2. Uh we deployed uh our service to cloud worker uh MCP server

resource server and a facilitator. Yeah. And uh then uh we'll use a cloud code and uh MCP server to make a payment and get from a protected API. So uh today's workshop uh we build our own our facilitator. Why uh build our own facilitator? Uh this uh will help us understand how payment verification and onchain settlement work. So we are not just uh using explorer 2. We are learning how it works inside.

So uh let me show you demo. Uh this is uh today's workshop goal. Okay. Uh first uh we are uh test in uh local laptop uh start uh facilitator and resource server and uh execution [snorts] uh uh execu execute uh exposure to uh test script. It looks like uh success uh exposure to settlement and get uh get data from a pro protected API.

uh please a moment uh okay it's successed and uh next check uh on block explorer and next uh we uh deployed uh MCP server uh resource server uh facilitator to crowd via worker and uh call uh call from uh cloud code uh via MCP server uh with uh national language.

Okay. Uh first uh check what status in this workshop uh we using uh wallet as a uh preb API and uh we uh uh sorry okay uh just a moment. first uh approve uh allowance to uh preview wallet uh to use uh USDC. And next uh uh get data from uh resource server.

Uh Okay. Okay. Okay. Okay. Uh first uh approved a success and next uh uh play set uh settlement success and get uh get data from uh protect API. Yeah. Sunny uh it's uh get uh weather information. Yeah. And uh in this workshop uh the I prepare uh three uh prompt two success pattern and uh one uh

fire pattern. Yeah. Okay. It looks like uh work well. Okay. Uh this is our final uh today's uh workshop goal. workshop and uh I'll show you a later again uh this workshop uh im uh image uh client uh crowd code and preview API and mgp server resource server f data uh all of deployed uh crowd workers and use uh uh

use a blockchain as uh as a arctet and uh to use uh USC to settlement. [snorts] Okay. [snorts] Yeah. Uh by the end of workshop uh you'll understand the exposure to payment flow. Uh you'll also learn how to deploy the system to cloud code uh crowd flare and customize the chain and token settings like [snorts] uh uh another chain uh monado uh optimism and uh not USDC uh using uh like a JPY uh eur.

Okay. Uh next uh let's talk about uh exposure 2. Uh as you know uh exposure 2 is a payment protocol based on HTTP uh which means payment requirements. It allows a agent to pay uh for APIs automatically using blockchain settlement. And there are four key components client is server facilitator and blockchain. The client requests data. The source server uh uh we uh we uh server protects the data and a facet data uh verify and settles payments and blockchain records

the payments. Uh this is uh how to uh exposure to payment work. Uh first the client send up a request to server. The server respond with HTTP uh 402 and payment requires requirement. Next uh client sign the payment and send another request. Then uh the facilitator uh verify and payment uh and process the settlement. Finally the server returns the requested data for example uh uh weather information.

That's the basic exposure to uh flow. Okay. So, uh All right. Let's start uh for hands on workshop. Uh Wi-Fi it is already returned. Uh oh. Oh, okay. Thank you. So uh if uh Wi-Fi returns uh you'll uh scan uh this code uh QR code and access uh today's workshop GitHub and folk and cry uh Chrome uh to your own uh local laptop and uh uh you read uh workshop

guide it's uh full of markdown and Uh if you have any question or run into uh any issues, please let me know. Uh I go there. Why wait? Okay. So, some of you might have like um

mobile internet on your phone and open able to open the instructions. How many is that? Oh, the majority. How many of you rely only on the Wi-Fi and are now waiting for it to come up? A few people. Did you know does your phone have eim? Did you know that there's a free eim for all conference attendees? So, you can go to the there's a link in the schedule somewhere. I found it. I don't remember where, but uh it's advertising Okay. So, seems we got the Wi-Fi back

now, but let me finish the sentence. So there's a beat refill ad somewhere in the in the app and if you follow that and install their app you'll get a free eim for 3 GB in India just to let you know but seems we have uh the Wi-Fi back now so everyone can use All right. Also, if you have any

questions, you can use the ask a question feature in the schedule. Uh you can also use this ask a question if you're participating remotely to this workshop. And if you're in person, you I guess you could also raise your hand if you want uh Harooi to to come and help you with something. Mine says it's temporarily full.

>> Oh, okay. Okay. I will provide you the three multiple separate scan. You can scan this. >> So, he works as a volunteer. >> Okay. >> So, get access to the >> Okay. >> supporter. Even you can spend this. >> For what? He's a volunteer. >> Oh, >> right now it's not in ship. So, he's attending the session.

>> Oh, there's a water connected. Let's do another quick show of hands.

How many of you managed to open the website and got access to the GitHub repository? Uh, anyone who did not get to the GitHub repository yet? No hands. Oh, great. So, everyone got started. Cool. So I just double checked where the

[snorts] EIM is. So if you go to Devcon website and go to the Mumbai travel guide and scroll down then at the bottom of the page there's a section with Bit Refill and other sponsors. And in the bit refill, you can click on a link which will take you to the app store and install it. And when when you open the app, it will detect that you came through that link and give you a free 3 GB eM. H

>> yeah just answer and I will mark them as >> ah okay uh thank you uh questions uh uh yeah uh thank you for question uh about my workshop uh I uh answered uh answered uh some question uh so please check it uh QA page and Yeah, >> just to clarify the preview here is the same as >> ah yes yes yes. This is the same. Yes, yes. Maybe uh same as I take preview and

>> the dependency question. Ah yes and uh uh you you have to uh run uh long run uh command uh in repositories root uh directory. Uh yes this this directory uh in this directory uh you should uh run PNB install and uh all uh dependency depend uh uh installed. Yep.

And ah okay. uh this command uh because uh this uh workshop repository uh uh monoro uh all packages in uh packages uh directory client config uh facilitator mcgp server and uh resource server or all of uh all all source code in this uh directory And uh [snorts] so uh you just uh run uh root directory uh PNP install uh all uh depend depending dependency uh

installed. Yeah, just one uh PNP installed. >> Can you show the front page of the repository? Oh, page. Okay. Okay. Okay. >> Yeah. And then scroll down to show the read me. >> Okay. >> So, you want people to click on this one right?

>> Oh, yes. Yes. Yes. Oh, sorry. Uh this this is uh repositories uh lead me page and uh you can scroll uh scroll scroll scroll and uh workshop uh markdown guide uh so uh you have to see uh you have to click uh this uh link button uh to access uh workshop guide. So uh click this one uh you uh you can access uh workshop markdown and you can uh try to uh follow this uh guide.

Yeah. uh it's workshop pro uh set up local verification uh deploy to cloud flare workers and uh finally uh you can call uh protect API uh with natural language uh with uh crowd code and mcgp server and uh clean up delete a deployed resource all resource server. Yeah and just scroll down a little bit more. >> Okay. Okay. Uh >> where is the first installation instruction instruction?

>> Scroll down more. >> Okay. Okay. Okay. Instruction. >> So here PM PM install. >> Yeah. Yeah. >> So just to recap here. So you go to the GitHub repository, you clone it, and then when you clone it, you you open the readme, and the readme has the link to this page, docs/workshop. And the first command you run is pnpm install. That will be installing all the dependencies for this node javascript uh typescript project.

>> Yeah. Yeah. Thank you. >> And and this is done on the arc test net. So there's no real money involved. >> Yeah. Yeah. Yeah. It's uh test the test net. It's all free uh crowd uh crowdfare uh accounts. Yeah. and a preview account. Uh it's uh it's for free. Uh and uh if uh uh you you have a cloud

code license, but uh if you have uh codex license uh [gasps] uh yeah uh it's uh same uh configuration uh for uh codeex and cloud code uh just uh set uh mcgp uh settings uh these like uh JSONs uh you you added uh uh MGP uh settings. So uh then uh you you can uh try uh workshop uh from prompt uh from uh crowd uh uh codeex. Yeah.

What the hell? Oh, and uh how should I start the setup after growing the Oh, >> this is for asking the questions. You

can read the questions from here but then answer them >> using the mic. >> This is for question not. You shouldn't be typing. >> Oh, >> this is just the audience asking questions. >> Okay. Okay. >> You answered. >> Ah, okay. Okay. Sorry. >> Oh, sorry. Um, and uh Okay. Thank you. uh asking uh how should I uh so uh okay okay uh after uh crowing theo uh please uh access uh GitHub repository uh read me file uh access

readme file and uh please click uh workshop guys uh link yeah this this one so uh you can see uh today's hands Zoom uh workshop guide markdown. This this all of uh today's uh workshop guide uh is here. Yes. Okay. Can I can I do if don't go?

Okay. Uh okay anyone uh uh don't uh have a crowd code uh sub subscription or codec subscription or any AI agent uh subscription uh people uh okay one uh two Okay. Okay. Uh uh okay. I I'll show you uh the demo

again uh when uh laptop se section. So yeah. M >> uh and uh the workshop label uh published as open source. So uh after this workshop you can uh uh temporary sub uh uh by uh sub uh pro pro subexriction and uh you can try uh this workshop and uh the finished uh then you you have uh Kayak.

Oh okay. So uh then uh if you uh have uh finished this workshop you cancellation uh AI agents uh subcription. So uh uh you you need to uh a little bit uh price to to pay uh try this uh workshop. Yeah. Okay. Setup is already written inside

workshop. It will be best if you proceed with font. I think you you could maybe answer this.

>> Ah, okay. >> Yeah. Thank you. You want to answer this question? >> Oh, okay. Uh, this this question. Uh, yeah. Uh, uh, I I already answered uh this this uh question.

What? What can I do? Uh, yeah. Yeah. I I already answered. Yeah. Yeah.

All right. So, we'll give you guys a couple more minutes to run the workshop on your own. If you're unable to run it, the instructions also had a link to the YouTube video where you can see what happens when Harooi ran it himself. And in a couple of minutes then we will wrap up the workshop part and then Haruki will summarize and talk more about the concepts going on here. Let's ask the audience how many

finished. >> Yeah. Okay. Okay. Uh please a moment. >> [clears throat] >> something. Sorry. Uh okay. Okay. Okay. Uh how did it go? Uh everyone uh how many people uh finished this workshop uh [snorts] contents? Uh okay. Uh okay. Okay. I'm I'm sorry. Uh >> how many came halfway?

>> Oh, really? Oh, nice. >> Okay. >> Thank you. Uh congratulation. Thank you. Thank you. Uh so uh uh okay. Uh I will start uh today's workshop laptop session. Uh uh today uh we learn uh how XO2 works. We built on our official data and deployed it on cloud workers and tested payments with an AI agent. You can use uh this code as a starting point for your own project. My workshop github repository are published opensource code. Uh so uh you uh access uh uh the code after uh this workshop

ended. Yeah. And uh feel free to uh try different support chain token and API like uh use cell monado uh base optimis uh yeah any other EBM chain and a token uh like JPA. So uh thank you for all joining uh today uh workshop and uh I'd like to thank you uh the Devcon team uh for this opportunity and approving my uh uh call for approve uh CFB and uh special thanks to Hucha and A uh reviewing my workshop material

and uh here are my ex LinkedIn and GitHub account uh QR code. So if you have any questions uh feel free to reach out. Uh thank you so much uh everyone for coming uh today uh workshop. It's it's done. Thank you everyone. So please keep that slide on the screen for a while. Do you have any further questions here? I'm checking if there was any you want to ask in in person.

Hey Haruki, my name is Elton. Uh thank you for your presentation. I'm actually defra for circle and arc. So chance upon your workshop and really thank you for bidding on ark. Um for those who manage to do the workshop halfway through um and complete it after this uh you can actually go a step further and if you want to sell services to agents you can actually park them in um circuit agent marketplace and if any of you are building in E global hackathon you can feel free to reach out to me as well but uh I think Hurok's demo is a is a great demo to see um end to end setting up facilitator the server as well as um how to make payments. So, not really a

question, but uh huge huge thank you to Hierarchy. >> Thank you. >> Laptop is I'll tell you that. >> All right. So on behalf of DevCon, I apologize that we had some struggle with the Wi-Fi, but at least you all got the GitHub repository address or you got it cloned. So you can do that anytime later on your own as well. And let's give a big thanks and applaud to for >> Thank you. Thank you everyone >> for preparing the guide so everyone can do that at any time.