File size: 1,413 Bytes
dcf8b6b
df61c23
 
 
 
dcf8b6b
 
 
 
 
 
 
 
 
df61c23
 
dcf8b6b
 
 
 
 
 
 
 
 
df61c23
dcf8b6b
 
 
 
 
 
 
 
 
df61c23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Network configuration. Reads NETWORK from env (default: stellar:testnet).
// Set NETWORK=stellar:pubnet for mainnet deployments.
//
// Note: x402 uses CAIP-2-style chain IDs which differ from the Stellar SDK's
// network passphrase concept. Stellar mainnet is "stellar:pubnet" in x402-land.
import { Networks } from "@stellar/stellar-sdk";

const NETWORKS = {
  "stellar:testnet": {
    network: "stellar:testnet",
    passphrase: Networks.TESTNET,
    horizonUrl: "https://horizon-testnet.stellar.org",
    usdcIssuer: "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5",
  },
  "stellar:pubnet": {
    network: "stellar:pubnet",
    passphrase: Networks.PUBLIC,
    horizonUrl: "https://horizon.stellar.org",
    usdcIssuer: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
  },
};

const selected = process.env.NETWORK || "stellar:testnet";
if (!NETWORKS[selected]) {
  throw new Error(
    `Invalid NETWORK="${selected}". Must be "stellar:testnet" or "stellar:pubnet".`,
  );
}

export const NETWORK = NETWORKS[selected].network;
export const NETWORK_PASSPHRASE = NETWORKS[selected].passphrase;
export const HORIZON_URL = NETWORKS[selected].horizonUrl;
export const USDC_ISSUER = NETWORKS[selected].usdcIssuer;
export const FACILITATOR_URL =
  process.env.FACILITATOR_URL || "https://www.x402.org/facilitator";
export const FACILITATOR_API_KEY = process.env.OPENZEPPELIN_API_KEY || null;