Deploy Token
Deploy new ERC20 tokens with automatic Uniswap V4 liquidity pool creation.
Overview
The /deployToken endpoint creates a new ERC20 token and automatically:
- Deploys the token contract
- Creates a Uniswap V4 liquidity pool
- Initializes liquidity
- Transfers LP NFT to token contract
- Returns token address and deployment details
Endpoint
POST /deployTokenRequest
Headers
Content-Type: application/json
Authorization: Bearer YOUR_API_KEYRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Token name (e.g., "My Token") |
symbol | string | Yes | Token symbol (e.g., "MTK") |
chain_id | string | Yes | Network chain ID (use "8453" for Base Mainnet) |
apiKey | string | Yes | Your Digifi API key |
Example Request
curl -X POST https://api.digifi.fun/deployToken \
-H "Content-Type: application/json" \
-H "Authorization: Bearer dg_YOUR_API_KEY_HERE" \
-d '{
"name": "MyToken",
"symbol": "MTK",
"chain_id": "8453",
"apiKey": "dg_YOUR_API_KEY_HERE"
}'Response
Success Response (200)
{
"success": true,
"message": "Deployment completed successfully",
"data": {
"name": "TokenName",
"symbol": "TKN",
"chain_id": "8453",
"tokenAddress": "0x...",
"poolAddress": "0x...",
"positionId": "123",
"explorerUrl": "https://basescan.org/address/0x...",
"feeCollector": "0x..."
},
"deploymentId": "unique-deployment-id"
}Error Response (500)
{
"success": false,
"message": "Deployment failed",
"error": "Deployment process exited with code: 1",
"details": "Full deployment output and error logs...",
"deploymentId": "unique-deployment-id"
}Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if deployment was successful |
message | string | Human-readable success message |
data.name | string | Deployed token name |
data.symbol | string | Deployed token symbol |
data.chain_id | string | Network chain ID |
data.tokenAddress | string | Deployed token contract address |
data.poolAddress | string | Uniswap V4 pool address |
data.positionId | string | Liquidity position NFT ID |
data.explorerUrl | string | Block explorer URL for the token |
data.feeCollector | string | Address that receives token fees |
deploymentId | string | Unique identifier for this deployment |
Code Examples
JavaScript / Node.js
const axios = require("axios");
const deployToken = async (name, symbol) => {
try {
const response = await axios.post(
"https://api.digifi.fun/deployToken",
{
name: name,
symbol: symbol,
chain_id: "8453",
apiKey: process.env.DIGIFI_API_KEY,
},
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.DIGIFI_API_KEY}`,
},
}
);
if (response.data.success) {
console.log("Token deployed successfully!");
console.log("Token Address:", response.data.data.tokenAddress);
console.log("Explorer:", response.data.data.explorerUrl);
return response.data;
}
} catch (error) {
console.error("Deployment failed:", error.response?.data || error.message);
throw error;
}
};
// Usage
deployToken("My Awesome Token", "MAT")
.then((data) => console.log("Deployment ID:", data.deploymentId))
.catch((error) => console.error("Error:", error));Python
import requests
import os
def deploy_token(name, symbol):
url = 'https://api.digifi.fun/deployToken'
api_key = os.getenv('DIGIFI_API_KEY')
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {api_key}'
}
payload = {
'name': name,
'symbol': symbol,
'chain_id': '8453',
'apiKey': api_key
}
try:
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
data = response.json()
if data['success']:
print('Token deployed successfully!')
print(f"Token Address: {data['data']['tokenAddress']}")
print(f"Explorer: {data['data']['explorerUrl']}")
return data
except requests.exceptions.RequestException as e:
print(f'Deployment failed: {e}')
if hasattr(e.response, 'json'):
print(e.response.json())
raise
# Usage
deploy_token('My Awesome Token', 'MAT')TypeScript
interface DeployTokenRequest {
name: string;
symbol: string;
chain_id: string;
apiKey: string;
}
interface DeployTokenResponse {
success: boolean;
message: string;
data: {
name: string;
symbol: string;
chain_id: string;
tokenAddress: string;
poolAddress: string;
positionId: string;
explorerUrl: string;
feeCollector: string;
};
deploymentId: string;
}
const deployToken = async (
name: string,
symbol: string
): Promise<DeployTokenResponse> => {
const apiKey = process.env.DIGIFI_API_KEY;
const response = await fetch("https://api.digifi.fun/deployToken", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
},
body: JSON.stringify({
name,
symbol,
chain_id: "8453",
apiKey,
}),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.message || "Deployment failed");
}
const data: DeployTokenResponse = await response.json();
if (data.success) {
console.log("Token deployed successfully!");
console.log("Token Address:", data.data.tokenAddress);
console.log("Explorer:", data.data.explorerUrl);
}
return data;
};
// Usage
deployToken("My Awesome Token", "MAT")
.then((data) => console.log("Deployment ID:", data.deploymentId))
.catch((error) => console.error("Error:", error));Deployment Process
What Happens During Deployment
- Validation: API key and parameters are validated
- Smart Contract Deployment: Token contract is deployed to Base
- Pool Creation: Uniswap V4 pool is initialized
- Liquidity Addition: Initial liquidity is provided
- LP NFT Transfer: LP position is transferred to token contract
- Record Creation: Deployment record is saved to database
Typical Timeline
- Validation: < 1 second
- Deployment: 30-60 seconds
- Pool Setup: 10-20 seconds
- Total Time: ~45-90 seconds
Limitations
Rate Limits
- 1 deployment per minute per API key
- 150 deployments per month (free tier)
- Rate limits reset on the 1st of each month
Token Constraints
- Name: 1-50 characters
- Symbol: 1-10 characters (typically 3-5)
- Chain: Currently Base Mainnet only (chain_id: 8453)
Troubleshooting
Common Errors
"Monthly deployment limit reached"
- Wait until the 1st of next month
- Contact support for enterprise limits
"Token deployment is rate-limited"
- Wait 60 seconds between deployments
- Retry after the cooldown period
"Deployment failed with exit code: 1"
- Check the
detailsfield for specific error - Verify your parameters are valid
- Contact support with
deploymentId
Debugging Tips
- Check deployment status: Use
deploymentIdto track - Review error details: Check
detailsfield in error response - Verify parameters: Ensure name/symbol are valid
- Check usage: Verify you haven't hit rate limits
Best Practices
Input Validation
function validateTokenParams(name, symbol) {
if (!name || name.length < 1 || name.length > 50) {
throw new Error("Token name must be 1-50 characters");
}
if (!symbol || symbol.length < 1 || symbol.length > 10) {
throw new Error("Token symbol must be 1-10 characters");
}
return true;
}Error Handling
const deployWithRetry = async (name, symbol, maxRetries = 3) => {
for (let i = 0; i < maxRetries; i++) {
try {
return await deployToken(name, symbol);
} catch (error) {
if (i === maxRetries - 1) throw error;
// Wait before retry (exponential backoff)
await new Promise((resolve) =>
setTimeout(resolve, 1000 * Math.pow(2, i))
);
}
}
};Monitoring
// Track deployment status
const monitorDeployment = async (deploymentId) => {
// Poll deployment status
const status = await checkDeploymentStatus(deploymentId);
if (status.success) {
console.log(`Deployment ${deploymentId} completed`);
} else {
console.error(`Deployment ${deploymentId} failed:`, status.error);
}
};Next Steps
- Check Rewards - Monitor token trading fees
- Error Handling - Handle errors properly
- Code Examples - More implementation examples
Questions? Contact us at digifievm999@gmail.com