primer-x402
Primer ecosystem toolkit for x402. Built on the official x402 SDK.
This package extends the official x402 SDK with Primer-specific infrastructure: our facilitator, SKALE network support, Robinhood Chain support, and Prism ERC-20 settlement.
Installation
pip install primer-x402
This automatically installs x402 as a dependency.
Quick Start
Using Primer's Facilitator
from primer_x402 import primer_facilitator, primer_facilitator_sync
# Async client
facilitator = primer_facilitator()
result = await facilitator.verify(payload, requirements)
# Sync client
facilitator_sync = primer_facilitator_sync()
result = facilitator_sync.verify(payload, requirements)
SKALE Networks (Gas-Free)
from primer_x402 import skale_networks
# Use SKALE for gas-free transactions
network = skale_networks.base # "eip155:1187947933"
network = skale_networks.base_sepolia # "eip155:324705682"
Robinhood Chain
from primer_x402 import robinhood_networks
# Use Robinhood Chain
network = robinhood_networks.mainnet # "eip155:4663"
network = robinhood_networks.testnet # "eip155:46630"
Prism ERC-20 Settlement
For standard ERC-20 tokens (not USDC/EURC), use Prism:
from eth_account import Account
from web3 import Web3
from primer_x402 import create_prism_payload, PrismPaymentParams
web3 = Web3(Web3.HTTPProvider("https://mainnet.base.org"))
account = Account.from_key("0x...")
payload = create_prism_payload(
account,
web3,
PrismPaymentParams(
token="0x...", # ERC-20 token address
to="0x...", # Recipient
value=1000000, # Amount in smallest unit
),
"eip155:8453",
)
Note: Payers must first approve the Prism contract (
0x402357ff1e18d42d0f14a5d56d6e1ebd741b3a86) to spend their tokens.
CLI
The package includes a CLI for scaffolding new x402 projects.
Create a Paid AI Proxy (Chutes)
Scaffold a FastAPI server that proxies Chutes (Bittensor Subnet 64) AI endpoints with x402 micropayments:
primer-x402 create chutes-proxy my-ai-api
cd my-ai-api
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install -r requirements.txt
Edit main.py to set your wallet address:
RECIPIENT = "0xYourWalletAddress"
Set your Chutes API key and run:
cp .env.example .env
# Edit .env with your CHUTES_API_KEY
export $(cat .env | xargs)
uvicorn main:app --reload
The generated proxy exposes these paid endpoints:
| Endpoint | Default Price |
|---|---|
/v1/chat/completions |
$0.001 |
/v1/completions |
$0.001 |
/v1/embeddings |
$0.0001 |
/v1/images/generations |
$0.01 |
Payments are verified via Primer's facilitator and accepted on Base mainnet. Edit the generated code to customize pricing, networks, or add additional endpoints.
API Reference
Facilitator
| Export | Description |
|---|---|
primer_facilitator() |
Async client for x402.primer.systems |
primer_facilitator_sync() |
Sync client for x402.primer.systems |
PRIMER_FACILITATOR_URL |
"https://x402.primer.systems" |
Networks
| Export | Value |
|---|---|
skale_networks.base |
"eip155:1187947933" |
skale_networks.base_sepolia |
"eip155:324705682" |
skale_rpc_urls.base |
"https://skale-base.skalenodes.com/v1/base" |
skale_rpc_urls.base_sepolia |
"https://base-sepolia-testnet.skalenodes.com/v1/..." |
robinhood_networks.mainnet |
"eip155:4663" |
robinhood_networks.testnet |
"eip155:46630" |
robinhood_rpc_urls.mainnet |
"https://rpc.mainnet.chain.robinhood.com" |
robinhood_rpc_urls.testnet |
"https://rpc.testnet.chain.robinhood.com" |
Prism Settlement
| Export | Description |
|---|---|
create_prism_payload(account, web3, params, network) |
Create signed ERC-20 payment |
get_prism_nonce(web3, user, token) |
Get current nonce for user/token |
PrismPaymentParams |
Dataclass for payment parameters |
PrismPayload |
TypedDict for the resulting payload |
PRISM_CONTRACT_ADDRESS |
"0x402357ff1e18d42d0f14a5d56d6e1ebd741b3a86" |
PRISM_ABI |
Contract ABI (minimal) |
ERC20_PAYMENT_TYPES |
EIP-712 type definitions |
Supported Networks
| Network | Chain ID | Facilitator |
|---|---|---|
| Base | eip155:8453 | ✓ Primer |
| Base Sepolia | eip155:84532 | ✓ Primer |
| SKALE Base | eip155:1187947933 | ✓ Primer |
| SKALE Base Sepolia | eip155:324705682 | ✓ Primer |
| Robinhood Chain | eip155:4663 | ✓ Primer |
| Robinhood Chain Testnet | eip155:46630 | ✓ Primer |
Links
License
Apache-2.0 — Primer Systems
Metadata
Release files for primer-x402 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| primer_x402-1.1.0.tar.gz | 13.7 kB | Without provenance | Details for primer_x402-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| primer_x402-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for primer_x402-1.1.0-py3-none-any.whl |
Total release size: 26.1 kB
Release files / primer_x402-1.1.0.tar.gz
| Download URL | primer_x402-1.1.0.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4aecdd55d65b7f73b38dd40ac33ee30aa0556bd82889721f407c78c952f0bafc
|
|
BLAKE2b-256 checksum How to use checksums |
ffb4b98c6563cafc02599de5cec571d261044aaadb3d9cab4d27e213d6b6603e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / primer_x402-1.1.0-py3-none-any.whl
| Download URL | primer_x402-1.1.0-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d6dfe4e0fce842de689ed1f31b325f14d52ae18d244ae9f5b0d3ff6e3423b27
|
|
BLAKE2b-256 checksum How to use checksums |
3223f4342ebe83e6e6a140236cec6c078287eb45d1a2cd78f026a717d2a14779
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for primer-x402 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.