Installation
Python
Requirements
- Python 3.9 or higher
- pip package manager
Install
bash
pip install x402-client httpx eth-account
# Verify installation
python -c "from x402.client import X402Client; print('OK installed')"Virtual Environment (Recommended)
bash
python -m venv foursec-env
source foursec-env/bin/activate # Linux/Mac
# foursec-env\Scripts\activate # Windows
pip install x402-client httpx eth-accountJavaScript / Node.js
Requirements
- Node.js 18 or higher
- npm or yarn
Install
bash
# Using npm
npm install @x402/client ethers
# Using yarn
yarn add @x402/client etherscURL / CLI
bash
npm install -g @x402/cli
x402 --versionVerify Everything Works
python
from x402.client import X402Client
from eth_account import Account
import httpx
wallet = Account.create()
client = X402Client(wallet=wallet)
# Test free endpoint (no payment needed)
response = httpx.get("https://api.foursec.xyz/health")
print(response.json())
# {"status": "healthy", "version": "2.1.0", ...}TIP
The /health endpoint is free — no wallet or payment needed. Use it to verify connectivity.
Network Configuration
python
client = X402Client(
wallet=wallet,
facilitator_url="https://x402.org/facilitator",
rpc_url="https://mainnet.base.org",
chain_id=8453, # Base mainnet
)Troubleshooting
| Issue | Solution |
|---|---|
| ModuleNotFoundError: x402 | Run pip install x402-client |
| Connection refused | Check firewall, API is at port 443 |
| Insufficient balance | Add USDC to wallet on Base network |
| Invalid chain | Ensure wallet is on Base (chain ID 8453) |