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
feat: add Apex tx check and delivery score actions
  • Loading branch information
apexfaucet-hub committed Nov 18, 2026
commit bb0b7bade1b1cf815154be67e7141529d3e224e8
5 changes: 5 additions & 0 deletions typescript/.changeset/apex-tx-check-delivery-score.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@coinbase/agentkit": patch
---

Added an Apex action provider with tx_check (unsigned Base or Solana transaction, SAFE or RISKY) and delivery_score (0 to 100 for an x402 URL). Both call the public HTTPS routes and return unpaid x402 terms for the caller's own wallet. Nothing is signed here.
14 changes: 14 additions & 0 deletions typescript/agentkit/src/action-providers/apex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Apex action provider

Two actions that call the public APEX routes. The provider does not hold a key and does not pay.

- `tx_check` checks one unsigned Base or Solana transaction and returns SAFE or RISKY. Price 0.001 USDC. Free sample: https://apexfaucet.xyz/tx-check
- `delivery_score` scores one https x402 URL from 0 to 100. Price 0.003 USDC. It does not pay that URL. Free sample: https://apexfaucet.xyz/delivery-score?url=https://apexfaucet.xyz/api/x402/page-markdown

On HTTP 402 the action returns the payment terms. Pay them with your own wallet, then call again.

```typescript
import { apexActionProvider } from "@coinbase/agentkit";

const actionProviders = [apexActionProvider()];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { apexActionProvider } from "./apexActionProvider";

describe("ApexActionProvider", () => {
const fetchMock = jest.fn();
const provider = apexActionProvider();

beforeEach(() => {
fetchMock.mockReset();
global.fetch = fetchMock as unknown as typeof fetch;
});

it("returns the unpaid terms and does not sign", async () => {
fetchMock.mockResolvedValueOnce({
status: 402,
text: async () => JSON.stringify({ accepts: [{ amount: "1000" }] }),
});
const parsed = JSON.parse(
await provider.txCheck({ chain: "base", from: "0x" + "11".repeat(20), to: "0x" + "22".repeat(20), data: "0x095ea7b3" }),
);
expect(parsed.paid).toBe(false);
expect(parsed.http).toBe(402);
expect(parsed.note).toMatch(/Nothing was signed/);
const called = String(fetchMock.mock.calls[0][0]);
expect(called.startsWith("https://apexfaucet.xyz/api/x402/tx-check?")).toBe(true);
expect(called).not.toMatch(/private/i);
});

it("refuses a Solana call that has no signer", async () => {
const parsed = JSON.parse(await provider.txCheck({ chain: "solana", tx: "abc" }));
expect(parsed.success).toBe(false);
expect(fetchMock).not.toHaveBeenCalled();
});

it("scores an https URL and does not pay it", async () => {
fetchMock.mockResolvedValueOnce({
status: 200,
text: async () => JSON.stringify({ ok: true, score: 96 }),
});
const parsed = JSON.parse(
await provider.deliveryScore({ url: "https://apexfaucet.xyz/api/x402/page-markdown" }),
);
expect(parsed.http).toBe(200);
expect(parsed.body.score).toBe(96);
const called = String(fetchMock.mock.calls[0][0]);
expect(called.startsWith("https://apexfaucet.xyz/api/x402/delivery-score?url=")).toBe(true);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { z } from "zod";
import { ActionProvider } from "../actionProvider";
import { CreateAction } from "../actionDecorator";
import { DeliveryScoreSchema, TxCheckSchema } from "./schemas";

const TX_CHECK = "https://apexfaucet.xyz/api/x402/tx-check";
const DELIVERY_SCORE = "https://apexfaucet.xyz/api/x402/delivery-score";

async function readPublic(url: string): Promise<string> {
const response = await fetch(url, { headers: { accept: "application/json" } });
const text = await response.text();
let body: unknown = text.slice(0, 8000);
try {
body = JSON.parse(text);
} catch {
// keep the clipped text
}
if (response.status === 402) {
return JSON.stringify({
paid: false,
http: 402,
note: "Unpaid. Pay the returned x402 terms with your own wallet, then retry. Nothing was signed here.",
terms: body,
});
}
return JSON.stringify({ http: response.status, body });
}

/**
* ApexActionProvider calls the public APEX x402 routes.
* It does not hold a key and it does not pay.
*/
export class ApexActionProvider extends ActionProvider {
constructor() {
super("apex", []);
}

@CreateAction({
name: "tx_check",
description: `Check one unsigned Base or Solana transaction and return SAFE or RISKY.
Base flags a simulation revert, an unlimited approval, an approval-for-all, a hidden token move, and one exit check.
Solana flags a simulation revert, a token drain, a delegate approval, and a rug mint.
Nothing is signed or broadcast. Price is 0.001 USDC. A free sample is at https://apexfaucet.xyz/tx-check.
On HTTP 402, pay the terms with your own wallet. Do not send a private key.`,
schema: TxCheckSchema,
})
async txCheck(args: z.infer<typeof TxCheckSchema>): Promise<string> {
const params = new URLSearchParams();
const chain = args.chain || "base";
if (chain === "solana") {
params.set("chain", "solana");
const signer = args.signer || args.from;
const tx = args.tx || args.raw;
if (!signer || !tx) {
return JSON.stringify({
success: false,
error: "Solana needs signer (or from) and tx (or raw). Do not pass a private key.",
});
}
params.set("signer", signer);
params.set("tx", tx);
} else {
if (!args.from) {
return JSON.stringify({ success: false, error: "Base needs from, plus to and data, or raw." });
}
params.set("from", args.from);
if (args.raw) params.set("raw", args.raw);
else {
if (!args.to) return JSON.stringify({ success: false, error: "Base needs to and data, or raw." });
params.set("to", args.to);
params.set("data", args.data || "0x");
if (args.value) params.set("value", args.value);
}
}
return readPublic(`${TX_CHECK}?${params.toString()}`);
}

@CreateAction({
name: "delivery_score",
description: `Score one https x402 URL from 0 to 100.
Five parts of 0 to 20: watchtower 7-day uptime for that exact URL, a valid unpaid 402, the USDC price, probe speed, and test buys already recorded.
This action does not pay the URL. A URL never bought scores 0 on test buys.
Price is 0.003 USDC. A free sample is at https://apexfaucet.xyz/delivery-score?url=https://apexfaucet.xyz/api/x402/page-markdown.
On HTTP 402, pay the terms with your own wallet.`,
schema: DeliveryScoreSchema,
})
async deliveryScore(args: z.infer<typeof DeliveryScoreSchema>): Promise<string> {
if (!args.url.startsWith("https://")) {
return JSON.stringify({ success: false, error: "url must start with https://" });
}
const params = new URLSearchParams({ url: args.url });
return readPublic(`${DELIVERY_SCORE}?${params.toString()}`);
}

supportsNetwork = () => true;
}

export const apexActionProvider = () => new ApexActionProvider();
2 changes: 2 additions & 0 deletions typescript/agentkit/src/action-providers/apex/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./apexActionProvider";
export * from "./schemas";
33 changes: 33 additions & 0 deletions typescript/agentkit/src/action-providers/apex/schemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { z } from "zod";

export const TxCheckSchema = z
.object({
chain: z
.enum(["base", "solana"])
.default("base")
.describe("Chain of the unsigned transaction. base or solana."),
from: z
.string()
.optional()
.describe("Base sender (0x...), or the Solana signer when signer is omitted."),
to: z.string().optional().describe("Base contract (0x...). Required on Base unless raw is set."),
data: z.string().optional().describe("Base hex calldata. Required on Base unless raw is set."),
value: z.string().optional().describe("Base native value in wei."),
raw: z
.string()
.optional()
.describe("Base serialized unsigned transaction, or the Solana transaction when tx is omitted."),
signer: z.string().optional().describe("Solana account that would sign."),
tx: z.string().optional().describe("Unsigned Solana transaction, base64 or base58."),
})
.strip()
.describe("Check one unsigned transaction. Nothing is signed or broadcast.");

export const DeliveryScoreSchema = z
.object({
url: z
.string()
.describe("https x402 URL to score from 0 to 100. This action does not pay that URL."),
})
.strip()
.describe("Score an x402 URL.");
1 change: 1 addition & 0 deletions typescript/agentkit/src/action-providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ export * from "./zerion";
export * from "./zerodev";
export * from "./zeroX";
export * from "./zora";
export * from "./apex";
Loading