Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added IMPLEMENTATION.md
Empty file.
7 changes: 7 additions & 0 deletions packages/geoip-x402-agent/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PORT=3000
X402_PRICE_USD=0.0005
X402_PAYMENT_TOKEN=dev-x402-token
X402_PAYMENT_RECEIVER=geoip-agent
X402_PAYMENT_NETWORK=base
GEOIP_CACHE_TTL_MS=300000
IP_API_TIMEOUT_MS=8000
19 changes: 19 additions & 0 deletions packages/geoip-x402-agent/DELIVERABLE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Deliverable

- GitHub repo URL: https://github.com/daydreamsai/lucid-agents
- Live endpoint URL: <LIVE_ENDPOINT_URL>

## 402 response example

```bash
LIVE_ENDPOINT=<LIVE_ENDPOINT_URL>
curl -i "$LIVE_ENDPOINT/geoip?ip=8.8.8.8"
```

## Successful paid response example

```bash
LIVE_ENDPOINT=<LIVE_ENDPOINT_URL>
curl -i "$LIVE_ENDPOINT/geoip?ip=8.8.8.8" \
-H "x402-payment: $X402_PAYMENT_TOKEN"
```
12 changes: 12 additions & 0 deletions packages/geoip-x402-agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM oven/bun:1.2.8

WORKDIR /app

COPY . .

RUN bun install --frozen-lockfile

ENV NODE_ENV=production
EXPOSE 3000

CMD ["bun", "run", "--cwd", "packages/geoip-x402-agent", "start"]
68 changes: 68 additions & 0 deletions packages/geoip-x402-agent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# IP Geolocation Lucid Agent (x402 payments)

Built via TaskMarket bounty from taskmarket.xyz.

## What this package does
- Uses `@lucid-agents/http` and `@lucid-agents/payments`
- Exposes `GET /geoip?ip=8.8.8.8`
- Calls ip-api.com free tier and returns:
- `ip`
- `country`
- `city`
- `lat`
- `lon`
- `isp`
- Enforces x402-style payment:
- No valid payment header => `402 Payment Required`
- Valid payment header => returns geolocation data

## API

### `GET /geoip?ip=8.8.8.8`
Success response:
```json
{
"ip": "8.8.8.8",
"country": "United States",
"city": "Mountain View",
"lat": 37.4056,
"lon": -122.0775,
"isp": "Google LLC"
}
```

### Payment header
Set one of:
- `x-402-payment`
- `x402-payment`
- `x-payment`
- `authorization` (`Bearer <token>` or `x402 <token>`)

By default, token must match `X402_PAYMENT_TOKEN`.

## Local run (Bun)
```bash
bun install
cp .env.example .env
bun run dev
```

## Deployment notes
This service is ready for deployment to Railway / Render / Fly.io:
- Runtime: Bun
- Start command: `bun src/server.ts`
- Required environment variables:
- `X402_PAYMENT_TOKEN`
- `X402_PAYMENT_RECEIVER` (optional, default `geoip-agent`)
- `X402_PAYMENT_NETWORK` (optional, default `base`)
- `X402_PRICE_USD` (optional, default `0.0005`)
- `PORT` (platform-provided)

## Quick test
```bash
# unpaid request -> 402
curl -i "http://localhost:3000/geoip?ip=8.8.8.8"

# paid request -> 200
curl -i -H "x-402-payment: dev-x402-token" "http://localhost:3000/geoip?ip=8.8.8.8"
```
37 changes: 37 additions & 0 deletions packages/geoip-x402-agent/SUBMISSION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# TaskMarket Submission — IP Geolocation Lucid Agent (x402 payments)

- GitHub repo URL: https://github.com/daydreamsai/lucid-agents
- Live endpoint URL: <LIVE_ENDPOINT_URL>

Built via TaskMarket bounty on taskmarket.xyz.

## curl examples

### 1) Unpaid request (expects 402)
```bash
curl -i "$LIVE_ENDPOINT_URL/geoip?ip=8.8.8.8"
```

Expected response status:
```text
HTTP/1.1 402 Payment Required
```

### 2) Paid request (expects 200)
```bash
curl -i \
-H "x-402-payment: $X402_PAYMENT_TOKEN" \
"$LIVE_ENDPOINT_URL/geoip?ip=8.8.8.8"
```

Expected success body shape:
```json
{
"ip": "8.8.8.8",
"country": "United States",
"city": "Mountain View",
"lat": 37.4056,
"lon": -122.0775,
"isp": "Google LLC"
}
```
16 changes: 16 additions & 0 deletions packages/geoip-x402-agent/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
app = "geoip-x402-agent"
primary_region = "iad"

[build]
dockerfile = "packages/geoip-x402-agent/Dockerfile"

[env]
PORT = "3000"

[http_service]
internal_port = 3000
force_https = true
auto_start_machines = true
auto_stop_machines = "off"
min_machines_running = 1
processes = ["app"]
24 changes: 24 additions & 0 deletions packages/geoip-x402-agent/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@lucid-agents/geoip-x402-agent",
"version": "0.1.0",
"private": true,
"type": "module",
"description": "Lucid Agent: IP geolocation with x402 micropayments",
"scripts": {
"dev": "bun --watch src/server.ts",
"start": "bun src/server.ts",
"typecheck": "bunx tsc --noEmit"
},
"dependencies": {
"@lucid-agents/http": "workspace:*",
"@lucid-agents/payments": "workspace:*"
},
"devDependencies": {
"@types/node": "^24.0.0",
"bun-types": "^1.2.0",
"typescript": "^5.8.0"
},
"engines": {
"bun": ">=1.1.0"
}
}
8 changes: 8 additions & 0 deletions packages/geoip-x402-agent/railway.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[build]
builder = "DOCKERFILE"
dockerfilePath = "packages/geoip-x402-agent/Dockerfile"

[deploy]
startCommand = "bun run --cwd packages/geoip-x402-agent start"
restartPolicyType = "ON_FAILURE"
restartPolicyMaxRetries = 10
16 changes: 16 additions & 0 deletions packages/geoip-x402-agent/render.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
- type: web
name: geoip-x402-agent
runtime: node
rootDir: packages/geoip-x402-agent
buildCommand: bun install
startCommand: bun src/server.ts
envVars:
- key: X402_PAYMENT_TOKEN
sync: false
- key: X402_PAYMENT_RECEIVER
value: geoip-agent
- key: X402_PAYMENT_NETWORK
value: base
- key: X402_PRICE_USD
value: "0.0005"
Loading