Session 2

Summary

Project Concept

Participants discussed the development of a system (Infernet) that allows users to offer AI models (like LLMs) on their computers and receive payments from other users who want to use these models. The system would use blockchain to manage payments and would require implementing both a terminal interface (TUI) and a command-line system (CLI).

Technical Architecture

Two main architecture approaches were proposed:

  • A centralized system where a server acts as an intermediary between the model provider and the consumer
  • A peer-to-peer system where nodes communicate directly after establishing the initial connection

They decided to initially implement a centralized architecture where a server facilitates communication and validates payments, avoiding the complexity of implementing WebSockets and direct peer-to-peer communication.

Payment System Demo

A demonstration of X402 was presented, a system that enables:

  • Exposing payment APIs that require a blockchain transaction
  • Implementing middleware that verifies payment before granting access
  • Using server wallets to sign transactions without exposing private keys
  • Verifying transactions via HTTP 402 (Payment Required) codes

The example shown was an email validation API that charges 0.005 USDC per request, where the middleware verifies that the header contains the corresponding payment hash.

Proposed Implementation Flow

The workflow was outlined for both sides of the system:

For the user requesting the model:

  • Install the tool
  • Fund their blockchain address
  • Execute commands to search and select available models
  • Send requests that automatically include the required payments

For the model provider:

  • Install Docker and the tool
  • Configure their payment address
  • Register their node and model in the system
  • Run a script that listens for requests and redirects them to the local model

Pending Actions

  • Research CLI flag implementation (they mentioned Cobra Commands in Go) (how-to-build-a-tui)
  • Define how the provider node will connect incoming requests with the local model
  • Research Docker container management for models (LLM Container Images)
  • Implement the registration system to list available models (node-registry-smart-contract)
  • Develop the logic to filter requests that don’t include valid payments

Notes

Transcript

Ready. It’s in the app. Ok, so I made the diagram and also, what was I saying? There’s the CLI vs TUI dilemma. And I basically made the diagram, planned how I thought this thing should work, a structure, and then I started poking around to see how the Charm stack works. I more or less understood it but…

I didn’t have enough time to really understand 100% how it works. I do understand it at a high level. And then I started building. It was going to take me too long, so I used AI for a first draft and it works well. And more or less, I tell you, I more or less understand how it works.

And so I managed to get this done. Let me see if you can see it. I mean, this is real. Charm also has a tool for recording like…

Like simulating a terminal, it’s a gif or an mp4. I don’t know if you can see it, but that’s how the TUI would look.

Ok!

Cheers.

Essentially, on the UI side, they would be API requests hitting the server, and the server would actually be performing the logical actions. And I think the other important topic I couldn’t fully resolve is this. If you give this document, which is an MDF, to AI and tell it to build the Go project, it should build it almost the same way I did. So we can skip the GitHub check because…

It would really be created at that moment from this file, it’s like a project spawner. Right. They’re calling me right now, I’ll connect. Yeah dude. Then there are more tutorials here, I put them for future reference. But here’s the thing, right?

The server, once it’s established a communication line with a model, in theory should be like a… Well, here I better ask you because I don’t know how we’re going to do it, which is better. I think it should act as a peer-to-peer session manager…

rather than a proxy. Because right now I had it planned as a proxy… where did I put this thing? So the yellow central server, let me see if I can make it…

I should prepare my presentation better. No, don’t worry. Where is it? This orange part here? That would be where assertions occur. So for example, this here is the TUI, and once a model is selected to talk to, the user sends a request here to the query relay.

Then pays, or rather sends a contract to the blockchain and if the other guy accepts it too, it returns a success. And then the two TUIs communicate directly, they manage transactions between themselves.

But I don’t know. I’ve never set up peer-to-peer stuff either. Yeah, it’s… Oh sorry. I’ve been experimenting with peer-to-peer things, but fuck, man, this is… What great news. It’s complicated, dude, because you generally need WebSockets and such, and most of the infrastructure I know how to use isn’t very compatible with WebSockets.

So I’m not that sure, but let me show you how X402 works because that thing should have…

