uvd-x402-sdk 0.3.4__py3-none-any.whl → 0.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uvd_x402_sdk/networks/__init__.py +3 -2
- uvd_x402_sdk/networks/algorand.py +287 -0
- uvd_x402_sdk/networks/base.py +11 -0
- uvd_x402_sdk/networks/solana.py +72 -1
- {uvd_x402_sdk-0.3.4.dist-info → uvd_x402_sdk-0.4.1.dist-info}/METADATA +3 -3
- {uvd_x402_sdk-0.3.4.dist-info → uvd_x402_sdk-0.4.1.dist-info}/RECORD +9 -8
- {uvd_x402_sdk-0.3.4.dist-info → uvd_x402_sdk-0.4.1.dist-info}/LICENSE +0 -0
- {uvd_x402_sdk-0.3.4.dist-info → uvd_x402_sdk-0.4.1.dist-info}/WHEEL +0 -0
- {uvd_x402_sdk-0.3.4.dist-info → uvd_x402_sdk-0.4.1.dist-info}/top_level.txt +0 -0
|
@@ -4,12 +4,13 @@ Network configurations for x402 payments.
|
|
|
4
4
|
This module provides configuration for all supported blockchain networks,
|
|
5
5
|
including USDC contract addresses, RPC URLs, and network-specific parameters.
|
|
6
6
|
|
|
7
|
-
The SDK supports
|
|
7
|
+
The SDK supports 16 mainnet networks out of the box:
|
|
8
8
|
- 10 EVM chains: Base, Ethereum, Polygon, Arbitrum, Optimism, Avalanche,
|
|
9
9
|
Celo, HyperEVM, Unichain, Monad
|
|
10
10
|
- 2 SVM chains: Solana, Fogo
|
|
11
11
|
- 1 NEAR: NEAR Protocol
|
|
12
12
|
- 1 Stellar: Stellar
|
|
13
|
+
- 2 Algorand: Algorand mainnet and testnet
|
|
13
14
|
|
|
14
15
|
Multi-token support (EVM chains only):
|
|
15
16
|
- USDC: All chains
|
|
@@ -47,7 +48,7 @@ from uvd_x402_sdk.networks.base import (
|
|
|
47
48
|
)
|
|
48
49
|
|
|
49
50
|
# Import all default network configurations
|
|
50
|
-
from uvd_x402_sdk.networks import evm, solana, near, stellar
|
|
51
|
+
from uvd_x402_sdk.networks import evm, solana, near, stellar, algorand
|
|
51
52
|
|
|
52
53
|
__all__ = [
|
|
53
54
|
# Core
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Algorand network configurations.
|
|
3
|
+
|
|
4
|
+
This module supports Algorand blockchain networks:
|
|
5
|
+
- Algorand mainnet
|
|
6
|
+
- Algorand testnet
|
|
7
|
+
|
|
8
|
+
Algorand uses ASA (Algorand Standard Assets) for USDC:
|
|
9
|
+
- Mainnet USDC ASA ID: 31566704
|
|
10
|
+
- Testnet USDC ASA ID: 10458941
|
|
11
|
+
|
|
12
|
+
Payment Flow:
|
|
13
|
+
1. User creates a signed ASA transfer transaction via Pera Wallet
|
|
14
|
+
2. Transaction transfers USDC from user to recipient
|
|
15
|
+
3. Facilitator submits the pre-signed transaction on-chain
|
|
16
|
+
4. User pays ZERO transaction fees (facilitator covers fees)
|
|
17
|
+
|
|
18
|
+
Transaction Structure:
|
|
19
|
+
- ASA TransferAsset transaction
|
|
20
|
+
- Signed by user wallet (Pera Wallet)
|
|
21
|
+
- Facilitator submits the signed transaction
|
|
22
|
+
|
|
23
|
+
Address Format:
|
|
24
|
+
- Algorand addresses are 58 characters, base32 encoded
|
|
25
|
+
- Example: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
import base64
|
|
29
|
+
import re
|
|
30
|
+
from typing import Any, Dict, Optional
|
|
31
|
+
|
|
32
|
+
from uvd_x402_sdk.networks.base import (
|
|
33
|
+
NetworkConfig,
|
|
34
|
+
NetworkType,
|
|
35
|
+
register_network,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# =============================================================================
|
|
40
|
+
# Algorand Networks Configuration
|
|
41
|
+
# =============================================================================
|
|
42
|
+
|
|
43
|
+
# Algorand Mainnet
|
|
44
|
+
ALGORAND = NetworkConfig(
|
|
45
|
+
name="algorand",
|
|
46
|
+
display_name="Algorand",
|
|
47
|
+
network_type=NetworkType.ALGORAND,
|
|
48
|
+
chain_id=0, # Non-EVM, no chain ID
|
|
49
|
+
usdc_address="31566704", # USDC ASA ID on mainnet
|
|
50
|
+
usdc_decimals=6,
|
|
51
|
+
usdc_domain_name="", # Not applicable for Algorand
|
|
52
|
+
usdc_domain_version="",
|
|
53
|
+
rpc_url="https://mainnet-api.algonode.cloud",
|
|
54
|
+
enabled=True,
|
|
55
|
+
extra_config={
|
|
56
|
+
# ASA (Algorand Standard Asset) details
|
|
57
|
+
"usdc_asa_id": 31566704,
|
|
58
|
+
# Block explorer
|
|
59
|
+
"explorer_url": "https://allo.info",
|
|
60
|
+
# Indexer endpoint (for account queries)
|
|
61
|
+
"indexer_url": "https://mainnet-idx.algonode.cloud",
|
|
62
|
+
# Network identifier
|
|
63
|
+
"genesis_id": "mainnet-v1.0",
|
|
64
|
+
# Genesis hash (for CAIP-2)
|
|
65
|
+
"genesis_hash": "wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=",
|
|
66
|
+
},
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# Algorand Testnet
|
|
70
|
+
ALGORAND_TESTNET = NetworkConfig(
|
|
71
|
+
name="algorand-testnet",
|
|
72
|
+
display_name="Algorand Testnet",
|
|
73
|
+
network_type=NetworkType.ALGORAND,
|
|
74
|
+
chain_id=0, # Non-EVM, no chain ID
|
|
75
|
+
usdc_address="10458941", # USDC ASA ID on testnet
|
|
76
|
+
usdc_decimals=6,
|
|
77
|
+
usdc_domain_name="", # Not applicable for Algorand
|
|
78
|
+
usdc_domain_version="",
|
|
79
|
+
rpc_url="https://testnet-api.algonode.cloud",
|
|
80
|
+
enabled=True,
|
|
81
|
+
extra_config={
|
|
82
|
+
# ASA (Algorand Standard Asset) details
|
|
83
|
+
"usdc_asa_id": 10458941,
|
|
84
|
+
# Block explorer
|
|
85
|
+
"explorer_url": "https://testnet.allo.info",
|
|
86
|
+
# Indexer endpoint (for account queries)
|
|
87
|
+
"indexer_url": "https://testnet-idx.algonode.cloud",
|
|
88
|
+
# Network identifier
|
|
89
|
+
"genesis_id": "testnet-v1.0",
|
|
90
|
+
# Genesis hash
|
|
91
|
+
"genesis_hash": "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=",
|
|
92
|
+
},
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# Register Algorand networks
|
|
96
|
+
register_network(ALGORAND)
|
|
97
|
+
register_network(ALGORAND_TESTNET)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# =============================================================================
|
|
101
|
+
# Algorand-specific utilities
|
|
102
|
+
# =============================================================================
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def is_algorand_network(network_name: str) -> bool:
|
|
106
|
+
"""
|
|
107
|
+
Check if a network is Algorand.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
network_name: Network name to check
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
True if network is Algorand (mainnet or testnet)
|
|
114
|
+
"""
|
|
115
|
+
from uvd_x402_sdk.networks.base import get_network, NetworkType
|
|
116
|
+
|
|
117
|
+
network = get_network(network_name)
|
|
118
|
+
if not network:
|
|
119
|
+
return False
|
|
120
|
+
return network.network_type == NetworkType.ALGORAND
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def get_algorand_networks() -> list:
|
|
124
|
+
"""
|
|
125
|
+
Get all registered Algorand networks.
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
List of Algorand NetworkConfig instances
|
|
129
|
+
"""
|
|
130
|
+
from uvd_x402_sdk.networks.base import list_networks, NetworkType
|
|
131
|
+
|
|
132
|
+
return [
|
|
133
|
+
n for n in list_networks(enabled_only=True)
|
|
134
|
+
if n.network_type == NetworkType.ALGORAND
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def is_valid_algorand_address(address: str) -> bool:
|
|
139
|
+
"""
|
|
140
|
+
Validate an Algorand address format.
|
|
141
|
+
|
|
142
|
+
Algorand addresses are 58 characters, base32 encoded (RFC 4648).
|
|
143
|
+
They consist of uppercase letters A-Z and digits 2-7.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
address: Address to validate
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
True if valid Algorand address format
|
|
150
|
+
"""
|
|
151
|
+
if not address or not isinstance(address, str):
|
|
152
|
+
return False
|
|
153
|
+
|
|
154
|
+
# Algorand addresses are exactly 58 characters
|
|
155
|
+
if len(address) != 58:
|
|
156
|
+
return False
|
|
157
|
+
|
|
158
|
+
# Base32 alphabet (RFC 4648): A-Z and 2-7
|
|
159
|
+
base32_pattern = re.compile(r'^[A-Z2-7]+$')
|
|
160
|
+
return bool(base32_pattern.match(address))
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def validate_algorand_payload(payload: Dict[str, Any]) -> bool:
|
|
164
|
+
"""
|
|
165
|
+
Validate an Algorand payment payload structure.
|
|
166
|
+
|
|
167
|
+
The payload must contain:
|
|
168
|
+
- from: Sender's Algorand address
|
|
169
|
+
- to: Recipient's Algorand address
|
|
170
|
+
- amount: Amount in base units (microUSDC)
|
|
171
|
+
- assetId: ASA ID for USDC
|
|
172
|
+
- signedTxn: Base64-encoded signed transaction
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
payload: Payload dictionary from x402 payment
|
|
176
|
+
|
|
177
|
+
Returns:
|
|
178
|
+
True if valid, raises ValueError if invalid
|
|
179
|
+
"""
|
|
180
|
+
required_fields = ["from", "to", "amount", "assetId", "signedTxn"]
|
|
181
|
+
|
|
182
|
+
for field in required_fields:
|
|
183
|
+
if field not in payload:
|
|
184
|
+
raise ValueError(f"Algorand payload missing '{field}' field")
|
|
185
|
+
|
|
186
|
+
# Validate addresses
|
|
187
|
+
if not is_valid_algorand_address(payload["from"]):
|
|
188
|
+
raise ValueError(f"Invalid 'from' address: {payload['from']}")
|
|
189
|
+
if not is_valid_algorand_address(payload["to"]):
|
|
190
|
+
raise ValueError(f"Invalid 'to' address: {payload['to']}")
|
|
191
|
+
|
|
192
|
+
# Validate amount
|
|
193
|
+
try:
|
|
194
|
+
amount = int(payload["amount"])
|
|
195
|
+
if amount <= 0:
|
|
196
|
+
raise ValueError(f"Amount must be positive: {amount}")
|
|
197
|
+
except (ValueError, TypeError) as e:
|
|
198
|
+
raise ValueError(f"Invalid amount: {payload['amount']}") from e
|
|
199
|
+
|
|
200
|
+
# Validate assetId
|
|
201
|
+
try:
|
|
202
|
+
asset_id = int(payload["assetId"])
|
|
203
|
+
if asset_id <= 0:
|
|
204
|
+
raise ValueError(f"Asset ID must be positive: {asset_id}")
|
|
205
|
+
except (ValueError, TypeError) as e:
|
|
206
|
+
raise ValueError(f"Invalid assetId: {payload['assetId']}") from e
|
|
207
|
+
|
|
208
|
+
# Validate signedTxn is valid base64
|
|
209
|
+
try:
|
|
210
|
+
signed_txn = payload["signedTxn"]
|
|
211
|
+
tx_bytes = base64.b64decode(signed_txn)
|
|
212
|
+
if len(tx_bytes) < 50:
|
|
213
|
+
raise ValueError(f"Signed transaction too short: {len(tx_bytes)} bytes")
|
|
214
|
+
except Exception as e:
|
|
215
|
+
raise ValueError(f"Invalid signedTxn (not valid base64): {e}") from e
|
|
216
|
+
|
|
217
|
+
return True
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def get_explorer_tx_url(network_name: str, tx_id: str) -> Optional[str]:
|
|
221
|
+
"""
|
|
222
|
+
Get block explorer URL for a transaction.
|
|
223
|
+
|
|
224
|
+
Args:
|
|
225
|
+
network_name: Network name ('algorand' or 'algorand-testnet')
|
|
226
|
+
tx_id: Transaction ID
|
|
227
|
+
|
|
228
|
+
Returns:
|
|
229
|
+
Explorer URL or None if network not found
|
|
230
|
+
"""
|
|
231
|
+
from uvd_x402_sdk.networks.base import get_network
|
|
232
|
+
|
|
233
|
+
network = get_network(network_name)
|
|
234
|
+
if not network or network.network_type != NetworkType.ALGORAND:
|
|
235
|
+
return None
|
|
236
|
+
|
|
237
|
+
explorer_url = network.extra_config.get("explorer_url", "https://allo.info")
|
|
238
|
+
return f"{explorer_url}/tx/{tx_id}"
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def get_explorer_address_url(network_name: str, address: str) -> Optional[str]:
|
|
242
|
+
"""
|
|
243
|
+
Get block explorer URL for an address.
|
|
244
|
+
|
|
245
|
+
Args:
|
|
246
|
+
network_name: Network name ('algorand' or 'algorand-testnet')
|
|
247
|
+
address: Algorand address
|
|
248
|
+
|
|
249
|
+
Returns:
|
|
250
|
+
Explorer URL or None if network not found
|
|
251
|
+
"""
|
|
252
|
+
from uvd_x402_sdk.networks.base import get_network
|
|
253
|
+
|
|
254
|
+
network = get_network(network_name)
|
|
255
|
+
if not network or network.network_type != NetworkType.ALGORAND:
|
|
256
|
+
return None
|
|
257
|
+
|
|
258
|
+
explorer_url = network.extra_config.get("explorer_url", "https://allo.info")
|
|
259
|
+
return f"{explorer_url}/account/{address}"
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def get_usdc_asa_id(network_name: str) -> Optional[int]:
|
|
263
|
+
"""
|
|
264
|
+
Get the USDC ASA ID for an Algorand network.
|
|
265
|
+
|
|
266
|
+
Args:
|
|
267
|
+
network_name: Network name ('algorand' or 'algorand-testnet')
|
|
268
|
+
|
|
269
|
+
Returns:
|
|
270
|
+
USDC ASA ID or None if network not found
|
|
271
|
+
"""
|
|
272
|
+
from uvd_x402_sdk.networks.base import get_network
|
|
273
|
+
|
|
274
|
+
network = get_network(network_name)
|
|
275
|
+
if not network or network.network_type != NetworkType.ALGORAND:
|
|
276
|
+
return None
|
|
277
|
+
|
|
278
|
+
# Try extra_config first, then fall back to usdc_address
|
|
279
|
+
asa_id = network.extra_config.get("usdc_asa_id")
|
|
280
|
+
if asa_id:
|
|
281
|
+
return int(asa_id)
|
|
282
|
+
|
|
283
|
+
# Parse from usdc_address (which stores the ASA ID as string)
|
|
284
|
+
try:
|
|
285
|
+
return int(network.usdc_address)
|
|
286
|
+
except (ValueError, TypeError):
|
|
287
|
+
return None
|
uvd_x402_sdk/networks/base.py
CHANGED
|
@@ -56,6 +56,7 @@ class NetworkType(Enum):
|
|
|
56
56
|
- SVM: Partially-signed VersionedTransaction (SPL token transfer) - Solana, Fogo
|
|
57
57
|
- NEAR: NEP-366 SignedDelegateAction (meta-transaction)
|
|
58
58
|
- STELLAR: Soroban Authorization Entry XDR
|
|
59
|
+
- ALGORAND: ASA (Algorand Standard Assets) transfer via signed transaction
|
|
59
60
|
|
|
60
61
|
Note: SOLANA is deprecated, use SVM instead for Solana-compatible chains.
|
|
61
62
|
"""
|
|
@@ -65,6 +66,7 @@ class NetworkType(Enum):
|
|
|
65
66
|
SOLANA = "solana" # Deprecated: use SVM
|
|
66
67
|
NEAR = "near"
|
|
67
68
|
STELLAR = "stellar"
|
|
69
|
+
ALGORAND = "algorand" # Algorand ASA transfers
|
|
68
70
|
|
|
69
71
|
@classmethod
|
|
70
72
|
def is_svm(cls, network_type: "NetworkType") -> bool:
|
|
@@ -369,6 +371,7 @@ _CAIP2_NAMESPACE_MAP = {
|
|
|
369
371
|
"solana": NetworkType.SVM,
|
|
370
372
|
"near": NetworkType.NEAR,
|
|
371
373
|
"stellar": NetworkType.STELLAR,
|
|
374
|
+
"algorand": NetworkType.ALGORAND,
|
|
372
375
|
}
|
|
373
376
|
|
|
374
377
|
# Network name to CAIP-2 format
|
|
@@ -391,6 +394,9 @@ _NETWORK_TO_CAIP2 = {
|
|
|
391
394
|
"near": "near:mainnet",
|
|
392
395
|
# Stellar
|
|
393
396
|
"stellar": "stellar:pubnet",
|
|
397
|
+
# Algorand
|
|
398
|
+
"algorand": "algorand:mainnet",
|
|
399
|
+
"algorand-testnet": "algorand:testnet",
|
|
394
400
|
}
|
|
395
401
|
|
|
396
402
|
# CAIP-2 to network name mapping (reverse of above)
|
|
@@ -444,6 +450,11 @@ def parse_caip2_network(caip2_id: str) -> Optional[str]:
|
|
|
444
450
|
return "near"
|
|
445
451
|
if namespace == "stellar" and reference in ("pubnet", "mainnet"):
|
|
446
452
|
return "stellar"
|
|
453
|
+
if namespace == "algorand":
|
|
454
|
+
if reference == "mainnet":
|
|
455
|
+
return "algorand"
|
|
456
|
+
if reference == "testnet":
|
|
457
|
+
return "algorand-testnet"
|
|
447
458
|
|
|
448
459
|
return None
|
|
449
460
|
|
uvd_x402_sdk/networks/solana.py
CHANGED
|
@@ -5,6 +5,10 @@ This module supports all SVM-compatible chains:
|
|
|
5
5
|
- Solana (mainnet)
|
|
6
6
|
- Fogo (fast finality SVM)
|
|
7
7
|
|
|
8
|
+
Supported Tokens:
|
|
9
|
+
- USDC: Standard SPL Token (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)
|
|
10
|
+
- AUSD: Token2022 (TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb)
|
|
11
|
+
|
|
8
12
|
All SVM chains use the same payment flow:
|
|
9
13
|
1. User creates a partially-signed VersionedTransaction
|
|
10
14
|
2. Transaction contains SPL token TransferChecked instruction
|
|
@@ -14,7 +18,7 @@ All SVM chains use the same payment flow:
|
|
|
14
18
|
Transaction Structure (flexible, facilitator v1.9.4+):
|
|
15
19
|
- SetComputeUnitLimit instruction (recommended: 20,000 units)
|
|
16
20
|
- SetComputeUnitPrice instruction (recommended: 100,000 microLamports)
|
|
17
|
-
- TransferChecked (
|
|
21
|
+
- TransferChecked (SPL or Token2022 transfer)
|
|
18
22
|
- Optional: CreateAssociatedTokenAccount (if recipient ATA doesn't exist)
|
|
19
23
|
- Additional instructions may be added by wallets (e.g., Phantom memo)
|
|
20
24
|
|
|
@@ -30,6 +34,7 @@ from typing import Dict, Any, Optional
|
|
|
30
34
|
from uvd_x402_sdk.networks.base import (
|
|
31
35
|
NetworkConfig,
|
|
32
36
|
NetworkType,
|
|
37
|
+
TokenConfig,
|
|
33
38
|
register_network,
|
|
34
39
|
)
|
|
35
40
|
|
|
@@ -50,9 +55,28 @@ SOLANA = NetworkConfig(
|
|
|
50
55
|
usdc_domain_version="",
|
|
51
56
|
rpc_url="https://api.mainnet-beta.solana.com",
|
|
52
57
|
enabled=True,
|
|
58
|
+
tokens={
|
|
59
|
+
# USDC - Standard SPL Token
|
|
60
|
+
"usdc": TokenConfig(
|
|
61
|
+
address="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
62
|
+
decimals=6,
|
|
63
|
+
name="", # Not applicable for SVM
|
|
64
|
+
version="",
|
|
65
|
+
),
|
|
66
|
+
# AUSD - Token2022 (Agora USD)
|
|
67
|
+
# Uses Token2022 with extensions: PermanentDelegate, TransferHook, Metadata
|
|
68
|
+
"ausd": TokenConfig(
|
|
69
|
+
address="AUSD1jCcCyPLybk1YnvPWsHQSrZ46dxwoMniN4N2UEB9",
|
|
70
|
+
decimals=6,
|
|
71
|
+
name="", # Not applicable for SVM
|
|
72
|
+
version="",
|
|
73
|
+
),
|
|
74
|
+
},
|
|
53
75
|
extra_config={
|
|
54
76
|
# Token program ID (standard SPL token program)
|
|
55
77
|
"token_program_id": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
|
|
78
|
+
# Token2022 program ID (for AUSD and other Token2022 tokens)
|
|
79
|
+
"token_2022_program_id": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb",
|
|
56
80
|
# Associated Token Account program
|
|
57
81
|
"ata_program_id": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
58
82
|
# Default compute units for transfer
|
|
@@ -280,3 +304,50 @@ DEFAULT_COMPUTE_UNITS = 20000
|
|
|
280
304
|
# Use 100k microlamports/CU for fast landing on mainnet
|
|
281
305
|
# Lower values (like 1) cause transactions to be deprioritized and time out
|
|
282
306
|
DEFAULT_PRIORITY_FEE_MICROLAMPORTS = 100_000
|
|
307
|
+
|
|
308
|
+
# =============================================================================
|
|
309
|
+
# Token Program Constants
|
|
310
|
+
# =============================================================================
|
|
311
|
+
|
|
312
|
+
# Standard SPL Token Program (used by USDC)
|
|
313
|
+
TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
314
|
+
|
|
315
|
+
# Token2022 Program (used by AUSD - has extensions like TransferHook)
|
|
316
|
+
TOKEN_2022_PROGRAM_ID = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
317
|
+
|
|
318
|
+
# Associated Token Account Program (same for both SPL and Token2022)
|
|
319
|
+
ATA_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
320
|
+
|
|
321
|
+
# Tokens that use Token2022 instead of standard SPL
|
|
322
|
+
TOKEN_2022_TOKENS = {"ausd"}
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
def get_token_program_id(token_type: str) -> str:
|
|
326
|
+
"""
|
|
327
|
+
Get the token program ID for a given token type.
|
|
328
|
+
|
|
329
|
+
USDC uses standard SPL Token program.
|
|
330
|
+
AUSD uses Token2022 (with extensions like TransferHook).
|
|
331
|
+
|
|
332
|
+
Args:
|
|
333
|
+
token_type: Token type (e.g., 'usdc', 'ausd')
|
|
334
|
+
|
|
335
|
+
Returns:
|
|
336
|
+
Token program ID string
|
|
337
|
+
"""
|
|
338
|
+
if token_type.lower() in TOKEN_2022_TOKENS:
|
|
339
|
+
return TOKEN_2022_PROGRAM_ID
|
|
340
|
+
return TOKEN_PROGRAM_ID
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def is_token_2022(token_type: str) -> bool:
|
|
344
|
+
"""
|
|
345
|
+
Check if a token uses the Token2022 program.
|
|
346
|
+
|
|
347
|
+
Args:
|
|
348
|
+
token_type: Token type (e.g., 'usdc', 'ausd')
|
|
349
|
+
|
|
350
|
+
Returns:
|
|
351
|
+
True if token uses Token2022, False for standard SPL
|
|
352
|
+
"""
|
|
353
|
+
return token_type.lower() in TOKEN_2022_TOKENS
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: uvd-x402-sdk
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Python SDK for x402 payments - gasless crypto payments across
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: Python SDK for x402 payments - gasless crypto payments across 16 blockchains with multi-stablecoin support (USDC, EURC, AUSD, PYUSD, USDT)
|
|
5
5
|
Author-email: Ultravioleta DAO <dev@ultravioletadao.xyz>
|
|
6
6
|
Project-URL: Homepage, https://github.com/UltravioletaDAO/uvd-x402-sdk-python
|
|
7
7
|
Project-URL: Documentation, https://docs.ultravioletadao.xyz/x402-sdk
|
|
8
8
|
Project-URL: Repository, https://github.com/UltravioletaDAO/uvd-x402-sdk-python
|
|
9
9
|
Project-URL: Issues, https://github.com/UltravioletaDAO/uvd-x402-sdk-python/issues
|
|
10
|
-
Keywords: x402,payments,crypto,usdc,eurc,stablecoin,web3,evm,solana,near,stellar,facilitator,gasless,eip-712,eip-3009
|
|
10
|
+
Keywords: x402,payments,crypto,usdc,eurc,stablecoin,web3,evm,solana,near,stellar,algorand,facilitator,gasless,eip-712,eip-3009
|
|
11
11
|
Classifier: Development Status :: 4 - Beta
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -10,14 +10,15 @@ uvd_x402_sdk/integrations/django_integration.py,sha256=e3xaV1Yz3HHI7zZBNcyTmV0Js
|
|
|
10
10
|
uvd_x402_sdk/integrations/fastapi_integration.py,sha256=j5h1IJwFLBBoWov7ANLCFaxeCa8pugn-XU9ibrzIL0Y,10205
|
|
11
11
|
uvd_x402_sdk/integrations/flask_integration.py,sha256=0iQKO5-WRxE76Pv-1jEl4lYhjCLmq_R-jxR5g9xIcKw,8825
|
|
12
12
|
uvd_x402_sdk/integrations/lambda_integration.py,sha256=nRf4o3nS6Syx-d5P0kEhz66y7jb_S4w-mwaIazgiA9c,10184
|
|
13
|
-
uvd_x402_sdk/networks/__init__.py,sha256=
|
|
14
|
-
uvd_x402_sdk/networks/
|
|
13
|
+
uvd_x402_sdk/networks/__init__.py,sha256=LKl_TljVoCDb27YB4X_VbQN8XKbdwWFAsCwgiqQtlgo,2092
|
|
14
|
+
uvd_x402_sdk/networks/algorand.py,sha256=ACaVMyXItRX3M29GPwwMMxECMjNXx3FlYARNBeAztH4,8601
|
|
15
|
+
uvd_x402_sdk/networks/base.py,sha256=gOPWfqasGbgtg9w2uG5pWnfjdOEain92L2egnDSBguc,14863
|
|
15
16
|
uvd_x402_sdk/networks/evm.py,sha256=4IbeaMH2I1c9DYCijghys0qYNeL2Nl92IMKLwq-b0Zg,10065
|
|
16
17
|
uvd_x402_sdk/networks/near.py,sha256=sxbxT1NqjcENh8ysFLDpAx5DGizf1EI0YjwgviLfqcY,11608
|
|
17
|
-
uvd_x402_sdk/networks/solana.py,sha256
|
|
18
|
+
uvd_x402_sdk/networks/solana.py,sha256=-snAeE3OxJU_kaGb_z4NOU6k0SGAD4DBPhJcPbgrdgo,11675
|
|
18
19
|
uvd_x402_sdk/networks/stellar.py,sha256=c-6re-dVc2-6gJ5rL4krUTaFsPz5vkactOJD-0wowBA,3534
|
|
19
|
-
uvd_x402_sdk-0.
|
|
20
|
-
uvd_x402_sdk-0.
|
|
21
|
-
uvd_x402_sdk-0.
|
|
22
|
-
uvd_x402_sdk-0.
|
|
23
|
-
uvd_x402_sdk-0.
|
|
20
|
+
uvd_x402_sdk-0.4.1.dist-info/LICENSE,sha256=OcLzB_iSgMbvk7b0dlyvleY_IbL2WUaPxvn1CHw2uAc,1073
|
|
21
|
+
uvd_x402_sdk-0.4.1.dist-info/METADATA,sha256=3cD7Kz9_fONGwbZVUBMOxXqglRmC_wikuBH8OWpIT24,29618
|
|
22
|
+
uvd_x402_sdk-0.4.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
23
|
+
uvd_x402_sdk-0.4.1.dist-info/top_level.txt,sha256=Exyjj_Kl7CDAGFMi72lT9oFPOYiRNZb3l8tr906mMmc,13
|
|
24
|
+
uvd_x402_sdk-0.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|