API
Deploy Token

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 /deployToken

Request

Headers

Content-Type: application/json
Authorization: Bearer YOUR_API_KEY

Request Body

ParameterTypeRequiredDefaultDescription
namestringYes-Token name (e.g., "My Token")
symbolstringYes-Token symbol (e.g., "MTK")
chain_idstringYes-Network chain ID (use "8453" for Base Mainnet)
apiKeystringYes-Your Digifi API key
baseCurrencystringNo"ETH"Base currency for the liquidity pool. Options: "ETH" (default), "DIGI"
sqrtPriceX96stringNo"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

FieldTypeDescription
successbooleanIndicates if deployment was successful
messagestringHuman-readable success message
data.namestringDeployed token name
data.symbolstringDeployed token symbol
data.chain_idstringNetwork chain ID
data.tokenAddressstringDeployed token contract address
data.poolAddressstringUniswap V4 pool address
data.positionIdstringLiquidity position NFT ID
data.explorerUrlstringBlock explorer URL for the token
data.feeCollectorstringAddress that receives token fees
deploymentIdstringUnique 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.

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.

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

FeatureETHDIGI
Pool PairETH/TokenDIGI/Token
Trading CurrencyNative ETH$DIGI Token
AccessibilityUniversal (everyone has ETH)DIGI holders
Use CaseGeneral token launchesDIGI ecosystem tokens
Factory Contract0xeF6...54B9D0xcdA...1FAa5
DefaultYesNo (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 sqrtPriceX96 is 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

  1. Validation: API key and parameters are validated
  2. Factory Selection: Chooses TokenFactory (ETH) or TokenFactoryUD (DIGI) based on baseCurrency
  3. Smart Contract Deployment: Token contract is deployed to Base
  4. Pool Creation: Uniswap V4 pool is initialized with selected base currency
  5. Liquidity Addition: Initial liquidity is provided
  6. LP NFT Transfer: LP position is transferred to token contract
  7. 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 details field for specific error
  • Verify your parameters are valid
  • Contact support with deploymentId

Debugging Tips

  1. Check deployment status: Use deploymentId to track
  2. Review error details: Check details field in error response
  3. Verify parameters: Ensure name/symbol are valid
  4. 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


Questions? Contact us at daniel@digifi.fun