`network` property should accept chain ids instead of arbitrary strings
Chain IDs are a well-established standard for referencing a specific EVM network. Using arbitrary strings like "base-sepolia" and "avalanche-fuji" makes for a frustrating developer experience (people agree), and makes it feel like x402 is a closed system where new chains have to get approved by Coinbase.
This file should not need to exist, but instead network should just be of type number (or bigint, i always forget the correct way to represent them but you get the point) https://github.com/coinbase/x402/blob/main/typescript/packages/x402/src/types/shared/network.ts
The error invalid_network already exists, which servers/facilitators can throw in the case that a given chain id isn't supported.
Adding on to this, we may want to use something like CAIP-2 as we add support for non-evm chains.
And for assets, perhaps CAIP-2 + CAIP-19
@notorious-d-e-v @gskril There was some discussion previously, see https://github.com/coinbase/x402/issues/137#issuecomment-2867663321
@notorious-d-e-v @gskril There was some discussion previously, see https://github.com/coinbase/x402/issues/137#issuecomment-2867663321
Nice thanks!
seconding this. was gonna open an issue asking for the same thing.
understand that chain ids can look evm centric, but we really need a way to define a chain (and asset) generically instead of hardcoding a set of constants.
a simple non-breaking change would be to accept integers for the network property as well as string.
integer = chain id = no mapping required string = network slug = requires mapping to id
wdyt @erikreppel-cb ?
Not Erik, but seems like it just adds complexity. We should choose one way and stick with it.
Note, that this is currently a blocker outside of just facilitator support. Even if a facilitator supports a custom network; the issue is actually created within the x402 based shared package on the network check.
Proposed Solution: allow the network support to be handled by the server & facilitator and remove from the client. Confirming that this does work with Faremeter's implementation as well both with string names (base-sepolia) and with CAIP-2
https://github.com/coinbase/x402/blob/2daa42f6a0e5a36c1bb19677fda2a74a6b466b06/typescript/packages/x402/src/shared/network.ts#L17