Similar things. Let me see… Ok. Give me a second? I mean, they talk through the blockchain and not through like a proxy type thing. Exactly. Yeah, I mean… Honestly…

I couldn’t explain exactly how the resolver works, but give me a second, I’m opening my project now.

Whoa, you guys look like HD on my camera. I’ve never called myself before.

You look good hahaha. Look, ok go ahead, I’ll prepare.

Well, if you want, let’s go in parts then.

Ok, so…

If I tell you I more or less understand, I mean it’s very basic, it’s really not a framework and they have very few methods. But yeah, the model is called ELM and has nothing to do with React, it’s something else. Ok. So basically, yeah, this is quite responsive, they can click browse nodes. Here all the active ones should appear from a database with their metadata.

You see, what worries me a bit about using this tool is that there’s going to be a contract called Registry where you’ll register your node and say: look, this node receives payments at this address and serves this model.

And I know a Node client that works to call the contract and read it. You simply tell it: this is the contract, this is the structure you can expect, and these are its functions.

And it gives you the whole kit to interact with that contract. But if we had to do it this way, I don’t know, this thing is written in Go or what? Yeah, it’s in Go. But anyway, I think it’s compatible with what I was telling you about the centralized server.

I mean, maybe not the connection itself, but for querying models. Go with an HTTP POST or whatever, a GET, hits the server, and the Node server reads the contract and just returns the metadata without having to access the contract directly. So we’d run a Node server.

And we’d run this as the front-facing. Exactly. Ok, sounds good. I don’t know if there’s a simpler way. I mean, I also know you can do these things in Node, but… Yeah, I mean, ultimately, if we end up doing it in something compatible with Node…

I feel like we could help more, or I could, but I think it’s better to separate it. So if you feel comfortable with this one, or equally adrift with this or the other, choose whichever. I’m fine either way. It looks good. I feel like the model will be the same, the other one is just written in TypeScript, right? That’s the main difference. I suppose.

I just know, for example, that the Claude CLI runs with Node. This Node, this Node, right. Let me get a second, dude. They’re ringing my doorbell.

Are they closing tomorrow?

What’s up man, sorry. No, no worries. I put water on. Is that your filter? No. Ah, nice. We were out. Yeah, but… Anyway, like you say, I think, dude… There are two things I believe. One is whether we can make a way, for example, you know how sometimes you can run a script with certain flags and skip the TUI? That’s the CLI.

They’re different things. The Terminal UI is very descriptively the Terminal UI. The CLI is a command that takes flags. Right. Do you think we can do both? Yes, well, this tool supposedly has that. Let me check… Well, I didn’t test that part, but… Yeah, I mean, if we can, I’m in. And I ask mainly because…

I was looking at what’s going on with these Coinbase guys and they have this idea that you can make an agent that runs scripts. So it would be cool if they can also be controlled through flags. If that’s possible, we’re good.

Totally possible. In fact, this TUI framework called Bubbletea can also format how you interact with a CLI. I mean, it’s more user-facing, but we could also do… they’re called Cobra Flags or something, Cobra Commands.

In Go, it’s a library. You just download it and start using those things. It supposedly has that feature. Ok, yeah we need to research how that’s done. But ok, we wouldn’t have a problem on that side then.

What shall we do, dude? I mean, I’m thinking…

Let me show you how what I have works, to think about how we could connect things, you know? Yeah, alright.

Well… Here it is.

Look.

So this thing here is… I’ll hide the screen but tell me if anything…

Look, this thing here…

And… wait!

One moment, doesn’t it exist?

And… let me check, I don’t think it’s this one.

Ok. Now yes, sorry. Go ahead, go ahead. This thing here is a repo, which actually… the json and txt files aren’t needed. So it’s a repo with two Next applications. So if I start the API here, which package am I using…

npm run d and here…

I open this…

I can…

Open a…

This one is going to be the one running. This is the API, I’m just using an API.

Damn.

So this one…

What I really care about is the app, and if you see the… Ah, this wasn’t it.

