Skip to content

Commit 11ae946

Browse files
committed
v1.1.0: Add 12 new PayAI-supported networks, update README
1 parent 7fbb2aa commit 11ae946

6 files changed

Lines changed: 149 additions & 65 deletions

File tree

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
x402-rails (1.0.0)
4+
x402-rails (1.1.0)
55
faraday (~> 2.0)
66
faraday-follow_redirects (~> 0.3)
77
rails (>= 7.0.0)

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Accept instant blockchain micropayments in your Rails applications using the [x402 payment protocol](https://www.x402.org/).
1010

11-
Supports Base, avalanche, and other blockchain networks.
11+
Supports 18 networks including Base, Polygon, Avalanche, Sei, Solana, and more.
1212

1313
## Features
1414

@@ -18,7 +18,7 @@ Supports Base, avalanche, and other blockchain networks.
1818
- **$0.001 minimum** payment amounts
1919
- **Optimistic & non-optimistic** settlement modes
2020
- **Automatic settlement** after successful responses
21-
- **Browser paywall** and API support
21+
- **API paywall** with 402 payment-required responses
2222
- **Rails 7.0+** compatible
2323

2424
## Example Video
@@ -145,7 +145,10 @@ X402.configure do |config|
145145
config.facilitator = ENV.fetch("X402_FACILITATOR_URL", "https://x402.org/facilitator")
146146

147147
# Blockchain network (default: "base-sepolia")
148-
# Options: "base-sepolia", "base", "avalanche-fuji", "avalanche"
148+
# Built-in: base, base-sepolia, polygon, polygon-amoy, avalanche, avalanche-fuji,
149+
# sei, sei-testnet, iotex, peaq, xlayer, xlayer-testnet,
150+
# skale-base, skale-base-sepolia, kiteai, kiteai-testnet,
151+
# solana, solana-devnet
149152
config.chain = ENV.fetch("X402_CHAIN", "base-sepolia")
150153

151154
# Payment token (default: "USDC")
@@ -165,7 +168,7 @@ end
165168
| ---------------- | -------- | -------------------------------- | --------------------------------------------------------------------------------- |
166169
| `wallet_address` | **Yes** | - | Your Ethereum wallet address where payments will be received |
167170
| `facilitator` | No | `"https://x402.org/facilitator"` | Facilitator service URL for payment verification and settlement |
168-
| `chain` | No | `"base-sepolia"` | Blockchain network to use (`base-sepolia`, `base`, `avalanche-fuji`, `avalanche`) |
171+
| `chain` | No | `"base-sepolia"` | Blockchain network (see built-in list above) |
169172
| `currency` | No | `"USDC"` | Payment token symbol (currently only USDC supported) |
170173
| `optimistic` | No | `true` | Settlement mode (see Optimistic vs Non-Optimistic Mode below) |
171174
| `version` | No | `2` | Protocol version (1 or 2). See Protocol Versions section |
@@ -240,7 +243,7 @@ end
240243
| `name` | Yes | Token name for EIP-712 domain |
241244
| `version` | No | EIP-712 version (default: "1") |
242245

243-
**Note:** Custom chains and tokens are only supported for EVM (eip155) networks. Solana chains use a different implementation.
246+
**Note:** Custom chains support both EVM (`eip155`) and Solana (`solana`) standards. Custom tokens can be registered on any chain.
244247

245248
### Accept Multiple Payment Options
246249

lib/x402/chains.rb

Lines changed: 133 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,87 +3,164 @@
33
module X402
44
# Chain configurations for supported networks
55
CHAINS = {
6+
# --- Base ---
7+
"base" => {
8+
chain_id: 8453,
9+
usdc_address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
10+
explorer_url: "https://basescan.org",
11+
},
612
"base-sepolia" => {
713
chain_id: 84532,
814
usdc_address: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
9-
explorer_url: "https://sepolia.basescan.org"
15+
explorer_url: "https://sepolia.basescan.org",
1016
},
11-
"base" => {
12-
chain_id: 8453,
13-
usdc_address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
14-
explorer_url: "https://basescan.org"
17+
18+
# --- Polygon ---
19+
"polygon" => {
20+
chain_id: 137,
21+
usdc_address: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
22+
explorer_url: "https://polygonscan.com",
1523
},
16-
"avalanche-fuji" => {
17-
chain_id: 43113,
18-
usdc_address: "0x5425890298aed601595a70AB815c96711a31Bc65",
19-
explorer_url: "https://testnet.snowtrace.io"
24+
"polygon-amoy" => {
25+
chain_id: 80002,
26+
usdc_address: "0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582",
27+
explorer_url: "https://amoy.polygonscan.com",
2028
},
29+
30+
# --- Avalanche ---
2131
"avalanche" => {
2232
chain_id: 43114,
2333
usdc_address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
24-
explorer_url: "https://snowtrace.io"
34+
explorer_url: "https://snowtrace.io",
2535
},
26-
"solana-devnet" => {
27-
chain_id: 103,
28-
usdc_address: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
29-
explorer_url: "https://explorer.solana.com/?cluster=devnet",
30-
fee_payer: "CKPKJWNdJEqa81x7CkZ14BVPiY6y16Sxs7owznqtWYp5"
36+
"avalanche-fuji" => {
37+
chain_id: 43113,
38+
usdc_address: "0x5425890298aed601595a70AB815c96711a31Bc65",
39+
explorer_url: "https://testnet.snowtrace.io",
40+
},
41+
42+
# --- Sei ---
43+
"sei" => {
44+
chain_id: 1329,
45+
usdc_address: "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392",
46+
explorer_url: "https://seitrace.com",
47+
},
48+
"sei-testnet" => {
49+
chain_id: 713715,
50+
explorer_url: "https://seitrace.com/?chain=arctic-1",
3151
},
52+
53+
# --- X Layer ---
54+
"xlayer" => {
55+
chain_id: 196,
56+
explorer_url: "https://www.oklink.com/xlayer",
57+
},
58+
"xlayer-testnet" => {
59+
chain_id: 1952,
60+
explorer_url: "https://www.oklink.com/xlayer-test",
61+
},
62+
63+
# --- SKALE ---
64+
"skale-base" => {
65+
chain_id: 1_187_947_933,
66+
explorer_url: "https://elated-tan-skat.explorer.mainnet.skalenodes.com",
67+
},
68+
"skale-base-sepolia" => {
69+
chain_id: 324_705_682,
70+
explorer_url: "https://lanky-ill-funny-testnet.explorer.testnet.skalenodes.com",
71+
},
72+
73+
# --- KiteAI ---
74+
"kiteai" => {
75+
chain_id: 2366,
76+
explorer_url: "https://testnet.kitescan.ai",
77+
},
78+
"kiteai-testnet" => {
79+
chain_id: 2368,
80+
explorer_url: "https://testnet.kitescan.ai",
81+
},
82+
83+
# --- IoTeX (mainnet only) ---
84+
"iotex" => {
85+
chain_id: 4689,
86+
explorer_url: "https://iotexscan.io",
87+
},
88+
89+
# --- Peaq (mainnet only) ---
90+
"peaq" => {
91+
chain_id: 3338,
92+
explorer_url: "https://peaq.subscan.io",
93+
},
94+
95+
# --- Solana ---
96+
# Default fee_payer is for the Coinbase facilitator (x402.org).
97+
# If using PayAI facilitator, set X402_SOLANA_FEE_PAYER or X402_SOLANA_DEVNET_FEE_PAYER
98+
# to PayAI's fee payer: 2wKupLR9q6wXYppw8Gr2NvWxKBUqm4PPJKkQfoxHDBg4
3299
"solana" => {
33100
chain_id: 101,
34101
usdc_address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
35102
explorer_url: "https://explorer.solana.com",
36-
fee_payer: "CKPKJWNdJEqa81x7CkZ14BVPiY6y16Sxs7owznqtWYp5"
37-
}
103+
fee_payer: "CKPKJWNdJEqa81x7CkZ14BVPiY6y16Sxs7owznqtWYp5",
104+
},
105+
"solana-devnet" => {
106+
chain_id: 103,
107+
usdc_address: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
108+
explorer_url: "https://explorer.solana.com/?cluster=devnet",
109+
fee_payer: "CKPKJWNdJEqa81x7CkZ14BVPiY6y16Sxs7owznqtWYp5",
110+
},
38111
}.freeze
39112

40113
# Currency configurations by chain
41114
CURRENCY_BY_CHAIN = {
42-
"base-sepolia" => {
43-
symbol: "USDC",
44-
decimals: 6,
45-
name: "USDC", # Testnet uses "USDC"
46-
version: "2"
47-
},
48-
"base" => {
49-
symbol: "USDC",
50-
decimals: 6,
51-
name: "USD Coin", # Mainnet uses "USD Coin"
52-
version: "2"
53-
},
54-
"avalanche-fuji" => {
55-
symbol: "USDC",
56-
decimals: 6,
57-
name: "USD Coin", # Testnet uses "USD Coin"
58-
version: "2"
59-
},
60-
"avalanche" => {
61-
symbol: "USDC",
62-
decimals: 6,
63-
name: "USDC", # Mainnet uses "USDC"
64-
version: "2"
65-
},
66-
"solana-devnet" => {
67-
symbol: "USDC",
68-
decimals: 6,
69-
name: "USDC",
70-
version: nil
71-
},
72-
"solana" => {
73-
symbol: "USDC",
74-
decimals: 6,
75-
name: "USD Coin",
76-
version: nil
77-
}
115+
"base" => { symbol: "USDC", decimals: 6, name: "USD Coin", version: "2" },
116+
"base-sepolia" => { symbol: "USDC", decimals: 6, name: "USDC", version: "2" },
117+
"polygon" => { symbol: "USDC", decimals: 6, name: "USD Coin", version: "2" },
118+
"polygon-amoy" => { symbol: "USDC", decimals: 6, name: "USDC", version: "2" },
119+
"avalanche" => { symbol: "USDC", decimals: 6, name: "USDC", version: "2" },
120+
"avalanche-fuji" => { symbol: "USDC", decimals: 6, name: "USD Coin", version: "2" },
121+
"sei" => { symbol: "USDC", decimals: 6, name: "USDC", version: nil },
122+
"sei-testnet" => { symbol: "USDC", decimals: 6, name: "USDC", version: nil },
123+
"xlayer" => { symbol: "USDC", decimals: 6, name: "USDC", version: nil },
124+
"xlayer-testnet" => { symbol: "USDC", decimals: 6, name: "USDC", version: nil },
125+
"skale-base" => { symbol: "USDC", decimals: 6, name: "USDC", version: nil },
126+
"skale-base-sepolia" => { symbol: "USDC", decimals: 6, name: "USDC", version: nil },
127+
"kiteai" => { symbol: "USDC", decimals: 6, name: "USDC", version: nil },
128+
"kiteai-testnet" => { symbol: "USDC", decimals: 6, name: "USDC", version: nil },
129+
"iotex" => { symbol: "USDC", decimals: 6, name: "USDC", version: nil },
130+
"peaq" => { symbol: "USDC", decimals: 6, name: "USDC", version: nil },
131+
"solana" => { symbol: "USDC", decimals: 6, name: "USD Coin", version: nil },
132+
"solana-devnet" => { symbol: "USDC", decimals: 6, name: "USDC", version: nil },
78133
}.freeze
79134

80135
CAIP2_MAPPING = {
81-
"base-sepolia" => "eip155:84532",
136+
# Base
82137
"base" => "eip155:8453",
83-
"avalanche-fuji" => "eip155:43113",
138+
"base-sepolia" => "eip155:84532",
139+
# Polygon
140+
"polygon" => "eip155:137",
141+
"polygon-amoy" => "eip155:80002",
142+
# Avalanche
84143
"avalanche" => "eip155:43114",
144+
"avalanche-fuji" => "eip155:43113",
145+
# Sei
146+
"sei" => "eip155:1329",
147+
"sei-testnet" => "eip155:713715",
148+
# X Layer
149+
"xlayer" => "eip155:196",
150+
"xlayer-testnet" => "eip155:1952",
151+
# SKALE
152+
"skale-base" => "eip155:1187947933",
153+
"skale-base-sepolia" => "eip155:324705682",
154+
# KiteAI
155+
"kiteai" => "eip155:2366",
156+
"kiteai-testnet" => "eip155:2368",
157+
# IoTeX
158+
"iotex" => "eip155:4689",
159+
# Peaq
160+
"peaq" => "eip155:3338",
161+
# Solana
162+
"solana" => "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
85163
"solana-devnet" => "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
86-
"solana" => "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
87164
}.freeze
88165

89166
REVERSE_CAIP2_MAPPING = CAIP2_MAPPING.invert.freeze

lib/x402/rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module X402
44
module Rails
5-
VERSION = "1.0.0"
5+
VERSION = "1.1.0"
66
end
77
end

spec/x402/chains_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,12 @@
120120
expect(base_address).not_to eq(avalanche_address)
121121
end
122122

123+
it "returns USDC address for polygon" do
124+
expect(X402.usdc_address_for("polygon")).to eq("0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359")
125+
end
126+
123127
it "returns nil for unsupported chain" do
124-
expect(X402.usdc_address_for("polygon")).to be_nil
128+
expect(X402.usdc_address_for("ethereum")).to be_nil
125129
end
126130
end
127131

x402-rails.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
99
spec.email = ["zach+x402@quiknode.io"]
1010

1111
spec.summary = "Rails integration for x402 payment protocol (supporting x402 v2)."
12-
spec.description = "Accept instant blockchain micropayments in Rails applications using the x402 protocol."
12+
spec.description = "Accept instant blockchain micropayments in Rails applications using the x402 protocol (supporting x402 v2)"
1313
spec.homepage = "https://github.com/quiknode-labs/x402-rails"
1414
spec.license = "MIT"
1515
spec.required_ruby_version = ">= 3.0.0"

0 commit comments

Comments
 (0)