Quick Start Guide
This guide will help you integrate Cryptofuse API into your application with a focus on ERC20 token payments on EVM-compatible networks.
Prerequisites
Before you begin, ensure you have:
- A Cryptofuse merchant account
- OAuth2 client credentials (client ID and client secret)
- Basic understanding of RESTful APIs
- A server-side application (never expose credentials in client-side code)
Step 1: Authentication
Cryptofuse uses OAuth 2.0 with the client credentials flow for secure API access.
Getting an Access Token
Request an access token using your client credentials:
# Create base64 encoded credentials
CLIENT_ID="your_client_id"
CLIENT_SECRET="your_client_secret"
CREDENTIALS=$(echo -n "$CLIENT_ID:$CLIENT_SECRET" | base64)
# Request access token
curl -X POST https://api.cryptofuse.io/o/token/ \
-H "Authorization: Basic $CREDENTIALS" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&scope=read write"
Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "read write"
}
Using the Access Token
Include the access token in all API requests:
Authorization: Bearer your_access_token_here
Step 2: Create a Payment
Create a payment request for USDTERC20 (Tether USD on Ethereum):
curl -X POST https://api.cryptofuse.io/payments/ \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"price_amount": 100.00,
"price_currency": "USD",
"pay_currency": "USDTERC20",
"order_id": "ORDER-12345",
"order_description": "Premium subscription payment",
"callback_url": "https://your-site.com/webhook/payment"
}'
Alternative: Using Blockchain + Token
You can also specify the blockchain and token separately:
{
"price_amount": 100.00,
"price_currency": "USD",
"blockchain": "ethereum",
"token": "USDT",
"order_id": "ORDER-12345"
}
Payment Response
{
"transaction_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "waiting",
"price_amount": "100.00",
"price_currency": "USD",
"pay_amount": "100.050000",
"pay_currency": "USDTERC20",
"blockchain_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f8b8E0",
"blockchain_network": "ETH",
"token": "USDT",
"expiry_time": "2025-01-15T10:30:00Z",
"order_id": "ORDER-12345",
"created_at": "2025-01-15T10:00:00Z"
}
Important Fields
transaction_id: Unique payment identifier (store this!)blockchain_address: EVM address where customer sends paymentpay_amount: Exact amount customer must sendexpiry_time: Payment deadline (default: 30 minutes)
Step 3: Display Payment Information
Show your customer:
- Payment address:
0x742d35Cc6634C0532925a3b844Bc9e7595f8b8E0 - Amount to send:
100.050000 USDT - Network:
Ethereum (ERC20) - Time limit: 30 minutes
QR Code Generation
Generate a QR code for easy mobile payments:
// Example using qrcode.js
const paymentData = `ethereum:${address}?value=${amount}`;
QRCode.toDataURL(paymentData, (err, url) => {
// Display QR code image
});
Step 4: Monitor Payment Status
Check payment status regularly or wait for webhook notifications:
curl -X GET https://api.cryptofuse.io/payments/550e8400-e29b-41d4-a716-446655440000/ \
-H "Authorization: Bearer $ACCESS_TOKEN"