Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
518e191
add payment types and bump lock
odilitime Nov 4, 2025
432d79f
add cors/solana/viem
odilitime Nov 4, 2025
72713a2
add x402 middleware
odilitime Nov 4, 2025
ec26939
export x402 items
odilitime Nov 4, 2025
d2e2d98
new files
odilitime Nov 4, 2025
4f35c4e
support more than 3 chains, PaymentConfigDefinition
odilitime Nov 4, 2025
b9b403a
update payment configs
odilitime Nov 4, 2025
313587a
update exports for payment configs
odilitime Nov 4, 2025
699d8cd
update exports for payment configs
odilitime Nov 4, 2025
efaf0d1
getX402Health(), listX402Configs(), getPaymentConfig supports by agen…
odilitime Nov 4, 2025
a29a9c1
buildX402Response now takes runtime, client dev helpers, style
odilitime Nov 4, 2025
e21cdda
add more test info, express safety, remove unneed env vars
odilitime Nov 4, 2025
b4b92ea
new files
odilitime Nov 4, 2025
aced954
additional validation and typechecking
odilitime Nov 4, 2025
8a4a51f
new tests
odilitime Nov 4, 2025
d64e2a5
fix pricing, old env var clean up, return types
odilitime Nov 4, 2025
359e732
update tests
odilitime Nov 4, 2025
e780c64
EIP712DomainInfo/PaymentExtraMetadata/OutputSchemaType types
odilitime Nov 4, 2025
6a7c5b7
openapi => FieldDefinition, Check if this is an ERC-20 token transfer…
odilitime Nov 4, 2025
bf117a5
new files
odilitime Nov 5, 2025
17bfa42
export middleware functionality for extensibility
odilitime Nov 5, 2025
70dd39d
better validation, throw if problem
odilitime Nov 5, 2025
644b9b4
type changes, start up validation
odilitime Nov 5, 2025
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
39 changes: 32 additions & 7 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,19 @@
"@elizaos/core": "workspace:*",
"@elizaos/plugin-sql": "workspace:*",
"@sentry/node": "^10.16.0",
"@solana/web3.js": "^1.98.4",
"@types/express": "^5.0.2",
"@types/helmet": "^4.0.0",
"@types/multer": "^2.0.0",
"cors": "^2.8.5",
"dotenv": "^17.2.3",
"express": "^5.1.0",
"express-rate-limit": "^8.1.0",
"helmet": "^8.1.0",
"multer": "^2.0.1",
"path-to-regexp": "^8.2.0",
"socket.io": "^4.8.1",
"viem": "^2.38.6",
},
"devDependencies": {
"@elizaos/client": "workspace:*",
Expand Down Expand Up @@ -4156,27 +4159,27 @@

"@cypress/xvfb/debug": ["[email protected]", "", { "dependencies": { "ms": "^2.1.1" } }, "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ=="],

"@elizaos/api-client/@types/node": ["@types/node@24.9.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="],
"@elizaos/api-client/@types/node": ["@types/node@24.10.0", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-qzQZRBqkFsYyaSWXuEHc2WR9c0a0CXwiE5FWUvn7ZM+vdy1uZLfCunD38UzhuB7YN/J11ndbDBcTmOdxJo9Q7A=="],

"@elizaos/app/@vitejs/plugin-react": ["@vitejs/[email protected]", "", { "dependencies": { "@babel/core": "^7.28.0", "@babel/plugin-transform-react-jsx-self": "^7.27.1", "@babel/plugin-transform-react-jsx-source": "^7.27.1", "@rolldown/pluginutils": "1.0.0-beta.27", "@types/babel__core": "^7.20.5", "react-refresh": "^0.17.0" }, "peerDependencies": { "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" } }, "sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA=="],

"@elizaos/app/typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ=="],

"@elizaos/cli/@types/node": ["@types/node@24.9.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="],
"@elizaos/cli/@types/node": ["@types/node@24.10.0", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-qzQZRBqkFsYyaSWXuEHc2WR9c0a0CXwiE5FWUvn7ZM+vdy1uZLfCunD38UzhuB7YN/J11ndbDBcTmOdxJo9Q7A=="],

"@elizaos/cli/prettier": ["[email protected]", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="],

"@elizaos/cli/vite": ["[email protected]", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-ZWyE8YXEXqJrrSLvYgrRP7p62OziLW7xI5HYGWFzOvupfAlrLvURSzv/FyGyy0eidogEM3ujU+kUG1zuHgb6Ug=="],

"@elizaos/client/@types/node": ["@types/node@24.9.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="],
"@elizaos/client/@types/node": ["@types/node@24.10.0", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-qzQZRBqkFsYyaSWXuEHc2WR9c0a0CXwiE5FWUvn7ZM+vdy1uZLfCunD38UzhuB7YN/J11ndbDBcTmOdxJo9Q7A=="],

"@elizaos/client/prettier": ["[email protected]", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="],

"@elizaos/client/vite": ["[email protected]", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-ZWyE8YXEXqJrrSLvYgrRP7p62OziLW7xI5HYGWFzOvupfAlrLvURSzv/FyGyy0eidogEM3ujU+kUG1zuHgb6Ug=="],

"@elizaos/config/prettier": ["[email protected]", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="],

"@elizaos/core/@types/node": ["@types/node@24.9.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="],
"@elizaos/core/@types/node": ["@types/node@24.10.0", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-qzQZRBqkFsYyaSWXuEHc2WR9c0a0CXwiE5FWUvn7ZM+vdy1uZLfCunD38UzhuB7YN/J11ndbDBcTmOdxJo9Q7A=="],

"@elizaos/core/prettier": ["[email protected]", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="],

Expand All @@ -4202,7 +4205,7 @@

"@elizaos/plugin-redpill/ai": ["[email protected]", "", { "dependencies": { "@ai-sdk/provider": "1.1.3", "@ai-sdk/provider-utils": "2.2.8", "@ai-sdk/react": "1.2.12", "@ai-sdk/ui-utils": "1.2.11", "@opentelemetry/api": "1.9.0", "jsondiffpatch": "0.6.0" }, "peerDependencies": { "react": "^18 || ^19 || ^19.0.0-rc", "zod": "^3.23.8" }, "optionalPeers": ["react"] }, "sha512-dIE2bfNpqHN3r6IINp9znguYdhIOheKW2LDigAMrgt/upT3B8eBGPSCblENvaZGoq+hxaN9fSMzjWpbqloP+7Q=="],

"@elizaos/plugin-sql/@types/node": ["@types/node@24.9.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="],
"@elizaos/plugin-sql/@types/node": ["@types/node@24.10.0", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-qzQZRBqkFsYyaSWXuEHc2WR9c0a0CXwiE5FWUvn7ZM+vdy1uZLfCunD38UzhuB7YN/J11ndbDBcTmOdxJo9Q7A=="],

"@elizaos/plugin-sql/dotenv": ["[email protected]", "", {}, "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow=="],

Expand All @@ -4228,7 +4231,7 @@

"@elizaos/project-starter/tailwind-merge": ["[email protected]", "", {}, "sha512-P+Vu1qXfzediirmHOC3xKGAYeZtPcV9g76X+xg2FD4tYgR71ewMA35Y3sCz3zhiN/dwefRpJX0yBcgwi1fXNQA=="],

"@elizaos/project-tee-starter/@types/node": ["@types/node@24.9.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="],
"@elizaos/project-tee-starter/@types/node": ["@types/node@24.10.0", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-qzQZRBqkFsYyaSWXuEHc2WR9c0a0CXwiE5FWUvn7ZM+vdy1uZLfCunD38UzhuB7YN/J11ndbDBcTmOdxJo9Q7A=="],

"@elizaos/project-tee-starter/@types/react": ["@types/[email protected]", "", { "dependencies": { "@types/prop-types": "*", "csstype": "^3.0.2" } }, "sha512-RFA/bURkcKzx/X9oumPG9Vp3D3JUgus/d0b67KB0t5S/raciymilkOa66olh78MUI92QLbEJevO7rvqU/kjwKA=="],

Expand All @@ -4244,10 +4247,14 @@

"@elizaos/project-tee-starter/tailwind-merge": ["[email protected]", "", {}, "sha512-P+Vu1qXfzediirmHOC3xKGAYeZtPcV9g76X+xg2FD4tYgR71ewMA35Y3sCz3zhiN/dwefRpJX0yBcgwi1fXNQA=="],

"@elizaos/server/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="],
"@elizaos/server/@solana/web3.js": ["@solana/[email protected]", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "@solana/codecs-numbers": "^2.1.0", "agentkeepalive": "^4.5.0", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw=="],

"@elizaos/server/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-qzQZRBqkFsYyaSWXuEHc2WR9c0a0CXwiE5FWUvn7ZM+vdy1uZLfCunD38UzhuB7YN/J11ndbDBcTmOdxJo9Q7A=="],

"@elizaos/server/prettier": ["[email protected]", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="],

"@elizaos/server/viem": ["[email protected]", "", { "dependencies": { "@noble/curves": "1.9.1", "@noble/hashes": "1.8.0", "@scure/bip32": "1.7.0", "@scure/bip39": "1.6.0", "abitype": "1.1.0", "isows": "1.0.7", "ox": "0.9.6", "ws": "8.18.3" }, "peerDependencies": { "typescript": ">=5.0.4" }, "optionalPeers": ["typescript"] }, "sha512-aqO6P52LPXRjdnP6rl5Buab65sYa4cZ6Cpn+k4OLOzVJhGIK8onTVoKMFMT04YjDfyDICa/DZyV9HmvLDgcjkw=="],

"@elizaos/service-interfaces/prettier": ["[email protected]", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="],

"@elizaos/test-utils/dotenv": ["[email protected]", "", {}, "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg=="],
Expand Down Expand Up @@ -4936,6 +4943,16 @@

"@elizaos/project-tee-starter/react-dom/scheduler": ["[email protected]", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ=="],

"@elizaos/server/@solana/web3.js/bn.js": ["[email protected]", "", {}, "sha512-v2YAxEmKaBLahNwE1mjp4WON6huMNeuDvagFZW+ASCuA/ku0bXR9hSMw0XpiqMoA3+rmnyck/tPRSFQkoC9Cuw=="],

"@elizaos/server/@solana/web3.js/node-fetch": ["[email protected]", "", { "dependencies": { "whatwg-url": "^5.0.0" }, "peerDependencies": { "encoding": "^0.1.0" }, "optionalPeers": ["encoding"] }, "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A=="],

"@elizaos/server/viem/@noble/curves": ["@noble/[email protected]", "", { "dependencies": { "@noble/hashes": "1.8.0" } }, "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA=="],

"@elizaos/server/viem/abitype": ["[email protected]", "", { "peerDependencies": { "typescript": ">=5.0.4", "zod": "^3.22.0 || ^4.0.0" }, "optionalPeers": ["typescript", "zod"] }, "sha512-6Vh4HcRxNMLA0puzPjM5GBgT4aAcFGKZzSgAXvuZ27shJP6NEpielTuqbBmZILR5/xd0PizkBGy5hReKz9jl5A=="],

"@elizaos/server/viem/ox": ["[email protected]", "", { "dependencies": { "@adraffy/ens-normalize": "^1.11.0", "@noble/ciphers": "^1.3.0", "@noble/curves": "1.9.1", "@noble/hashes": "^1.8.0", "@scure/bip32": "^1.7.0", "@scure/bip39": "^1.6.0", "abitype": "^1.0.9", "eventemitter3": "5.0.1" }, "peerDependencies": { "typescript": ">=5.4.0" }, "optionalPeers": ["typescript"] }, "sha512-8SuCbHPvv2eZLYXrNmC0EC12rdzXQLdhnOMlHDW2wiCPLxBrOOJwX5L5E61by+UjTPOryqQiRSnjIKCI+GykKg=="],

"@esbuild-kit/core-utils/esbuild/@esbuild/android-arm": ["@esbuild/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw=="],

"@esbuild-kit/core-utils/esbuild/@esbuild/android-arm64": ["@esbuild/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ=="],
Expand Down Expand Up @@ -5328,6 +5345,10 @@

"@elizaos/project-tee-starter/jsdom/whatwg-url/tr46": ["[email protected]", "", { "dependencies": { "punycode": "^2.3.1" } }, "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw=="],

"@elizaos/server/@solana/web3.js/node-fetch/whatwg-url": ["[email protected]", "", { "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } }, "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw=="],

"@elizaos/server/viem/ox/eventemitter3": ["[email protected]", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="],

"@inquirer/core/wrap-ansi/strip-ansi/ansi-regex": ["[email protected]", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],

"@lerna/create/rimraf/glob/minimatch": ["[email protected]", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA=="],
Expand Down Expand Up @@ -5422,6 +5443,10 @@

"@elizaos/project-tee-starter/jsdom/tough-cookie/tldts/tldts-core": ["[email protected]", "", {}, "sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA=="],

"@elizaos/server/@solana/web3.js/node-fetch/whatwg-url/tr46": ["[email protected]", "", {}, "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="],

"@elizaos/server/@solana/web3.js/node-fetch/whatwg-url/webidl-conversions": ["[email protected]", "", {}, "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="],

"@lerna/create/rimraf/glob/minimatch/brace-expansion": ["[email protected]", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ=="],

"@lerna/create/rimraf/glob/path-scurry/minipass": ["[email protected]", "", {}, "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw=="],
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from './knowledge';
export * from './environment';
export * from './agent';
export * from './components';
export * from './payment';
export * from './plugin';
export * from './service';
export * from './model';
Expand Down
115 changes: 115 additions & 0 deletions packages/core/src/types/payment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* x402 Payment Types
*
* These types extend the core Route type to support payment protection.
* Plugin developers can import these from @elizaos/core without needing
* to depend on @elizaos/server.
*/

import type { Route } from './plugin.js';

/**
* Network configuration - supports multiple chains
* Can be extended by plugins to support additional networks
*/
export type Network = string;

/**
* Payment config definition that plugins can register
*/
export interface PaymentConfigDefinition {
network: string;
assetNamespace: string; // e.g., "erc20", "spl-token", "slip44"
assetReference: string; // e.g., contract address or token mint
paymentAddress: string; // Recipient address
symbol: string; // Display symbol (USDC, ETH, etc.)
chainId?: string; // Optional chain ID for CAIP-2 (e.g., "8453" for Base)
}

/**
* x402 configuration for routes
*/
export interface X402Config {
priceInCents: number;
paymentConfigs?: string[]; // Named configs, defaults to ['base_usdc']
}

/**
* Validation result for pre-payment parameter validation
*/
export interface X402ValidationResult {
valid: boolean;
error?: {
status: number;
message: string;
details?: any;
};
}

/**
* Validator function that checks request parameters before payment
* Returns validation result indicating if request is valid
*/
export type X402RequestValidator = (req: any) => X402ValidationResult | Promise<X402ValidationResult>;

/**
* OpenAPI parameter definition
*/
export interface X402OpenAPIParameter {
name: string;
in: 'path' | 'query' | 'header';
required?: boolean;
description?: string;
schema: {
type: string;
format?: string;
pattern?: string;
enum?: string[];
minimum?: number;
maximum?: number;
};
}

/**
* OpenAPI request body definition
*/
export interface X402OpenAPIRequestBody {
required?: boolean;
description?: string;
content: {
'application/json'?: { schema: any };
'multipart/form-data'?: { schema: any };
};
}

/**
* Extended Route interface to include payment properties
* Plugin developers can use this type when defining paid routes
*
* @example
* ```typescript
* import type { PaymentEnabledRoute } from '@elizaos/core';
*
* const routes: PaymentEnabledRoute[] = [{
* type: 'GET',
* path: '/api/premium-data',
* x402: {
* priceInCents: 10,
* paymentConfigs: ['base_usdc']
* },
* handler: async (req, res, runtime) => {
* // Your handler logic
* }
* }];
* ```
*/
export interface PaymentEnabledRoute extends Route {
x402?: X402Config;
description?: string;
openapi?: {
parameters?: X402OpenAPIParameter[];
requestBody?: X402OpenAPIRequestBody;
};
validator?: X402RequestValidator;
}

5 changes: 4 additions & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,18 @@
"@elizaos/core": "workspace:*",
"@elizaos/plugin-sql": "workspace:*",
"@sentry/node": "^10.16.0",
"@solana/web3.js": "^1.98.4",
"@types/express": "^5.0.2",
"@types/helmet": "^4.0.0",
"@types/multer": "^2.0.0",
"cors": "^2.8.5",
"dotenv": "^17.2.3",
"express": "^5.1.0",
"express-rate-limit": "^8.1.0",
"helmet": "^8.1.0",
"multer": "^2.0.1",
"path-to-regexp": "^8.2.0",
"socket.io": "^4.8.1"
"socket.io": "^4.8.1",
"viem": "^2.38.6"
}
}
28 changes: 26 additions & 2 deletions packages/server/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import {
validateContentTypeMiddleware,
createApiRateLimit,
} from '../middleware';
import {
createPaymentAwareHandler,
type PaymentEnabledRoute
} from '../middleware/x402';

/**
* Sets up Socket.io server for real-time messaging
Expand Down Expand Up @@ -177,7 +181,17 @@ export function createPluginRouteHandler(elizaOS: ElizaOS): express.RequestHandl
);
try {
if (route.handler) {
route.handler(req, res, runtime);
// Check if route has x402 payment protection
const paymentRoute = route as PaymentEnabledRoute;
if (paymentRoute.x402) {
logger.debug(`Route ${routePath} has x402 payment protection enabled`);
const paymentAwareHandler = createPaymentAwareHandler(paymentRoute);
if (paymentAwareHandler) {
paymentAwareHandler(req, res, runtime);
}
Comment on lines +189 to +191
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guard always evaluates to true.

Suggested change
if (paymentAwareHandler) {
paymentAwareHandler(req, res, runtime);
}
paymentAwareHandler(req, res, runtime);

Copilot uses AI. Check for mistakes.
} else {
route.handler(req, res, runtime);
}
handled = true;
}
} catch (error) {
Expand Down Expand Up @@ -226,7 +240,17 @@ export function createPluginRouteHandler(elizaOS: ElizaOS): express.RequestHandl
req.params = { ...(matched.params || {}) };
try {
if (route.handler) {
route.handler(req, res, runtime);
// Check if route has x402 payment protection
const paymentRoute = route as PaymentEnabledRoute;
if (paymentRoute.x402) {
logger.debug(`Route ${routePath} has x402 payment protection enabled`);
const paymentAwareHandler = createPaymentAwareHandler(paymentRoute);
if (paymentAwareHandler) {
paymentAwareHandler(req, res, runtime);
}
Comment on lines +248 to +250
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guard always evaluates to true.

Suggested change
if (paymentAwareHandler) {
paymentAwareHandler(req, res, runtime);
}
paymentAwareHandler(req, res, runtime);

Copilot uses AI. Check for mistakes.
} else {
route.handler(req, res, runtime);
}
handled = true;
}
} catch (error) {
Expand Down
Loading
Loading