Operator-supplied mapping for a non-default EVM network. The x402 v2 SDK only knows about Base mainnet (``eip155:8453``) and Base Sepolia (``eip155:84532``) out of the box. Reaching any other EVM chain — SKALE, Polygon, Avalanche, Ethereum mainnet, etc. — needs two things: 1. A
| 12 | |
| 13 | |
| 14 | class ExtraNetwork(BaseModel): |
| 15 | """Operator-supplied mapping for a non-default EVM network. |
| 16 | |
| 17 | The x402 v2 SDK only knows about Base mainnet (``eip155:8453``) and |
| 18 | Base Sepolia (``eip155:84532``) out of the box. Reaching any other |
| 19 | EVM chain — SKALE, Polygon, Avalanche, Ethereum mainnet, etc. — needs |
| 20 | two things: |
| 21 | |
| 22 | 1. A facilitator that supports that chain (set ``facilitator_url`` on |
| 23 | :class:`X402Settings` to a facilitator advertising the chain in its |
| 24 | ``/supported`` response). |
| 25 | 2. A way for the SDK's price parser to convert a human-readable amount |
| 26 | (``"$0.01"``) into the right ERC-20 contract on that chain. |
| 27 | |
| 28 | This config carries #2 — the asset metadata the resource server |
| 29 | registers with x402 v2's ``ExactEvmServerScheme.add_money_parser`` so |
| 30 | pricing in the agent's ``execution_cost`` lands on the right asset. |
| 31 | The friendly key (the dict key in :attr:`X402Settings.extra_networks`) |
| 32 | is what operators write in their agent config; the ``caip2`` field is |
| 33 | what gets stamped on PaymentRequirements. |
| 34 | |
| 35 | Example — adding SKALE Europa Hub: |
| 36 | |
| 37 | .. code-block:: python |
| 38 | |
| 39 | extra_networks={ |
| 40 | "skale-europa": ExtraNetwork( |
| 41 | caip2="eip155:1187947933", |
| 42 | asset="0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20", |
| 43 | asset_name="Bridged USDC (SKALE Bridge)", |
| 44 | asset_decimals=6, |
| 45 | asset_eip712_version="2", |
| 46 | ) |
| 47 | } |
| 48 | """ |
| 49 | |
| 50 | caip2: str = Field( |
| 51 | ..., |
| 52 | description="CAIP-2 network identifier (e.g. 'eip155:1187947933').", |
| 53 | ) |
| 54 | asset: str = Field( |
| 55 | ..., |
| 56 | description="ERC-20 contract address that the facilitator settles in.", |
| 57 | ) |
| 58 | asset_symbol: str = Field(default="USDC", description="Token symbol.") |
| 59 | asset_name: str = Field( |
| 60 | default="USD Coin", |
| 61 | description="Token name. Goes into EIP-712 domain — must match the on-chain token's `name()`.", |
| 62 | ) |
| 63 | asset_decimals: int = Field( |
| 64 | default=6, |
| 65 | ge=0, |
| 66 | le=36, |
| 67 | description="Token decimals — used to scale Money to atomic units.", |
| 68 | ) |
| 69 | asset_eip712_version: str = Field( |
| 70 | default="2", |
| 71 | description="EIP-712 domain version — must match the on-chain token's domain separator.", |