Mint API Documentation
Overview
The mint
API allows you to mint NFT tokens directly to any wallet address through a single HTTP request. Your Server Wallet handles all blockchain interactions automatically, making NFT minting as simple as calling a REST API.
Authentication
All requests must include your secret key in the authorization header:
Authorization: Bearer sk-your-secret-key
Endpoint
POST https://api.lootexplus.com/mint
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
contractAddress | string | Yes | The NFT contract address to mint from |
chainId | number | Yes | Blockchain network ID (e.g., 1868 for Sonelum) |
recipientAddress | string | Yes | Wallet address to receive the minted NFT |
quantity | number | Yes | Number of tokens to mint |
metadata | object | No | Custom data for your business logic |
Example Request
curl -X POST https://api.lootexplus.com/mint \
-H "Authorization: Bearer sk-your-secret-key" \
-H "Content-Type: application/json" \
-d '{
"contractAddress": "0x1a52aa96b98fc49cdb94d88cd7f0714b06230543",
"chainId": 1868,
"recipientAddress": "0x7D878A527e86321aECd80A493E584117A907A0AB",
"quantity": 1,
"metadata": {
"username": "alice123",
"productId": "premium_sword",
"consumedPoints": 100
}
}'
Response Handling
The API uses a smart response system based on blockchain confirmation time:
- 200 OK: Transaction confirmed within 30 seconds
- 202 Accepted: Transaction submitted but still pending confirmation
Successful Response (200 OK)
When the transaction is confirmed quickly:
{
"id": "5cabaebb-40f5-4920-8511-25d5fabd1277",
"jobId": "1e7ba1c87325b059af542f37",
"status": "completed",
"projectId": "p-2e48091c5b40d0d03a564e5a",
"transactionHash": "0xa3ea7bcfb35e9b2f614fa3befdf0317db4dad686d788d3b796669d3d0c45808f",
"chainId": 1868,
"from": "0x50A1eD7DEb09508771288BcEa72143436ffCF7Fb",
"to": "0x54e1e95356c9b3eb4ad991824a78ddb7a184c6fe",
"value": "0",
"gasUsed": "111235",
"gasPrice": "1000456",
"totalGasFee": "111285723160",
"metadata": {
"username": "alice123",
"productId": "premium_sword",
"consumedPoints": 100
},
"createdAt": "2025-05-26T06:12:47.757Z",
"updatedAt": "2025-05-26T06:12:52.094Z"
}
Pending Response (202 Accepted)
When the transaction needs more time to confirm:
{
"id": "5cabaebb-40f5-4920-8511-25d5fabd1277",
"jobId": "1e7ba1c87325b059af542f37",
"status": "pending",
"projectId": "p-2e48091c5b40d0d03a564e5a",
"transactionHash": "0xa3ea7bcfb35e9b2f614fa3befdf0317db4dad686d788d3b796669d3d0c45808f",
"chainId": 1868,
"from": "0x50A1eD7DEb09508771288BcEa72143436ffCF7Fb",
"to": "0x54e1e95356c9b3eb4ad991824a78ddb7a184c6fe",
"value": "0",
"gasUsed": null,
"gasPrice": null,
"totalGasFee": null,
"metadata": {
"username": "alice123",
"productId": "premium_sword",
"consumedPoints": 100
},
"createdAt": "2025-05-26T06:12:47.757Z",
"updatedAt": "2025-05-26T06:12:52.094Z"
}
Checking Transaction Status
For pending transactions, you can poll the status using the transaction ID:
GET https://api.lootexplus.com/transactions/{id}
Response:
{
"id": "5cabaebb-40f5-4920-8511-25d5fabd1277",
"status": "completed",
"transactionHash": "0xa3ea7bcfb35e9b2f614fa3befdf0317db4dad686d788d3b796669d3d0c45808f",
"gasUsed": "111235",
"totalGasFee": "111285723160",
"metadata": {
"username": "alice123",
"productId": "premium_sword",
"consumedPoints": 100
}
}
Webhook Integration
For real-time updates, set up webhooks to receive transaction events automatically.
Setting Up Webhooks
- Create a POST endpoint in your application to receive webhook events
- Add your webhook URL in Lootex Plus > Projects > Webhooks
- Enable the events you want to monitor:
transaction.created
transaction.completed
transaction.failed
Example Webhook Handler
const express = require('express');
const app = express();
app.use(express.json());
app.post('/webhook', async (req, res) => {
const event = req.body;
switch(event.type) {
case 'transaction.completed':
console.log('NFT minted successfully:', event.data.transactionHash);
// Process your business logic
const { username, consumedPoints } = event.data.metadata;
const user = await DB.findUser(username);
await user.spendPoints(consumedPoints);
break;
case 'transaction.failed':
console.log('Minting failed:', event.data.error);
// Handle failed transaction (e.g., refund points)
break;
}
res.status(200).send('Webhook received');
});
app.listen(3000);
Webhook Event Structure
{
"event": "transaction.completed",
"data": {
"status": "completed",
"jobId": "3773a09a26d713a7bdb7cddc",
"projectId": "p-2e48091c5b40d0d03a564e5a",
"chainId": 1868,
"transactionHash": "0x9e949c2967f3d8afd2d79d6287cb41b49e83b3cc67865161ac5df901e314c75b",
"metadata": {
"type": "mint",
"contractAddress": "0x1a52aa96b98fc49cdb94d88cd7f0714b06230543",
"quantity": 1,
"recipientAddress": "0xbF6692795A07684147838fC54A2764aa884C440c",
"username": "alice123",
"productId": "premium_sword",
"consumedPoints": 100
}
},
"timestamp": "2025-05-22T08:56:06.278Z"
}
Error Handling
Common error scenarios and responses:
Status Code | Error | Description |
---|---|---|
400 | invalid_request | Missing or invalid parameters |
401 | unauthorized | Invalid or missing API key |
402 | insufficient_funds | Not enough ETH for gas fees |
404 | contract_not_found | Invalid contract address |
500 | internal_error | Server or blockchain error |
Best Practices
- Use Metadata Wisely: Include relevant business data in metadata for webhook processing
- Handle Async Operations: Always implement webhook handlers for reliable transaction processing
- Monitor Gas Fees: Keep your Server Wallet funded to avoid failed transactions
- Implement Retries: Handle network issues with appropriate retry logic
- Validate Recipients: Ensure recipient addresses are valid before minting