I should have prepared my demo better too. Here it is. If you see the API, actually… the example I made was imagine you have an API that checks whether an email is temporary or fake. And on the other side you have a guy who has his SaaS and uses the API in the registration form. That’s the use case.

So on the right side I have the guy who’ll consume the API and on the left I have the API. And practically this thing here, I have an API route called ValidateEmail that uses a thing called EmailValidator. And here I basically set it to check the result, tell you a RiskScore and such.

It’s a bit dummy, but you just check if the format is right, if the domain exists, if it’s in a disposable email database, and you set the temp mail and whatever. So what you configure is that in the middleware you use this thing called x402 next.

You tell it where to receive payment and how much your API route costs. So it reads this from the environment variable.

This is too hardcore for me.

So in the environment variable you’re just… we’re looking at the guy who has his API for sale. His paid API. So this guy just has to say: here’s where I want to be paid. And in the middleware he says: this endpoint…

costs half a cent on this Base Sepolia, on this network. So the API maker just says that. Then the consumer…

The consumer is this guy here, damn, something got cached.

Or not? Did I leave a server running somewhere?

That’s 3002.

And it’s weird, I don’t know why it stayed running.

What’s the top command?

And how do I close the…

Yeah, must be Node.

I don’t see anything, do I need to press I? Or J here? How do I navigate?

Yeah, I left a server running. Well, whatever, I’ll shut it down later.

So…

This thing here, you have your SaaS form, right? And you want to make sure no junk users register. So you find this guy has a paid API for half a cent and you’re like, cool, I’ll use it.

And it’s using a Coinbase server wallet. But we basically need to fund this thing. So I’ll fund it on Base Sepolia, I need to send this…

And it should show up in the balance in a few seconds.

Yeah, I thought it was showing. Ok, ok.

Every time you start this app, it gives you a new address the server has, and it’s empty. So you’d need to put money in it. Can be done programmatically or not, but here I literally went to a faucet, copied this address, pasted it, and it said it sent me 10 USDC. They’re showing up now. So if I check, Arturo…

The important thing is also to see that in my wallet, it’s my MetaMask address. So if I switch to Base Sepolia network…

I have, besides being rich, two and a half cents of USDC. And this other guy has 10 dollars, it’s another wallet. Can you see my screen? So if I click validate…

It’ll send a request with a payment header.

And it tells me to check because this thing failed. I spent five cents, half a cent in validations. I had two and a half cents, so now I should have three cents. And if I check this sheet… I already have three cents… let me put this cat down.

Could we do anything? The problem is the more complicated we make it… The harder it’ll be to finish in time, right. Right.

Look.

Oh look, if I go to this thing, it has a wallet starting with FBA. If I shut down and restart that server, which is this one…

And I don’t run it again…

Look, it’s telling me which process is using it.

And I can just specify the port, right?

Ok.

Oh shit, I think it worked. Let me try again.

Ok, now. Easy use by 3909. Oh no, did I kill this one?

Seems not, dude. I don’t know what I did. Ok, it started with FBA I think. So if I reload these things…

It’s a different wallet now. I don’t have money there. So if I try to send the same request from here. And this one is the server, right? And…

conito@tempmail

It’s good.

Yeah, so, ah no, couldn’t see. You dodged a bullet there.

Click validate.

It says Request Failed with Status Code 402. And… that’s the Expected Behavior. The 402, that’s why the library is named that. 402 means no payment header. So what happens is when you send the API request, what the middleware checks is that there’s a header with the payment hash, i.e., the receipt.

So exactly…

You see, if it’s true, you tell your middleware to verify that a transaction happened for .005 to this wallet. And when someone sends a request they have to put a payment header, and that payment is literally the receipt number. So this contract, I can’t tell you exactly how it works, but I know it’s a contract…

deployed there. It checks the transaction hash and verifies the receipt matches what you were supposed to pay, and if yes, the request goes through. If not, it doesn’t.

Exactly.

And… theoretically… Right, go ahead, tell me.

