-
Notifications
You must be signed in to change notification settings - Fork 7
docs: add AutoIncentive facilitator #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Concorde89
wants to merge
3
commits into
skalenetwork:staging
Choose a base branch
from
Concorde89:add-autoincentive-facilitator
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| --- | ||
| title: "AutoIncentive" | ||
| description: "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 | ||
| # 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 | ||
| npm install x402 viem | ||
| ``` | ||
|
|
||
| ## Integration with AutoIncentive | ||
|
|
||
| <Tabs> | ||
| <Tab title="Server Setup"> | ||
|
|
||
| ```typescript | ||
| 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 | ||
| 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` | | ||
|
|
||
| ## Next Steps | ||
|
|
||
| <CardGroup cols={2}> | ||
| <Card title="SKALE Supported Facilitators" icon="dollar-sign" href="/get-started/agentic-builders/facilitators"> | ||
| Alternative facilitator with advanced features | ||
| </Card> | ||
| <Card title="Run Your Own" icon="server" href="/cookbook/x402/facilitator"> | ||
| Deploy your own facilitator infrastructure | ||
| </Card> | ||
| <Card title="Accept Payments" icon="dollar-sign" href="/cookbook/x402/accepting-payments"> | ||
| Protect endpoints with payment middleware | ||
| </Card> | ||
| <Card title="Make Payments" icon="credit-card" href="/cookbook/x402/buying"> | ||
| Build clients that handle x402 payments | ||
| </Card> | ||
| </CardGroup> | ||
|
|
||
| ## 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> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering these are the official SKALE Docs its only needed to share the supported tokens on SKALE Base -> in this case USDC; Please remove the tokens from other chains
In the future if autoincentive supports more SKALE Base tokens as x402 payment (ex: SKL, USDT, etc) it can be added to the table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified