Skip to content

Solana clients cannot pay for any GET endpoint (402 rejected before signing) #8

Description

@VickyXAI

Problem

doGetWithPayment rejects every 402 on a GET when bc.privateKey == nil:

https://github.com/BlockRunAI/blockrun-llm-go/blob/main/base_client.go#L358-L361

if resp.StatusCode == http.StatusPaymentRequired {
    if bc.privateKey == nil {
        return nil, &PaymentError{Message: "endpoint returned 402 but no wallet is configured"}
    }
    return bc.handleGetPaymentAndRetry(ctx, url, resp)
}

But privateKey is nil for Solana by design — the baseClient doc comment says so directly:

// The default chain is Base (EIP-712 signing with privateKey). When chain is
// "solana" the client pays USDC on Solana instead: privateKey is nil, solanaKey
// holds the bs58 signing key, and address is the bs58 public key.

So Solana clients never reach createPaymentPayload on a GET. They get a misleading "no wallet is configured" error even with a perfectly good Solana key loaded.

Impact

Every paid GET surface fails for Solana users:

  • dex.go:28/v1/zerox/
  • market.go:113,150,186 — market data
  • prediction_market.go:22 — prediction markets
  • defi.go:26/v1/defillama/
  • surf.go:244/v1/surf/

POST paths are unaffected (they use a different code path), which is why this has gone unnoticed.

Fix

Make the guard check that any signing key is configured, rather than the Base one specifically:

if bc.privateKey == nil && bc.solanaKey == "" {
    return nil, &PaymentError{Message: "endpoint returned 402 but no wallet is configured"}
}

base_client.go:359 is the only privateKey == nil guard in the repo, so this is a one-condition change. Worth a regression test that drives a Solana client through a paid GET.

Provenance

Surfaced by Codex during the /review pass on #7 while tracing callers of CreateSolanaPaymentPayload. Not introduced by #7 — kept out of that PR to avoid widening the blast radius of a payment-path change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions