### Install Go Dependencies Source: https://github.com/abstract-foundation/abstract-docs/blob/main/ai-agents/payments/x402/accepting-payments.mdx Install the x402 Go package using go get. ```bash go get github.com/coinbase/x402/go ``` -------------------------------- ### Gin Payment Middleware Setup (Go) Source: https://github.com/abstract-foundation/abstract-docs/blob/main/x402/accepting-payments.mdx Configure and add the x402 payment middleware to a Gin web server. This example demonstrates setting up routes and payment schemes. ```go package main import ( "net/http" "time" "github.com/gin-gonic/gin" "github.com/x402/x402-go/evm" "github.com/x402/x402-go/ginmw" "github.com/x402/x402-go/schemas" "github.com/x402/x402-go/server" ) func main() { r := gin.Default() payTo := "0xYourWalletAddress" facilitatorClient := server.NewHTTPFacilitatorClient( server.FacilitatorConfig{ URL: "https://facilitator.x402.abs.xyz", }, ) r.Use(ginmw.PaymentMiddleware(ginmw.PaymentMiddlewareConfig{ Server: server.NewX402ResourceServer(facilitatorClient), Routes: map[string]ginmw.RouteConfig{ "GET /weather": { Accepts: []PaymentOption{ { Scheme: "exact", Price: "$0.001", Network: "eip155:2741", PayTo: payTo, }, }, Description: "Get weather data", MimeType: "application/json", }, }, Facilitator: facilitatorClient, Schemes: []ginmw.SchemeConfig{ { Network: x402.Network("eip155:*"), Server: evm.NewExactEvmScheme(), }, }, Timeout: 30 * time.Second, })) r.GET("/weather", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "weather": "sunny", "temperature": 70, }) }) r.Run(":4021") } ``` -------------------------------- ### Make Paid Requests with Go's http Client Source: https://github.com/abstract-foundation/abstract-docs/blob/main/x402/making-payments.mdx This Go example demonstrates how to wrap the standard `net/http` client with x402 payment support. It shows the setup for the x402 client and the registration of an EVM payment scheme. ```go package main import ( "context" "encoding/json" "fmt" "net/http" "os" "time" x402 "github.com/coinbase/x402/go" x402http "github.com/coinbase/x402/go/http" evm "github.com/coinbase/x402/go/mechanisms/evm/exact/client" evmsigners "github.com/coinbase/x402/go/signers/evm" ) func main() { evmSigner, _ := evmsigners.NewClientSignerFromPrivateKey( os.Getenv("PRIVATE_KEY"), ) x402Client := x402.Newx402Client(). Register("eip155:*", evm.NewExactEvmScheme(evmSigner)) httpClient := x402http.WrapHTTPClientWithPayment( http.DefaultClient, x402http.Newx402HTTPClient(x402Client), ) ctx, cancel := context.WithTimeout( context.Background(), 30*time.Second, ) defer cancel() req, _ := http.NewRequestWithContext( ctx, "GET", "https://api.example.com/weather", nil, ) resp, err := httpClient.Do(req) if err != nil { fmt.Printf("Request failed: %v\n", err) return } defer resp.Body.Close() var data map[string]interface{} json.NewDecoder(resp.Body).Decode(&data) fmt.Printf("Response: %+v\n", data) } ``` -------------------------------- ### Make Paid Requests with Python's requests (Sync) Source: https://github.com/abstract-foundation/abstract-docs/blob/main/x402/making-payments.mdx This synchronous Python example demonstrates using the `requests` library with x402 payment support. It covers setting up the x402 client and making a GET request. ```python import os from eth_account import Account from x402 import x402ClientSync from x402.http.clients import x402_requests from x402.mechanisms.evm import EthAccountSigner from x402.mechanisms.evm.exact.register import register_exact_evm_client def main() -> None: client = x402ClientSync() account = Account.from_key(os.getenv("PRIVATE_KEY")) register_exact_evm_client(client, EthAccountSigner(account)) with x402_requests(client) as session: response = session.get("https://api.example.com/weather") print(f"Response: {response.text}") main() ``` -------------------------------- ### Make Paid Requests with Python's httpx (Async) Source: https://github.com/abstract-foundation/abstract-docs/blob/main/x402/making-payments.mdx This asynchronous Python example shows how to use the `httpx` client with x402 payment support. It demonstrates registering an EVM signer and making a GET request. ```python import asyncio import os from eth_account import Account from x402 import x402Client from x402.http.clients import x402HttpxClient from x402.mechanisms.evm import EthAccountSigner from x402.mechanisms.evm.exact.register import register_exact_evm_client async def main() -> None: client = x402Client() account = Account.from_key(os.getenv("PRIVATE_KEY")) register_exact_evm_client(client, EthAccountSigner(account)) async with x402HttpxClient(client) as http: response = await http.get("https://api.example.com/weather") await response.aread() print(f"Response: {response.text}") asyncio.run(main()) ``` -------------------------------- ### Install Python SDK Source: https://github.com/abstract-foundation/abstract-docs/blob/main/ai-agents/payments/x402/making-payments.mdx Install the x402 Python SDK with httpx support. ```bash pip install "x402[httpx]" ``` -------------------------------- ### Create Project and Install Dependencies Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/applications/ethers.mdx Sets up a new Node.js project and installs the necessary zksync-ethers and ethers libraries. ```bash mkdir my-abstract-app && cd my-abstract-app npm init -y npm install zksync-ethers@6 ethers@6 ``` -------------------------------- ### Install Fetch SDK Source: https://github.com/abstract-foundation/abstract-docs/blob/main/ai-agents/payments/x402/making-payments.mdx Install the necessary packages for using the Fetch API with x402. ```bash npm install @x402/fetch @x402/core @x402/evm viem ``` -------------------------------- ### FastAPI Payment Middleware Setup (Python) Source: https://github.com/abstract-foundation/abstract-docs/blob/main/x402/accepting-payments.mdx Integrate x402 payment middleware into a FastAPI application. This example shows how to configure routes and the payment server. ```python from typing import Any from fastapi import FastAPI from x402.http import FacilitatorConfig, HTTPFacilitatorClient, PaymentOption from x402.http.middleware.fastapi import PaymentMiddlewareASGI from x402.http.types import RouteConfig from x402.mechanisms.evm.exact import ExactEvmServerScheme from x402.schemas import Network from x402.server import x402ResourceServer app = FastAPI() pay_to = "0xYourWalletAddress" NETWORK: Network = "eip155:2741" facilitator = HTTPFacilitatorClient( FacilitatorConfig(url="https://facilitator.x402.abs.xyz") ) server = x402ResourceServer(facilitator) server.register(NETWORK, ExactEvmServerScheme()) routes: dict[str, RouteConfig] = { "GET /weather": RouteConfig( accepts=[ PaymentOption( scheme="exact", pay_to=pay_to, price="$0.001", network=NETWORK, ), ], mime_type="application/json", description="Weather report", ), } app.add_middleware(PaymentMiddlewareASGI, routes=routes, server=server) @app.get("/weather") async def get_weather() -> dict[str, Any]: return {"weather": "sunny", "temperature": 70} if __name__ == "__main__": import uvicorn uvicorn.run(app, host="0.0.0.0", port=4021) ``` -------------------------------- ### Install System Contracts Library Source: https://github.com/abstract-foundation/abstract-docs/blob/main/how-abstract-works/native-account-abstraction/paymasters.mdx Install the system contracts library for your project. Use npm for Hardhat or forge install for Foundry. ```bash npm install @matterlabs/zksync-contracts ``` ```bash forge install matter-labs/era-contracts ``` -------------------------------- ### Install agw-client Package Source: https://github.com/abstract-foundation/abstract-docs/blob/main/abstract-global-wallet/agw-client/getting-started.mdx Install the agw-client and viem packages using your preferred package manager. ```bash npm npm install @abstract-foundation/agw-client viem ``` ```bash yarn yarn add @abstract-foundation/agw-client viem ``` ```bash pnpm pnpm add @abstract-foundation/agw-client viem ``` ```bash bun bun add @abstract-foundation/agw-client viem ``` -------------------------------- ### Flask Payment Middleware Setup (Python) Source: https://github.com/abstract-foundation/abstract-docs/blob/main/x402/accepting-payments.mdx Add x402 payment middleware to a Flask application. This example configures routes and the payment server for handling payments. ```python from flask import Flask, jsonify from x402.http import ( FacilitatorConfig, HTTPFacilitatorClientSync, PaymentOption, ) from x402.http.middleware.flask import payment_middleware from x402.http.types import RouteConfig from x402.mechanisms.evm.exact import ExactEvmServerScheme from x402.schemas import Network from x402.server import x402ResourceServerSync app = Flask(__name__) pay_to = "0xYourWalletAddress" NETWORK: Network = "eip155:2741" facilitator = HTTPFacilitatorClientSync( FacilitatorConfig(url="https://facilitator.x402.abs.xyz") ) server = x402ResourceServerSync(facilitator) server.register(NETWORK, ExactEvmServerScheme()) routes: dict[str, RouteConfig] = { "GET /weather": RouteConfig( accepts=[ PaymentOption( scheme="exact", pay_to=pay_to, price="$0.001", network=NETWORK, ), ], mime_type="application/json", description="Weather report", ), } payment_middleware(app, routes=routes, server=server) @app.route("/weather") def get_weather(): return jsonify({"weather": "sunny", "temperature": 70}) if __name__ == "__main__": app.run(host="0.0.0.0", port=4021) ``` -------------------------------- ### Install Dependencies Source: https://github.com/abstract-foundation/abstract-docs/blob/main/abstract-global-wallet/agw-react/integrating-with-connectkit.mdx Install the necessary packages for AGW, wagmi, viem, and ConnectKit using your preferred package manager. ```bash npm install @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem connectkit @tanstack/react-query @rainbow-me/rainbowkit ``` ```bash yarn add @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem connectkit @tanstack/react-query @rainbow-me/rainbowkit ``` ```bash pnpm add @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem connectkit @tanstack/react-query @rainbow-me/rainbowkit ``` ```bash bun add @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem connectkit @tanstack/react-query @rainbow-me/rainbowkit ``` -------------------------------- ### Install Viem Package Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/applications/viem.mdx Install the Viem package using npm. ```bash npm install viem ``` -------------------------------- ### Start Documentation Development Server Source: https://github.com/abstract-foundation/abstract-docs/blob/main/README.md Starts the local development server for the documentation. After running this command, the documentation can be accessed at http://localhost:3000. ```bash mintlify dev ``` -------------------------------- ### Install foundry-zksync Toolchain Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/smart-contracts/foundry/installation.mdx Download and execute the foundry-zksync installation script. This command fetches the script and pipes it directly to bash for execution. ```bash curl -L https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/install-foundry-zksync | bash ``` -------------------------------- ### Install Dependencies (bun) Source: https://github.com/abstract-foundation/abstract-docs/blob/main/abstract-global-wallet/agw-react/integrating-with-rainbowkit.mdx Install the necessary packages for integrating Abstract Global Wallet with RainbowKit using bun. ```bash bun add @abstract-foundation/agw-react @abstract-foundation/agw-client @rainbow-me/rainbowkit wagmi viem@2.x @tanstack/react-query ``` -------------------------------- ### Install Python SDK (requests) Source: https://github.com/abstract-foundation/abstract-docs/blob/main/x402/making-payments.mdx Install the x402 Python SDK with requests support using pip. ```bash pip install "x402[requests]" ``` -------------------------------- ### Run foundry-zksync Installer Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/smart-contracts/foundry/installation.mdx Execute the foundryup-zksync command to install forge, cast, and anvil. This command should be run after the installation script has been downloaded and executed. ```bash foundryup-zksync ``` -------------------------------- ### Install Axios SDK Source: https://github.com/abstract-foundation/abstract-docs/blob/main/ai-agents/payments/x402/making-payments.mdx Install the necessary packages for using the Axios API with x402. ```bash npm install @x402/axios @x402/core @x402/evm viem axios ``` -------------------------------- ### Install Dependencies (npm) Source: https://github.com/abstract-foundation/abstract-docs/blob/main/abstract-global-wallet/agw-react/integrating-with-rainbowkit.mdx Install the necessary packages for integrating Abstract Global Wallet with RainbowKit using npm. ```bash npm install @abstract-foundation/agw-react @abstract-foundation/agw-client @rainbow-me/rainbowkit wagmi viem@2.x @tanstack/react-query ``` -------------------------------- ### Install hardhat-zksync with bun Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/smart-contracts/hardhat/installation.mdx Install the `@matter-labs/hardhat-zksync` package as a development dependency using bun. ```bash bun add -D @matterlabs/hardhat-zksync ``` -------------------------------- ### Install Abstract Hardhat Dependencies Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/smart-contracts/hardhat/get-started.mdx Install the necessary Hardhat plugins and libraries for working with Abstract smart contracts. ```bash npm install -D @matterlabs/hardhat-zksync zksync-ethers@6 ethers@6 ``` -------------------------------- ### Install Hono Dependencies Source: https://github.com/abstract-foundation/abstract-docs/blob/main/ai-agents/payments/x402/accepting-payments.mdx Install the necessary x402 packages for Hono applications. ```bash npm install @x402/hono @x402/core @x402/evm ``` -------------------------------- ### Install Next.js Dependencies Source: https://github.com/abstract-foundation/abstract-docs/blob/main/ai-agents/payments/x402/accepting-payments.mdx Install the necessary x402 packages for Next.js applications. ```bash npm install @x402/next @x402/core @x402/evm ``` -------------------------------- ### Install hardhat-zksync with pnpm Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/smart-contracts/hardhat/installation.mdx Install the `@matter-labs/hardhat-zksync` package as a development dependency using pnpm. ```bash pnpm add -D @matterlabs/hardhat-zksync ``` -------------------------------- ### Install Mintlify CLI Source: https://github.com/abstract-foundation/abstract-docs/blob/main/README.md Installs the Mintlify command-line interface globally. This is required to build and serve the documentation locally. ```bash npm install -g mintlify ``` -------------------------------- ### Install AGW and Thirdweb Dependencies Source: https://github.com/abstract-foundation/abstract-docs/blob/main/abstract-global-wallet/agw-react/integrating-with-thirdweb.mdx Install the required packages for Abstract Global Wallet and Thirdweb integration using your preferred package manager. ```bash npm install @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem thirdweb ``` ```bash yarn add @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem thirdweb ``` ```bash pnpm add @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem thirdweb ``` ```bash bun add @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem thirdweb ``` -------------------------------- ### Install Dependencies (yarn) Source: https://github.com/abstract-foundation/abstract-docs/blob/main/abstract-global-wallet/agw-react/integrating-with-rainbowkit.mdx Install the necessary packages for integrating Abstract Global Wallet with RainbowKit using yarn. ```bash yarn add @abstract-foundation/agw-react @abstract-foundation/agw-client @rainbow-me/rainbowkit wagmi viem@2.x @tanstack/react-query ``` -------------------------------- ### Install hardhat-zksync with npm Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/smart-contracts/hardhat/installation.mdx Install the `@matter-labs/hardhat-zksync` package as a development dependency using npm. ```bash npm install -D @matterlabs/hardhat-zksync ``` -------------------------------- ### Install Dependencies (pnpm) Source: https://github.com/abstract-foundation/abstract-docs/blob/main/abstract-global-wallet/agw-react/integrating-with-rainbowkit.mdx Install the necessary packages for integrating Abstract Global Wallet with RainbowKit using pnpm. ```bash pnpm add @abstract-foundation/agw-react @abstract-foundation/agw-client @rainbow-me/rainbowkit wagmi viem@2.x @tanstack/react-query ``` -------------------------------- ### Install System Contracts for Hardhat Source: https://github.com/abstract-foundation/abstract-docs/blob/main/how-abstract-works/system-contracts/using-system-contracts.mdx Install the @matterlabs/zksync-contracts package for Hardhat projects to access system contracts. ```bash npm install @matterlabs/zksync-contracts ``` -------------------------------- ### Start a local ZKsync node Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/smart-contracts/hardhat/testing-contracts.mdx Use the zksync-cli to start a local development node. Docker is required. Select the 'anvil-zksync' option for a quick startup with no persisted state. ```bash npx zksync-cli dev start ``` ```bash ❯ anvil-zksync - Quick startup, no persisted state, only L2 node - zkcli-in-memory-node Dockerized node - Persistent state, includes L1 and L2 nodes - zkcli-dockerized-node ``` ```bash anvil-zksync started v0.3.2: - ZKsync Node (L2): - Chain ID: 260 - RPC URL: http://127.0.0.1:8011 - Rich accounts: https://docs.zksync.io/zksync-era/tooling/local-setup/anvil-zksync-node#pre-configured-rich-wallets ``` -------------------------------- ### Install Dependencies for AGW and Dynamic Source: https://github.com/abstract-foundation/abstract-docs/blob/main/abstract-global-wallet/agw-react/integrating-with-dynamic.mdx Install the required packages for integrating Abstract Global Wallet with Dynamic using npm, yarn, pnpm, or bun. ```bash npm install @abstract-foundation/agw-react @abstract-foundation/agw-client @dynamic-labs/sdk-react-core @dynamic-labs/ethereum @dynamic-labs-connectors/abstract-global-wallet-evm viem ``` ```bash yarn add @abstract-foundation/agw-react @abstract-foundation/agw-client @dynamic-labs/sdk-react-core @dynamic-labs/ethereum @dynamic-labs-connectors/abstract-global-wallet-evm viem ``` ```bash pnpm add @abstract-foundation/agw-react @abstract-foundation/agw-client @dynamic-labs/sdk-react-core @dynamic-labs/ethereum @dynamic-labs-connectors/abstract-global-wallet-evm viem ``` ```bash bun add @abstract-foundation/agw-react @abstract-foundation/agw-client @dynamic-labs/sdk-react-core @dynamic-labs/ethereum @dynamic-labs-connectors/abstract-global-wallet-evm viem ``` -------------------------------- ### Install AGW Dependencies Source: https://github.com/abstract-foundation/abstract-docs/blob/main/abstract-global-wallet/agw-react/native-integration.mdx Install the necessary packages for Abstract Global Wallet integration using npm, yarn, pnpm, or bun. ```bash npm install @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem@2.x @tanstack/react-query ``` ```bash yarn add @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem@2.x @tanstack/react-query ``` ```bash pnpm add @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem@2.x @tanstack/react-query ``` ```bash bun add @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem@2.x @tanstack/react-query ``` -------------------------------- ### Install OpenZeppelin Contracts Source: https://github.com/abstract-foundation/abstract-docs/blob/main/how-abstract-works/native-account-abstraction/signature-validation.mdx Use this command to install the OpenZeppelin contracts library, which provides utilities for smart contract development, including signature checking. ```bash npm install @openzeppelin/contracts ``` -------------------------------- ### Install agw-react and Dependencies (bun) Source: https://github.com/abstract-foundation/abstract-docs/blob/main/abstract-global-wallet/agw-react/getting-started.mdx Install the agw-react package along with necessary dependencies like wagmi, viem, and @tanstack/react-query using bun. ```bash bun add @abstract-foundation/agw-react wagmi viem@2.x @tanstack/react-query ``` -------------------------------- ### Install Dependencies for AGW and Privy Source: https://github.com/abstract-foundation/abstract-docs/blob/main/abstract-global-wallet/agw-react/integrating-with-privy.mdx Install the necessary packages for Abstract Global Wallet and Privy integration using npm, yarn, pnpm, or bun. ```bash npm install @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem @tanstack/react-query ``` ```bash yarn add @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem @tanstack/react-query ``` ```bash pnpm add @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem @tanstack/react-query ``` ```bash bun add @abstract-foundation/agw-react @abstract-foundation/agw-client wagmi viem @tanstack/react-query ``` -------------------------------- ### Recommended Thirdweb Project Setup Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/applications/thirdweb.mdx CLI prompts for creating a new thirdweb project with recommended settings. ```bash ✔ What type of project do you want to create? › App ✔ What is your project named? … my-abstract-app ✔ What framework do you want to use? › Next.js ``` -------------------------------- ### Start the MCP Server Source: https://github.com/abstract-foundation/abstract-docs/blob/main/ai-agents/wallet-access/run-as-mcp.mdx Starts the AGW CLI's built-in MCP server with strict sanitization enabled. This is the primary command to get the server running. ```bash agw-cli mcp serve --sanitize strict ``` -------------------------------- ### Start Development Server Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/applications/thirdweb.mdx Run the development server to view your application locally. ```bash npm run dev ``` -------------------------------- ### Express Payment Middleware Setup Source: https://github.com/abstract-foundation/abstract-docs/blob/main/ai-agents/payments/x402/accepting-payments.mdx Configure and use x402 payment middleware in an Express.js application. This example sets up a route that requires payment using the ExactEvmScheme. ```typescript import express from "express"; import { paymentMiddleware, x402ResourceServer } from "@x402/express"; import { ExactEvmScheme } from "@x402/evm/exact/server"; import { HTTPFacilitatorClient } from "@x402/core/server"; const app = express(); const payTo = "0xYourWalletAddress"; const facilitatorClient = new HTTPFacilitatorClient({ url: "https://facilitator.x402.abs.xyz", }); app.use( paymentMiddleware( { "GET /weather": { accepts: [ { scheme: "exact", price: "$0.001", network: "eip155:2741", payTo, }, ], description: "Weather data", mimeType: "application/json", }, }, new x402ResourceServer(facilitatorClient).register( "eip155:*", new ExactEvmScheme() ), ), ); app.get("/weather", (_req, res) => { res.send({ weather: "sunny", temperature: 70 }); }); ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/applications/thirdweb.mdx Change into the newly created project directory. ```bash cd my-abstract-app ``` -------------------------------- ### Bootstrap a New Project with Abstract CLI Source: https://github.com/abstract-foundation/abstract-docs/blob/main/abstract-global-wallet/agw-react/getting-started.mdx Use the create-abstract-app CLI to quickly set up a new React project with Abstract Global Wallet pre-configured. ```bash npx @abstract-foundation/create-abstract-app@latest my-app ``` -------------------------------- ### Install foundry-zksync Fork Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/smart-contracts/foundry/get-started.mdx Installs the foundry-zksync fork, which includes forge, cast, and anvil. Restart your terminal after installation. Ensure libusb is installed on macOS if encountering related errors. ```bash curl -L https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/install-foundry-zksync | bash ``` ```bash foundryup-zksync ``` ```bash export PATH="$PATH:/Users//.foundry/bin" ``` ```bash brew install libusb ``` -------------------------------- ### Install AGW CLI Source: https://github.com/abstract-foundation/abstract-docs/blob/main/ai-agents/wallet-access/install-and-authenticate.mdx Install the AGW CLI globally using npm. Ensure you have Node.js 18+ and npm 10+ installed. This command also verifies the installation by checking the CLI version. ```bash npm install -g @abstract-foundation/agw-cli agw-cli --version ``` -------------------------------- ### Install ZKsync CLI Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/zksync-cli.mdx Install the ZKsync CLI globally using npm. Ensure Node.js v18.0.0 or later is installed. ```bash npm install -g zksync-cli ``` -------------------------------- ### Go (Gin) Payment Middleware Setup Source: https://github.com/abstract-foundation/abstract-docs/blob/main/x402/accepting-payments.mdx This Go snippet demonstrates setting up the x402 payment middleware for a Gin web server. Ensure '0xYourWalletAddress' is replaced with your actual wallet address. ```go package main import ( "net/http" time x402 "github.com/coinbase/x402/go" x402http "github.com/coinbase/x402/go/http" ginmw "github.com/coinbase/x402/go/http/gin" evmn "github.com/coinbase/x402/go/mechanisms/evm/exact/server" "github.com/gin-gonic/gin" ) func main() { payTo := "0xYourWalletAddress" r := gin.Default() facilitatorClient := x402http.NewHTTPFacilitatorClient( &x402http.FacilitatorConfig{ URL: "https://facilitator.x402.abs.xyz", }, ) r.Use(ginmw.X402Payment(ginmw.Config{ Routes: x402http.RoutesConfig{ "GET /weather": { Accepts: x402http.PaymentOptions{ { ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/abstract-foundation/abstract-docs/blob/main/ai-agents/payments/x402/accepting-payments.mdx Install the x402 Python package using pip. ```bash pip install x402 ``` -------------------------------- ### Next.js Route Handler with x402 Source: https://github.com/abstract-foundation/abstract-docs/blob/main/x402/accepting-payments.mdx This example shows how to set up a shared x402 server instance and wrap a Next.js route handler with `withX402`. Remember to replace '0xYourWalletAddress' with your wallet address. ```typescript // lib/x402.ts import { x402ResourceServer } from "@x402/core/server"; import { HTTPFacilitatorClient } from "@x402/core/server"; import { ExactEvmScheme } from "@x402/evm/exact/server"; export const payTo = "0xYourWalletAddress"; const facilitatorClient = new HTTPFacilitatorClient({ url: "https://facilitator.x402.abs.xyz", }); export const server = new x402ResourceServer(facilitatorClient); server.register("eip155:*", new ExactEvmScheme()); ``` ```typescript // app/api/weather/route.ts import { NextRequest, NextResponse } from "next/server"; import { withX402 } from "@x402/next"; import { server, payTo } from "../../../lib/x402"; const handler = async (_: NextRequest) => { return NextResponse.json( { weather: "sunny", temperature: 72 }, { status: 200 }, ); }; export const GET = withX402( handler, { accepts: [ { scheme: "exact", price: "$0.001", network: "eip155:2741", payTo, }, ], description: "Access to weather API", mimeType: "application/json", }, server, ); ``` -------------------------------- ### Install Express Dependencies Source: https://github.com/abstract-foundation/abstract-docs/blob/main/ai-agents/payments/x402/accepting-payments.mdx Install the necessary x402 packages for Express.js applications. ```bash npm install @x402/express @x402/core @x402/evm ``` -------------------------------- ### Create a New Project with ZKsync CLI Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/zksync-cli.mdx Use the 'create' command to scaffold new projects for frontend, contracts, and scripting. This command initiates the project setup process. ```bash zksync-cli create ``` -------------------------------- ### Create New Project Directory Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/smart-contracts/hardhat/get-started.mdx Create a new directory for your project and navigate into it. ```bash mkdir my-abstract-project && cd my-abstract-project ``` -------------------------------- ### Initialize Hardhat Project Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/smart-contracts/hardhat/get-started.mdx Initialize a new Hardhat project within the current directory. ```bash npx hardhat init ``` -------------------------------- ### Install hardhat-zksync with yarn Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/smart-contracts/hardhat/installation.mdx Install the `@matter-labs/hardhat-zksync` package as a development dependency using yarn. ```bash yarn add -D @matterlabs/hardhat-zksync ``` -------------------------------- ### Example HelloAbstract Smart Contract Source: https://github.com/abstract-foundation/abstract-docs/blob/main/build-on-abstract/smart-contracts/hardhat/get-started.mdx A simple Solidity smart contract that returns a 'Hello, World!' string. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; contract HelloAbstract { function sayHello() public pure virtual returns (string memory) { return "Hello, World!"; } } ``` -------------------------------- ### Install MPP Packages Source: https://github.com/abstract-foundation/abstract-docs/blob/main/ai-agents/payments/mpp/charge-payments.mdx Install the necessary packages for MPP charge payments using npm. ```bash npm install @abstract-foundation/mpp mppx viem zod ```