x402-hub API Reference
Base URL
Production:
https://hub.sigwei.com
Authentication
x402-hub uses two authentication patterns:
Bearer Token (for Auth and History endpoints):
Authorization: Bearer <JWT_TOKEN>No Authentication (for Protocol endpoints):
Protocol endpoints are public and don't require authentication
Authentication Endpoints
Get Authentication Message
GET /api/v1/auth/message?walletAddress=0xYOUR_WALLET
Response:
{
"message": "hub.sigwei.com wants you to sign in with your Ethereum account:\n0x742D35Cc6634C19D8B4e8d5C1234567890123456\n\nURI: https://hub.sigwei.com\nVersion: 1\nChain ID: 8453\nNonce: abc123...\nIssued At: 2024-01-15T10:30:00Z",
"apiVersion": "v1",
"timestamp": "2024-01-15T10:30:00Z"
}Query Parameters:
walletAddress(required): Ethereum wallet address (EIP-55 checksum format recommended)
Response Fields:
message: SIWE-compliant message to signapiVersion: API versiontimestamp: ISO 8601 timestamp
SIWE Compliance: Messages follow the Sign-In with Ethereum (EIP-4361) standard.
Login with Wallet Signature
POST /api/v1/auth/login
Content-Type: application/json
{
"message": "FULL_SIGNED_MESSAGE",
"signature": "0x1234567890abcdef..."
}
Response:
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "abcd1234...",
"user": {
"id": 1,
"walletAddress": "0x742d35cc6634c0532925a3b8c2414f4e456c10f4",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
},
"apiVersion": "v1",
"timestamp": "2024-01-15T10:30:00Z"
}Request Body:
message(required): The full SIWE message from/auth/messagesignature(required): Wallet signature of the message
Response Fields:
accessToken: JWT token for authenticated requests (15 min expiry)refreshToken: Token for refreshing access token (7 days expiry)user: User informationapiVersion: API versiontimestamp: ISO 8601 timestamp
Refresh Token
POST /api/v1/auth/refresh
Content-Type: application/json
{
"refreshToken": "your_refresh_token"
}
Response:
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "new_refresh_token",
"apiVersion": "v1",
"timestamp": "2024-01-15T10:30:00Z"
}Request Body:
refreshToken(required): The refresh token from login
Response Fields:
accessToken: New JWT access tokenrefreshToken: New refresh tokenapiVersion: API versiontimestamp: ISO 8601 timestamp
Get Current User
GET /api/v1/auth/me
Authorization: Bearer <token>
Response:
{
"user": {
"id": 1,
"walletAddress": "0x742d35cc6634c0532925a3b8c2414f4e456c10f4",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
},
"apiVersion": "v1",
"timestamp": "2024-01-15T10:30:00Z"
}Headers:
Authorization: Bearer token (required)
Logout
POST /api/v1/auth/logout
Authorization: Bearer <token>
Response:
{
"success": true,
"message": "Logged out successfully",
"apiVersion": "v1",
"timestamp": "2024-01-15T10:30:00Z"
}Headers:
Authorization: Bearer token (required)
Transaction History Endpoints
Get Transaction History
GET /api/v1/history?limit=20&offset=0&network=base
Authorization: Bearer <token>
Query Parameters:
- limit (required): Number of transactions to return (1-100)
- offset (optional): Number of transactions to skip (default: 0)
- network (optional): Filter by network ("base" or "base-sepolia")
Response:
{
"success": true,
"history": [
{
"id": 123,
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:35:00Z",
"signerAddress": "0x742d35cc6634c0532925a3b8c2414f4e456c10f4",
"amount": "1000000",
"network": "base",
"chainId": 8453,
"transactionHash": "0x1234567890abcdef...",
"status": "success",
"error": null,
"type": "transfer",
"x402Data": {
"paymentRequirements": "{\"amount\":1000000,\"currency\":\"USDC\",\"to\":\"0x...\"}",
"paymentPayload": [123, 34, 120, 52, 48, 50, 86, 101, 114, 115, 105, 111, 110, 34, 58, 49],
"paymentHeader": "Bearer payment_token_here",
"settleResponse": [123, 34, 115, 116, 97, 116, 117, 115, 34, 58, 34, 115, 117, 99, 99, 101, 115, 115, 34],
"typedData": "{\"types\":{\"EIP712Domain\":[]}}"
},
"purchaseData": null
}
],
"pagination": {
"totalCount": 156,
"limit": 20,
"offset": 0,
"hasNext": true,
"hasPrev": false
},
"apiVersion": "v1",
"timestamp": "2024-01-15T10:30:00Z"
}Headers:
Authorization: Bearer token (required)
Query Parameters:
limit(required): 1-100offset(optional): Default 0network(optional): "base" or "base-sepolia"
Response Fields:
success: Boolean indicating successhistory: Array of transaction history itemspagination: Pagination informationtotalCount: Total number of transactionslimit: Requested limitoffset: Requested offsethasNext: Whether there are more resultshasPrev: Whether there are previous results
apiVersion: API versiontimestamp: ISO 8601 timestamp
Transaction History Item Fields:
id: Unique transaction IDcreatedAt: Transaction creation timeupdatedAt: Last update timesignerAddress: Wallet address that signedamount: Amount in wei (6 decimals for USDC)network: Network name ("base" or "base-sepolia")chainId: Blockchain chain IDtransactionHash: On-chain transaction hash (null if pending)status: "pending", "success", or "failed"error: Error message (null if no error)type: "transfer" or "purchase"x402Data: x402 protocol datapurchaseData: PayGate purchase data (only for 402ify purchases)
Protocol Endpoints
All x402 protocol endpoints support both EVM (Ethereum Virtual Machine) networks like Base and Solana (SVM) networks. The payload structure differs between the two, but the API endpoints and response formats are consistent.
Check Supported Networks
GET /supported
Response:
{
"kinds": [
{
"scheme": "exact",
"network": "base",
"assets": [
{
"address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"name": "USDC",
"symbol": "USDC",
"decimals": 6
}
]
},
{
"scheme": "exact",
"network": "base-sepolia",
"assets": [
{
"address": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"name": "USDC",
"symbol": "USDC",
"decimals": 6
}
]
}
]
}Response Fields:
kinds: Array of supported payment kindsscheme: Payment scheme ("exact")network: Network nameassets: Supported assets on this networkaddress: Token contract addressname: Token namesymbol: Token symboldecimals: Token decimals
Verify Payment
Verifies a payment for both EVM and Solana networks.
EVM (Ethereum/Base) Example:
POST /verify
Content-Type: application/json
{
"x402Version": 1,
"paymentPayload": {
"scheme": "exact",
"network": "base",
"payload": {
"signature": "0x...",
"authorization": {
"from": "0xSender",
"to": "0xRecipient",
"value": "1000000",
"validAfter": "0",
"validBefore": "9999999999",
"nonce": "0x..."
}
}
},
"paymentRequirements": {
"scheme": "exact",
"network": "base",
"exact": {
"from": "0xSender",
"to": "0xRecipient",
"amount": "1000000",
"token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
}
}
}Solana Example:
POST /verify
Content-Type: application/json
{
"x402Version": 1,
"paymentPayload": {
"x402Version": 1,
"scheme": "exact",
"network": "solana-devnet",
"payload": {
"transaction": "base64_encoded_solana_transaction"
}
},
"paymentRequirements": {
"scheme": "exact",
"network": "solana-devnet",
"maxAmountRequired": "1000000",
"resourceUrl": "https://sigwei.com",
"asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"extra": {
"feePayer": "FeePayerPublicKey..."
}
}
}Response (same for both EVM and Solana):
{
"isValid": true,
"invalidReason": null
}Request Body:
x402Version: Protocol version (always 1)paymentPayload: Payment data from payer (EVM or Solana structure)paymentRequirements: Payment requirements from payee
Response Fields:
isValid: Boolean indicating if payment is validinvalidReason: Error message if invalid (null if valid)
Settle Payment
Settles a payment for both EVM and Solana networks.
EVM (Ethereum/Base) Example:
POST /settle
Content-Type: application/json
{
"x402Version": 1,
"paymentPayload": {
"scheme": "exact",
"network": "base",
"payload": {
"signature": "0x...",
"authorization": {
"from": "0xSender",
"to": "0xRecipient",
"value": "1000000",
"validAfter": "0",
"validBefore": "9999999999",
"nonce": "0x..."
}
}
},
"paymentRequirements": { ... },
"confirm": true,
"useDbId": false
}Solana Example:
POST /settle
Content-Type: application/json
{
"x402Version": 1,
"paymentPayload": {
"x402Version": 1,
"scheme": "exact",
"network": "solana-devnet",
"payload": {
"transaction": "base64_encoded_solana_transaction"
}
},
"paymentRequirements": {
"scheme": "exact",
"network": "solana-devnet",
"maxAmountRequired": "1000000",
"resourceUrl": "https://sigwei.com",
"asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"extra": {
"feePayer": "FeePayerPublicKey..."
}
},
"confirm": true,
"useDbId": false
}Response (same for both EVM and Solana):
{
"status": "success",
"transaction": "0x1325a7b20147c57dab8c3f3f1234567890abcdef...",
"network": "base",
"amount": "1000000"
}Request Body:
x402Version: Protocol version (always 1)paymentPayload: Payment data from payer (EVM or Solana structure)paymentRequirements: Payment requirements from payeeconfirm(optional): Enable on-chain verification (default: false)useDbId(optional): Return database ID instead of tx hash (default: false)
Response Fields:
status: "success" or "failed"transaction: Transaction hash or database IDnetwork: Network nameamount: Amount settled in base units (wei for EVM, lamports for Solana)
Transfer
Executes a transfer for both EVM and Solana networks.
EVM (Ethereum/Base) Example:
POST /transfer
Content-Type: application/json
{
"payload": {
"signature": "0x...",
"authorization": {
"from": "0xSender",
"to": "0xRecipient",
"value": "1000000",
"validAfter": "0",
"validBefore": "9999999999",
"nonce": "0x..."
}
},
"network": "base",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"confirm": true
}Solana Example:
POST /transfer
Content-Type: application/json
{
"payload": {
"transaction": "base64_encoded_solana_transaction"
},
"network": "solana-devnet",
"asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": 1000000,
"recipient": "RecipientPublicKey...",
"confirm": true
}Response (same for both EVM and Solana):
{
"status": "success",
"transaction": "0x1325a7b20147c57dab8c3f3f1234567890abcdef...",
"network": "base",
"amount": "1000000"
}Request Body:
payload: Transfer payload (EVM or Solana structure)EVM: Contains
signatureandauthorizationwith transfer detailsSolana: Contains
transaction(base64-encoded pre-signed transaction)
network: Network name (e.g., "base", "base-sepolia", "solana-devnet")asset: Token address (EVM) or mint address (Solana)amount(required for Solana): Transfer amount in base unitsrecipient(required for Solana): Recipient wallet addressconfirm(optional): Enable on-chain verification (default: false)
Response Fields:
status: "success" or "failed"transaction: Transaction hash or signaturenetwork: Network nameamount: Amount transferred in base units
Error Response Format
All errors return structured responses:
{
"error": {
"type": "validation|authentication|payment|server",
"code": "SPECIFIC_ERROR_CODE",
"message": "Human-readable error description"
},
"apiVersion": "v1",
"timestamp": "2024-01-15T10:30:00Z"
}Common HTTP Status Codes
200- OK (successful request)400- Bad Request (validation errors)401- Unauthorized (missing or invalid authentication)403- Forbidden (valid auth but insufficient permissions)404- Not Found500- Internal Server Error
Common Error Codes
Authentication Errors (401):
AUTH_REQUIRED- Authentication required but not providedINVALID_TOKEN- JWT token is invalid or expiredINVALID_SIGNATURE- Wallet signature verification failed
Validation Errors (400):
INVALID_ADDRESS- Invalid Ethereum addressINVALID_AMOUNT- Invalid amount specifiedINVALID_NETWORK- Unsupported networkMISSING_PARAMETER- Required parameter missing
Payment Errors (400):
PAYMENT_INVALID- Payment verification failedINSUFFICIENT_FUNDS- Not enough balanceNONCE_ALREADY_USED- Nonce has been used
Rate Limiting
x402-hub does not currently implement rate limiting. However, clients should implement reasonable retry logic and avoid excessive requests.
Pagination
The history endpoint supports pagination:
GET /api/v1/history?limit=20&offset=0 # First page
GET /api/v1/history?limit=20&offset=20 # Second page
GET /api/v1/history?limit=20&offset=40 # Third pageUse the pagination object in responses to determine if more pages exist:
{
"pagination": {
"totalCount": 156,
"limit": 20,
"offset": 0,
"hasNext": true,
"hasPrev": false
}
}Network Information
EVM Networks
Base Mainnet
Network:
baseChain ID: 8453
USDC Contract:
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
Base Sepolia Testnet
Network:
base-sepoliaChain ID: 84532
USDC Contract:
0x036CbD53842c5426634e7929541eC2318f3dCF7e
Solana Networks
Solana Devnet
Network:
solana-devnetUSDC Mint:
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1vRPC:
https://api.devnet.solana.com
Solana Mainnet
Network:
solana-mainnetUSDC Mint:
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1vRPC:
https://api.mainnet-beta.solana.com
Related Documentation
Last updated