Quick Start Guide
Get Started
Start accepting USDT payments in 5 minutes. This guide shows you how to integrate FromChain into your application.
Step 1: Get Your API Key
Contact our team to get your API credentials. You'll receive:
API Key
gw_live_your_key_hereWebhook Secret
whsec_your_secret_hereStep 2: Create Your First Invoice
Make a POST request to create a payment invoice:
create-invoice.js
const response = await fetch('https://api.fromchain.io/v1/invoices', {
method: 'POST',
headers: {
'Authorization': 'Bearer gw_live_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
amountExpected: '100.00',
externalId: 'order_12345',
description: 'Payment for Order #12345',
expiresInMinutes: 30
})
});
const invoice = await response.json();
console.log('Deposit Address:', invoice.depositAddress);
console.log('Invoice ID:', invoice.id);Response Example:
{
"id": "inv_abc123",
"depositAddress": "0x1234567890123456789012345678901234567890",
"amountExpected": "100.00",
"status": "PENDING",
"expiresAt": "2025-12-18T12:30:00.000Z",
"createdAt": "2025-12-18T12:00:00.000Z"
}Step 3: Show Payment Instructions
Display the deposit address and amount to your customer:
display-payment.js
// Show this information to your customer
const paymentInfo = {
address: invoice.depositAddress,
amount: invoice.amountExpected,
network: 'Binance Smart Chain (BSC)',
token: 'USDT (BEP-20)'
};
// Display QR code, copy button, etc.
console.log('Send exactly', paymentInfo.amount, 'USDT to:');
console.log(paymentInfo.address);Step 4: Handle Webhook Notifications
Set up a webhook endpoint to receive payment status updates:
webhook-handler.js
// Express.js example
app.post('/api/webhooks/fromchain', express.json(), (req, res) => {
const event = req.body;
// Verify webhook signature (see Security docs)
const signature = req.headers['x-webhook-signature'];
// ... verify signature ...
switch (event.type) {
case 'invoice.detected':
console.log('Payment detected:', event.data.id);
break;
case 'invoice.confirmed':
console.log('Payment confirmed:', event.data.id);
// Update your database, fulfill order
break;
case 'invoice.paid_out':
console.log('Funds sent to your wallet:', event.data.id);
break;
case 'invoice.failed':
console.log('Payment failed:', event.data.id);
break;
}
res.json({ received: true });
});Step 5: Check Invoice Status
You can also poll the invoice status:
check-status.js
const response = await fetch(
`https://api.fromchain.io/v1/invoices/${invoiceId}`,
{
headers: {
'Authorization': 'Bearer gw_live_your_api_key_here'
}
}
);
const invoice = await response.json();
if (invoice.status === 'PAID_OUT') {
console.log('Payment complete!');
console.log('Received:', invoice.amountReceived, 'USDT');
console.log('Your payout:', invoice.payoutAmount, 'USDT');
}Invoice Lifecycle
1
PENDING
Invoice created, waiting for payment
2
DETECTED
Payment detected on blockchain (0 confirmations)
3
CONFIRMED
Payment confirmed (5 blocks)
4
PROCESSING_PAYOUT
Sending funds to your wallet
5
PAID_OUT
Complete! Funds transferred to your address