But ultimately you need a directory, a list where I say, look, I’m going to run a Llama 3.5 Billion, right? And my super simple idea would be that I say, like, cool, it’s bedtime. So I open my terminal, run a script, or open the TUI with Ethereum Inference Network or whatever, set a couple values, and see a green light saying your node is live. And then somewhere in a directory, everyone who wants to send requests can say, today I want to code so I want a powerful model, the o1 from DeepSeek.

So they open their terminal user interface, search, and it shows there’s none, or maybe latency shows up or something. They select it and can send requests. I know we could do it literally by sending requests, but it wouldn’t integrate so well with your development environment because it’d be like the old days of copying text, going to chatgpt.com, pasting, submitting, and bringing the answer back.

It’s an MVP, it would work I think, but I think it could be easier if… locally you have a node that sends requests, but that node gives you your… I’m getting a bit off track here, but… more or less.

Yeah, something like that.

Yeah, I mean, ultimately, I think what you had also works, but I’m a bit worried that… the data pipeline could get stuck because the flow is more complex, with more steps.

But I tell you, I think we’re more or less aligned. I saw more or less how it would look and it’s cool dude, it’s cool. If we can run it with flags as you say, it works great. And maybe we can even do the whole thing of… I mean, what worries me dude is that…

There’s still the other mess of actually running a model and having it actually accept and send things. But what I’m imagining is… you start a container with a Llama image on port 8080. And this tool already knows that when initialized, there’ll be a process waiting there. Assuming it’s an LLM, it’s waiting for a string and will return a longer string, which is basically what they do. So the node or this thing communicates with the other port locally and sends the result over the internet.

Subtitles by the Amara.org community.

Yeah.

It’s a panacea dude, I’d love if we could do that. And I also feel like if we knew shell scripting…

Exactly.

Yeah, exactly. Yeah, I think that would be the idea and…

Also, from what I showed you, my example where I’m sending a request from a Next thing, right? But they have, for example, X402 Axios. So we can use a node without user interface for requests. I think it can still be optimized quite a bit.

I mean, what the library does is it has two faces: one for the API exposer and one for the consumer. The consumer library just says: look, here’s my wallet, I give you permission to sign.

micropayments.

So when you encounter an API that asks for payment…

Send it.

And then…

Well, it’s a mess, dude. I now understand it more but not enough to explain it easily. Basically there’s x402, I think it’s x402.org.

No, no, no worries. I mean…

Basically…

You have a private key.

And if you derive it or do an operation on it, you get a public key. And that public key is an address. So if you have the private key, you can sign payments, you can say: send this amount from here to here. So what we’re doing here is using a tool that signs on your behalf.

When you call certain APIs.

And we use that so when consuming paid APIs, the thing can automatically send the request. Because otherwise MetaMask would pop up asking you to sign. And here it’s done server-side, hence “server wallets.”

So the client never sees the private key.

That’s another whole thing, but the Coinbase Developer Platform prize we’re aiming for… Those guys already built this infrastructure where you never show the client the private key, but let them interact with an SDK and sign things.

And a use case is consuming paid APIs. So the guy who puts up the paid API, who exposes the endpoint, has it super easy. He just says: my API costs one dollar.

And you have to pay here. If you don’t pay a dollar here, FOG YOUR REQUEST, it responds 402. So that guy has it easy. The one that’s a bit more complicated is the one who has to send the request with the payment header.

But…

Yeah, you don’t have to give permission because it has the private key.

Right, exactly. Yeah. So…

Yeah, I think we need, we have the two flows, right? I’ll draw a little diagram here and you clean it up later. We have the one who’ll send the request and the one who’ll rent out his computer.

So here we have the requester.

That guy needs to run a command.

something happens that installed it.

And it’ll tell him: ok, but you don’t have money dude. Put money in, otherwise you can’t send requests. So he runs what he installed and it returns: this is your address.

No, I’m just writing in my notebook. This is your address, fund it.

And then that guy…

The prerequisites if you want to earn money: have Docker installed and run a model, run a Docker with a model. For our example let’s assume an LLM. So that guy installs Docker.

Installs the tool.

And says where he wants to receive payments, right?

Then he needs to register his node and model. He has to say: I am such and I run such. Register.

node

and model.

A script or something that on one side listens for requests.

