Instantly monetize APIs, Static Sites, and AI Agents. MachinePal is a drop-in proxy that adds crypto payments to any web resource.
MachinePal is a "Toll Booth" for the internet. It sits in front of your API, website, or AI Agent and demands payment before allowing access.
It implements the x402 protocol (standardized by Coinbase) to handle negotiation, payment verification, and access granting automatically.
- For Developers: Sell API access without setting up Stripe or user accounts.
- For AI Agents: Allow your agents to buy and sell data autonomously.
- For Hosting: Turn a static file server into a paid resource.
Follow these steps to set up a Server (The Seller) and a Client (The Buyer) on your local machine.
Create a directory for your data and generate the default configuration.
mkdir machinepal_project && cd machinepal_project
# Initialize config files
docker run --rm \
-v "$(pwd):/machinepal" \
-e PUID=$(id -u) -e PGID=$(id -g) \
ghcr.io/skalenetwork/machinepal init
π° The Money Hook: Look at the
machinepay.ymlfile created in this folder. This is the config file where you will eventually paste your wallet address to receive real payments!
This starts the MachinePal proxy. It is now protecting the hello_world.txt resource.
docker run -d \
--name machinepal \
--restart unless-stopped \
--network host \
-e PUID=$(id -u) -e PGID=$(id -g) \
-v "$(pwd):/machinepal" \
ghcr.io/skalenetwork/machinepal
Note: We use --network host for best performance and ease of access on Linux. On macOS/Windows, ensure Docker Desktop allows host networking or map ports manually.
Now, pretend to be a customer. This command runs a client that attempts to fetch the file, realizes it requires payment, pays it (using a test wallet), and displays the content.
docker run --rm --network host \
-v "$(pwd):/machinepal" \
ghcr.io/skalenetwork/machinepal client http://localhost:8080/hello_world.txt
- Request: The Client asked for
hello_world.txt. - Rejection: MachinePal blocked it and replied:
402 Payment Required. - Payment: The Client automatically paid the required amount (on Testnet).
- Success: MachinePal verified the transaction on-chain and delivered the file.
MachinePal is designed for high-concurrency and low-latency environments.
| Feature | Description |
|---|---|
| β‘ Plug & Play | Wraps existing APIs/Sites. No code changes required on your backend. |
| π Multi-Chain | Native support for Base and SKALE networks. |
| π High Performance | Asynchronous HTTP server scaling to 1M+ concurrent connections. |
| πΈ Flexible Models | Support for subscriptions, pay-per-request, and metered access. |
| π Deep Logging | Full visibility into payment traffic and revenue. |
flowchart LR
subgraph External_World["External World"]
U1["User / AI Agent"]
end
subgraph Your_Infrastructure["Your Infrastructure"]
MP["MachinePal Gateway\n(The Toll Booth)"]
API["Your API / Service"]
DB["Your Data / Files"]
end
%% Flow
U1 -- "1. Request Resource" --> MP
MP -- "2. Demand Payment (402)" --> U1
U1 -- "3. Submit Payment Proof" --> MP
MP -- "4. Verify & Forward" --> API
MP -- "4. Verify & Forward" --> DB
API -- "5. Return Data" --> MP
MP -- "6. Deliver to User" --> U1
%% Styling
classDef gateway fill:#ff9800,stroke:#e65100,color:#000000,font-weight:600;
classDef users fill:#4caf50,stroke:#1b5e20,color:#ffffff,font-weight:600;
classDef services fill:#1976d2,stroke:#0d47a1,color:#ffffff,font-weight:600;
MP:::gateway
U1:::users
API:::services
DB:::services
We love community contributions!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request