Skip to content

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')"
bash
python -m venv foursec-env
source foursec-env/bin/activate  # Linux/Mac
# foursec-env\Scripts\activate   # Windows

pip install x402-client httpx eth-account

JavaScript / 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 ethers

cURL / CLI ​

bash
npm install -g @x402/cli
x402 --version

Verify 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 ​

IssueSolution
ModuleNotFoundError: x402Run pip install x402-client
Connection refusedCheck firewall, API is at port 443
Insufficient balanceAdd USDC to wallet on Base network
Invalid chainEnsure wallet is on Base (chain ID 8453)

Built with x402 protocol on Base