And it’ll only listen for requests that have already paid. If someone sends an unpaid request, the node won’t even notice.

Then… well, not really, but yeah. It listens for requests… exactly, bounces unpaid ones. And…

Then sends them to the correct port.

And this gets answered by…

the node.

That sent the request. And that’s it. It’s not that complicated. So… And receiving a response is an HTTP client, as you said. Literally an Axios or whatever. And with this Coinbase tool we manage wallets and everything. It’s a couple of lines, you don’t have to do more.

But for the other guy we’ll have a bit more work because we need to make some path where he can say: I install the model, put it on a port, and send the requests that arrive here to this node. Assuming it’s also a Node.

We’ll send it to his own model. I’m not sure exactly how to do it, but I’ll research that today. But we’d need to see if we can make a CLI that’s like node or something. Ultimately all we want is for your computer to send a request from your localhost 3000 or whatever to another port, listen to the response, and send it over HTTPS.

I think the process doesn’t die in the sense that until you hit Ctrl+C, it stays open. And it stays idle, waiting to send or listen to something else.

Can you zoom in a bit?

Yeah.

Yeah, I mean, I don’t know if I’d say with extra steps. I think if we implemented it barebones with HTTP and Sockets and whatever, we could do it with the same number of steps, but there’s a skill issue. We don’t know that well how bare metal works and that’s why we need Node and all the tooling. But yeah, ultimately, LLMs…

work with a stateless API, right? That’s why you can switch models mid-conversation. It’s simply a buffer, and it gives it some special characters indicating whose turn it is, and then when the model sees those characters it adds stuff at the end. That’s basically all they do.

Notes

Transcript

There was just an event here in Mexico, right, like late July? For Notion? No, for ETH Global.

Eh, I suppose the anniversary was Terry’s anniversary. Right. Yeah, yeah, yeah.

I didn’t go but I saw it around. Sorry, is it recording now? If you want…

Ok, I checked if the Notion thing was there, but it’s not. Well, I don’t know. Doesn’t matter.

What was I saying? Right, what we’d do is create the tool for another agent to manage context. We just manage the connection from point A to point B and its payment, its transaction. We create a transaction system.

Of requests, automated. From my point of view…

We need to make, because if you run a local model…

You don’t need to send an API request. You already have it there and you just say… Once upon a time, and it responds. It’s like that game, I don’t know what it’s called.

But that’s what this thing does. But ultimately, what OpenAI does is say: look, this program needs a lot of GPU. So I’ll create an API for you to use this program. And I give you the API key. In the header you put your API key, Bearer Token, and then send it to the Completions endpoint.

With certain parameters, and you send: once upon a time. And the same thing happens, right? It’s not that it’s amazing to consume these programs through APIs. But it’s how Sam Altman says: if you pay me, I give you an API key. And what I’m saying is…

Assuming there are people with computers that can run these programs, how could those people do what Sam Altman does? Yeah, no, agreed. My comment wasn’t about the philosophy of what we’re doing, but about…

In very objective and practical terms, the scope of our implementation this weekend.

See you soon!

And…

The scope I think is…

That through the API, instead of needing a Bearer Token, you pass a receipt that you already paid 5. So we need to do, it sounds very complicated if you say it like that, but we need to do the same thing OpenAI did in the sense that we want to take a model…

That works through endpoints. And instead of serving it as…

It’s ultimately the same because if we’re serving and consuming via HTTPS, the only different thing is that in parallel we’re using a header that runs on the blockchain. Instead of an API key, it’s blockchain. But that’s the only difference.

I think we went too deep, but at least I rethought everything. It was good. But we should make progress. If you want, Antonio, tell us what you found, dude. And… let’s see what we do now.

Well, I was looking at the teams participating in the Coinbase tracks and I saw that actually the only one at ETH Global was in San Francisco, the one we went to. And I saw there were other online Coinbase events. Honestly, I didn’t see many similar features. Most of what I saw was attempts to build certain types of marketplaces.

Using micropayments to buy and sell certain products or things on the internet. And the other info you posted about the Artificial Super Intelligence track, would we still qualify, or yes, because we’re using that too.

