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

ParameterTypeRequiredDescription
namestringYesToken name (e.g., "My Token")
symbolstringYesToken symbol (e.g., "MTK")
chain_idstringYesNetwork chain ID (use "8453" for Base Mainnet)
apiKeystringYesYour 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

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) => {
  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

  1. Validation: API key and parameters are validated
  2. Smart Contract Deployment: Token contract is deployed to Base
  3. Pool Creation: Uniswap V4 pool is initialized
  4. Liquidity Addition: Initial liquidity is provided
  5. LP NFT Transfer: LP position is transferred to token contract
  6. 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 digifievm999@gmail.com