> ## Documentation Index
> Fetch the complete documentation index at: https://docs.skale.space/llms.txt
> Use this file to discover all available pages before exploring further.

# AutoIncentive

> Integrate AutoIncentive facilitator for x402 payment processing

AutoIncentive is a hosted facilitator service that streamlines x402 payment processing. By using AutoIncentive's endpoints, you can offload payment verification and settlement without needing to operate your own facilitator infrastructure.

## Highlights

* **Multi-Chain Support** — Base, SKALE Base, and Solana from a single facilitator endpoint
* **Gasless on SKALE** — Zero gas fees for settlement on SKALE Base, powered by CREDITS
* **x402 v1 & v2** — Supports both legacy network names and CAIP-2 format
* **Free to use** — No fees charged on top of payments

## Supported Networks and Tokens

| Network            | Network Identifier                 | Token | Signer Address                               |
| ------------------ | ---------------------------------- | ----- | -------------------------------------------- |
| SKALE Base Mainnet | `skale-base` / `eip155:1187947933` | USDC  | `0x12a2A9353fD1bAdb2eB9DbE9Cb75d73e527D2763` |

## Prerequisites

* Node.js and npm installed
* A SKALE Chain endpoint
* Basic understanding of x402 protocol

## Configuration

### Environment Variables

Create a `.env` file with the following configuration:

```bash theme={null}
# Receiver address for the x402 payment
RECEIVING_ADDRESS=0xAddress_Receiving_Payment

# please don't share your private key with anyone
PRIVATE_KEY=0xyour_pk
```

### Dependencies

Install the x402 client library and viem:

```bash theme={null}
npm install x402 viem
```

## Integration with AutoIncentive

<Tabs>
  <Tab title="Server Setup">
    ```typescript theme={null}
    import express from "express";
    import { paymentMiddleware } from "x402/express";
    import "dotenv/config";

    const app = express();

    const receiver_address = process.env.RECEIVING_ADDRESS || "0xsome_default_address";
    const facilitator = "https://facilitator.x402endpoints.online";

    app.get("/api/free", (req, res) => {
      res.json({
        type: "free",
        message: "This is free data that does not require payment",
        timestamp: new Date().toISOString(),
        data: {
          temperature: 72,
          humidity: 45,
          conditions: "Sunny",
        },
      });
    });

    // Premium endpoint with payment required
    app.get(
      "/api/premium",
      paymentMiddleware(facilitator, {
        network: "eip155:1187947933",
        asset: "0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20",
        amount: "1000",
        payTo: receiver_address,
        description: "Premium weather data",
        mimeType: "application/json",
        maxTimeoutSeconds: 60,
        resource: "/api/premium",
      }),
      (req, res) => {
        res.json({
          type: "paid",
          message: "This is paid data that requires x402 payment",
          timestamp: new Date().toISOString(),
          data: {
            temperature: 72,
            humidity: 45,
            conditions: "Sunny",
          },
        });
      }
    );

    app.listen(3000, () => {
      console.log("Listening on http://localhost:3000");
    });
    ```
  </Tab>

  <Tab title="Client Setup">
    ```typescript theme={null}
    import { wrapFetch } from "x402";
    import { createWalletClient, http } from "viem";
    import { privateKeyToAccount } from "viem/accounts";
    import "dotenv/config";

    const pk = process.env.PRIVATE_KEY;

    if (!pk) {
      throw new Error("PRIVATE_KEY must be set in your environment");
    }

    const account = privateKeyToAccount(pk as `0x${string}`);
    const walletClient = createWalletClient({
      account,
      transport: http("https://skale-base.skalenodes.com/v1/base"),
    });

    const fetchWithPayer = wrapFetch(fetch, walletClient);

    const url = "http://localhost:3000/api/premium";
    const response = await fetchWithPayer(url);

    if (response.ok) {
      const data = await response.json();
      console.log("Response data:", data);
    } else {
      console.error(`Error: ${response.statusText}`);
    }
    ```
  </Tab>
</Tabs>

## Troubleshooting

### Connection Issues

If you cannot connect to AutoIncentive:

1. Verify the facilitator URL is correct
2. Check network connectivity
3. Ensure API credentials are valid
4. Review firewall settings

### Payment Failures

Common causes and solutions:

| Issue                 | Solution                                |
| --------------------- | --------------------------------------- |
| Invalid signature     | Verify wallet configuration and signing |
| Insufficient balance  | Ensure payer has enough USDC            |
| Network mismatch      | Check chain ID matches configuration    |
| Expired authorization | Increase `maxTimeoutSeconds`            |

## Resources

* [AutoIncentive GitHub](https://github.com/Concorde89/facilitator)
* [x402 Protocol Specification](https://x402.org)

***

<Note>
  This entity -- AutoIncentive -- is deployed and actively supporting SKALE. These are 3rd party services that may have their own terms and conditions and privacy policies. Use these services at your own risk. AI and agents is a highly experimental space; the 3rd party software solutions may have bugs or be unaudited. You and your agents and your customers use all 3rd party services chosen at your own risk and per their terms.
</Note>