Well, nothing, I don’t know what do you think.

Eh, we’d have to see. I think it could work.

Ultimately I think the goal should be how to try to secure the Coinbase one because… I wanted you to do that research to see if nobody has done this before because I feel like… Well, it’s not that complicated. That’s what I say now, let’s see what we say Saturday at midnight. But… Did you see another protocol called Cash Network?

Ah, I saw you put it there, I researched it, but it’s much more like IPFS, right? Right. But it would also be something similar, right? To be able to enter and make requests.

Those things are more infrastructure-level, like thinking about miners and stuff.

Ok, hey Diego, I need to go, can you call me right now please?

Yeah… let me…

Let me see, ok, nothing left here.

An impressive and useful AI agent.

And I think the biggest impact of our project would be decentralizing AI use. I think that’s how we should frame the project. So… Well, I need to move this to Node so it’s just a server and use… we use Axios.

I suppose there was a specific thing to request that data, to check the contract and match. From the side… Yeah, well, with what we discussed I think we’re good. If you made a diagram, could you upload a photo or something? It’s very ugly, but yeah, I’ll upload it now. Oh, it doesn’t matter.

I’ll use a visual aid… what’s the word… Let me try to use more Spanish and fewer anglicisms. You’re already doing it. But…

With that visual aid I can keep developing. Ok. Hey, and why, dude? I’m curious.

It works on many levels, but I think partly my Spanish vocabulary is poor and I want to expand it. On the other hand, when I think in English, I think I think poorly, so I want to master my mind more in Spanish. That’s cool. Cool, right?

Hell yeah. Um. Hey, I was also going to tell you that there’s a sponsor…

that has something similar to IPFS for storing multimedia.

So I’ve been thinking about what I was saying about it being competitive because… I feel like there’ll be a lot of people and not enough money for everyone to win. And ultimately Coinbase has some of the biggest prizes. That always attracts more competition. So…

I still think we should be laser-focused on that one until it’s secured. But if we have time left afterwards, from here until the weekend, I think it’d be cool to add Walrus. Like, also if you use a model that generates… Images. Images. Well, you can’t send it directly, I don’t know if you can. But instead of sending it… I don’t think you can.

Can you in an…? No, not in HTTP, but it’s like a peer-to-peer connection where you send chunks in binary, and the receiver builds it. I don’t know what it’s called, but I know it exists.

Well, the idea there is a bit weaker, but it would be that the model, the requester is here and the image generation model provider is here. This guy passes the request directly. This guy generates the image, uploads it, and sends you the link. So…

I think there’s something there but I can’t quite see it yet.

Yeah, I think it’s worth concentrating on securing the Coinbase one because it’s… five thousand bucks. Among the three of us that’d be great. Hopefully. And if we have time we’ll add Walrus and talk to those ASI guys who supposedly have a very aligned vision. We just need them to tell us: in the future we’ll put up a node and such. So for now we simulate with a request to their API key, but in the future…

It’ll be possible to do differently, because they don’t have the infrastructure yet. So it’s very new.

Ok. Well, let’s do that then.

No, I’m going to get into that thing. I have other things to do, but… Yeah, no, dude, no worries. The Walrus thing… Obviously varies between implementations, but the easy way to use it is very easy and I’ve already implemented it in production. So I have that code. Don’t worry about that now, just focus on the node and…

We’ll see about the rest.

Once you’re in the US, we’ll figure out the rest as we go.

Alright. Alright. Alright.

Well hey, and then what happened with what you were telling me about Diego and going to see your friend and all that? That was more for tomorrow. Yeah yeah I said. No, it was fine and he’s not going to charge us. Oh, good. But I don’t know if it’ll work out tomorrow. If it does, I’ll see you there. If not, then not.

Where are you going to eat today? No idea. JC said let’s do something, but he hasn’t said anything. Yeah, he told me last week and… Look, free. I hope. I hope, dude. I thought about it. I mean, yeah, I’d like to, but where would I study, man? So I don’t know, we’ll see.

Well, I’ll let you go. Ok? Ok, see you. Bye. Bye.