Skip to content

Add EVM/Base support — register ExactEvmScheme alongside Solana #2

Description

@Morganyyu

Context

The Vybe x402 gateway (x402-api.vybenetwork.xyz) now advertises payment options on both Solana mainnet and Base mainnet in every 402 challenge — see PR vybenetwork/x402-vybe-gateway#29. The 402 accepts[] array carries two entries:

"accepts": [
  { "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", "asset": "EPjF...", "payTo": "HJHe...", "extra": { "feePayer": "..." } },
  { "network": "eip155:8453",                            "asset": "0x83358...", "payTo": "0x5a55...", "extra": { "name": "USD Coin", "version": "2" } }
]

Coinbase's CDP facilitator settles both — the gateway is chain-agnostic for verify/settle.

What this SDK is missing

Today src/http.ts registers only ExactSvmScheme:

const scheme = new ExactSvmScheme(signer, ctx.rpcUrl ? { rpcUrl: ctx.rpcUrl } : undefined);
const x402 = new x402Client().register(info.network as any, scheme);

So an EVM-only agent using VybeClient can't pay — x402Client.payOrThrow(...) finds no matching scheme for the EVM entry in accepts[] and falls back to a 402 error. They'd have to drop down to raw @x402/fetch + @x402/evm.

Proposed shape (v0.2.0)

Extend the wallet/client surface so a single VybeClient can hold either or both:

const client = new VybeClient({
  wallet: { solana: loadKeypair(...), evm: { privateKey: "0x..." } },
  // or wallet: loadKeypair(...) for back-compat (still Solana-only)
});

Internally, register both schemes against x402Client:

const x402 = new x402Client();
if (solanaSigner) x402.register("solana:*", new ExactSvmScheme(solanaSigner, opts));
if (evmSigner)    x402.register("eip155:*", new ExactEvmScheme(evmSigner));

The auto-selector picks the first accept whose network matches a registered scheme. Solana clients keep working; EVM clients work for the first time; dual-wallet clients use the gateway's preferred chain (server controls the accepts[] order — Solana first today, configurable).

Out of scope

  • Cross-chain routing logic (let server decide via accepts[] order).
  • Polygon / Arbitrum / World — same pattern, but the gateway only advertises Base today. Adding them is a one-line gateway change when needed; client SDK should already handle them via eip155:* registration.

Not blocking

The current 0.1.1 release still works fine for Solana flows after the gateway swap. This is a feature-add, not a bug fix.

Acceptance

  • VybeClient accepts either Wallet (Solana, back-compat) or { solana?, evm? }
  • Both schemes registered against the underlying x402Client when both are provided
  • EVM paid call against x402-api.vybenetwork.xyz/v4/markets succeeds on Base (test against Base Sepolia first via the gateway's devnet config)
  • README updated with EVM code sample
  • No breaking change for existing Solana-only callers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions