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 | Default | 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 |
baseCurrency | string | No | "ETH" | Base currency for the liquidity pool. Options: "ETH" (default), "DIGI" |
sqrtPriceX96 | string | No | "79228162514264337593543950336" | Custom starting price (Uniswap V4 sqrt price format). Only used with baseCurrency: "DIGI". Defaults to 1:1 ratio |
Example Requests
Deploy with ETH (Default)
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"
}'Deploy with DIGI
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",
"baseCurrency": "DIGI"
}'Deploy with DIGI and Custom Starting Price
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",
"baseCurrency": "DIGI",
"sqrtPriceX96": "79228162514264337593543950336"
}'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,
baseCurrency = "ETH",
sqrtPriceX96 = null
) => {
try {
const payload = {
name: name,
symbol: symbol,
chain_id: "8453",
apiKey: process.env.DIGIFI_API_KEY,
baseCurrency: baseCurrency, // "ETH" or "DIGI"
};
// Add sqrtPriceX96 if provided
if (sqrtPriceX96) {
payload.sqrtPriceX96 = sqrtPriceX96;
}
const response = await axios.post(
"https://api.digifi.fun/deployToken",
payload,
{
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("Pool Pair:", `${baseCurrency}/Token`);
console.log("Explorer:", response.data.data.explorerUrl);
return response.data;
}
} catch (error) {
console.error("Deployment failed:", error.response?.data || error.message);
throw error;
}
};
// Usage examples
// Deploy with ETH (default)
deployToken("My Awesome Token", "MAT")
.then((data) => console.log("Deployment ID:", data.deploymentId))
.catch((error) => console.error("Error:", error));
// Deploy with DIGI (uses default 1:1 ratio)
deployToken("DIGI Token", "DGTK", "DIGI")
.then((data) => console.log("Deployment ID:", data.deploymentId))
.catch((error) => console.error("Error:", error));
// Deploy with DIGI and custom starting price
deployToken("DIGI Token", "DGTK", "DIGI", "79228162514264337593543950336")
.then((data) => console.log("Deployment ID:", data.deploymentId))
.catch((error) => console.error("Error:", error));Python
import requests
import os
def deploy_token(name, symbol, base_currency='ETH', sqrt_price_x96=None):
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,
'baseCurrency': base_currency # "ETH" or "DIGI"
}
# Add sqrtPriceX96 if provided
if sqrt_price_x96:
payload['sqrtPriceX96'] = sqrt_price_x96
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"Pool Pair: {base_currency}/Token")
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 examples
# Deploy with ETH (default)
deploy_token('My Awesome Token', 'MAT')
# Deploy with DIGI (uses default 1:1 ratio)
deploy_token('DIGI Token', 'DGTK', 'DIGI')
# Deploy with DIGI and custom starting price
deploy_token('DIGI Token', 'DGTK', 'DIGI', '79228162514264337593543950336')TypeScript
interface DeployTokenRequest {
name: string;
symbol: string;
chain_id: string;
apiKey: string;
baseCurrency?: "ETH" | "DIGI"; // Optional: defaults to "ETH"
sqrtPriceX96?: string; // Optional: custom starting price (for DIGI), defaults to 1:1 ratio
}
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,
baseCurrency: "ETH" | "DIGI" = "ETH",
sqrtPriceX96?: string
): Promise<DeployTokenResponse> => {
const apiKey = process.env.DIGIFI_API_KEY;
const payload: DeployTokenRequest = {
name,
symbol,
chain_id: "8453",
apiKey: apiKey!,
baseCurrency,
};
// Add sqrtPriceX96 if provided
if (sqrtPriceX96) {
payload.sqrtPriceX96 = sqrtPriceX96;
}
const response = await fetch("https://api.digifi.fun/deployToken", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
},
body: JSON.stringify(payload),
});
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("Pool Pair:", `${baseCurrency}/Token`);
console.log("Explorer:", data.data.explorerUrl);
}
return data;
};
// Usage examples
// Deploy with ETH (default)
deployToken("My Awesome Token", "MAT")
.then((data) => console.log("Deployment ID:", data.deploymentId))
.catch((error) => console.error("Error:", error));
// Deploy with DIGI (uses default 1:1 ratio)
deployToken("DIGI Token", "DGTK", "DIGI")
.then((data) => console.log("Deployment ID:", data.deploymentId))
.catch((error) => console.error("Error:", error));
// Deploy with DIGI and custom starting price
deployToken("DIGI Token", "DGTK", "DIGI", "79228162514264337593543950336")
.then((data) => console.log("Deployment ID:", data.deploymentId))
.catch((error) => console.error("Error:", error));Base Currency Options
The optional baseCurrency parameter allows you to choose which currency your token will be paired with in the Uniswap V4 liquidity pool.
Available Options
ETH (Default)
When baseCurrency is omitted or set to "ETH", your token will be paired with native ETH.
- Factory Contract:
0xeF6ce237F69D238Fe3CfAB801f24b4cfd3A54B9D(opens in a new tab) - Pool Pair: ETH/Token
- Use Case: General public token launches
- Accessibility: Anyone with ETH can trade
Example:
{
"name": "MyToken",
"symbol": "MTK",
"chain_id": "8453",
"apiKey": "dg_YOUR_API_KEY_HERE"
// baseCurrency defaults to "ETH"
}DIGI
When baseCurrency is set to "DIGI", your token will be paired with the $DIGI token instead of ETH.
- Factory Contract:
0xcdAB147bC10F4eCc32Fc0bc96c2D739C6F21FAa5(opens in a new tab) - DIGI Token:
0x0A1a3A82c75144D059bC36D09fA1F9Be4fA0EeF0(opens in a new tab) - Pool Pair: DIGI/Token
- Use Case: DIGI ecosystem integration
- Benefits: Supports $DIGI utility, contributes to DIGI ecosystem
- Custom Pricing: Supports
sqrtPriceX96parameter for custom starting prices
Example (default 1:1 ratio):
{
"name": "MyToken",
"symbol": "MTK",
"chain_id": "8453",
"apiKey": "dg_YOUR_API_KEY_HERE",
"baseCurrency": "DIGI"
}Example with custom starting price:
{
"name": "MyToken",
"symbol": "MTK",
"chain_id": "8453",
"apiKey": "dg_YOUR_API_KEY_HERE",
"baseCurrency": "DIGI",
"sqrtPriceX96": "79228162514264337593543950336" // Custom starting price (1:1 ratio)
}Key Differences
| Feature | ETH | DIGI |
|---|---|---|
| Pool Pair | ETH/Token | DIGI/Token |
| Trading Currency | Native ETH | $DIGI Token |
| Accessibility | Universal (everyone has ETH) | DIGI holders |
| Use Case | General token launches | DIGI ecosystem tokens |
| Factory Contract | 0xeF6...54B9D | 0xcdA...1FAa5 |
| Default | Yes | No (must specify explicitly) |
When to Use Each Option
Choose ETH if:
- You want maximum accessibility for traders
- You're launching a general-purpose token
- You want to attract users who already have ETH
Choose DIGI if:
- You want to integrate with the DIGI ecosystem
- You want to support $DIGI token utility
- Your target audience holds $DIGI tokens
- You want your token to be part of the DIGI-paired ecosystem
Understanding sqrtPriceX96
The sqrtPriceX96 parameter is used to set the initial price ratio in the Uniswap V4 pool. It's only applicable when using baseCurrency: "DIGI".
What is it?
- A Uniswap V4 price format representing the square root of the price ratio
- Encoded as a fixed-point number with 96 fractional bits
- Formula:
sqrtPriceX96 = sqrt(price) * 2^96
Default Value:
"79228162514264337593543950336"(represents a 1:1 price ratio)- Used automatically when
sqrtPriceX96is not provided
When to customize:
- If you want a specific starting price for your token relative to DIGI
- Advanced use case: most users can use the default 1:1 ratio
Example values:
// 1:1 ratio (default - 1 DIGI = 1 Token)
"79228162514264337593543950336";
// For other ratios, calculate: sqrt(desiredPrice) * 2^96
// Where desiredPrice = token1/token0 (DIGI/Token)Note: ETH-based deployments don't support custom starting prices and will use a fixed very low starting price.
Deployment Process
What Happens During Deployment
- Validation: API key and parameters are validated
- Factory Selection: Chooses TokenFactory (ETH) or TokenFactoryUD (DIGI) based on
baseCurrency - Smart Contract Deployment: Token contract is deployed to Base
- Pool Creation: Uniswap V4 pool is initialized with selected base currency
- 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 daniel@digifi.fun