Skip to content
Open
Changes from all commits
Commits
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
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,45 @@ resp = client.fetch_paid(
print(resp.status_code, resp.text[:120])
```

## Custom EVM example: Chain 138

Custom EVM networks work well with this client because selection happens via
CAIP-2 network ids rather than a hardcoded chain registry.

One useful production-style example is **Chain 138** (`eip155:138`):

| Field | Value |
| --- | --- |
| Chain name | DeFi Oracle Meta Mainnet |
| RPC | `https://rpc-http-pub.d-bis.org` |
| Explorer | `https://explorer.d-bis.org` |
| x402 origin | `https://x402.d-bis.org` |
| Well-known | `https://x402.d-bis.org/.well-known/x402.json` |
| Example asset | `cUSDC_V2` |

```python
def on_payment(parsed):
accept = select_payment_method(
parsed.accepts,
preferred_chain="eip155:138",
max_amount_usd=0.05,
)
return build_payment_header(accept, MY_ADDRESS, sign)

resp = client.fetch_paid(
"https://x402.d-bis.org/api/catalog",
on_payment=on_payment,
)
```

When signing an ERC-3009 authorization for Chain 138 `cUSDC_V2`, the EIP-712
domain values are:

- `name = "USD Coin (Compliant V2)"`
- `version = "2"`
- `chainId = 138`
- `verifyingContract = <accept.asset>`

## API

| Symbol | Purpose |
Expand Down Expand Up @@ -70,6 +109,19 @@ The x402 spec is scheme-agnostic: `erc3009`, `exact`, and future schemes (Solana

A reference signer built on [`eth-account`](https://pypi.org/project/eth-account/) is ~30 lines and lives in the [examples/ folder](https://github.com/cryptomotifs/x402-python/tree/main/examples) of the repo.

## Atomic x402 compatibility

This client also works well with merchants that use x402 as the front door to
an **atomic intent** flow:

1. the buyer signs an ERC-3009 authorization,
2. another actor executes settlement or downstream fulfillment,
3. the merchant returns the paid resource only after proof is accepted.

Because signing is a callback, the package does not force any particular
execution model. That keeps it useful for both direct settlement and
intent-driven corridors.

## Reference implementation / live demo

- **Live x402 demo**: <https://cipher-x402.vercel.app>
Expand Down