Skip to main content
GET
https://dev.api.baanx.com
/
v1
/
delegation
/
chain
/
config
curl --request GET \
  --url 'https://dev.api.baanx.com/v1/delegation/chain/config' \
  --header 'x-client-key: YOUR_PUBLIC_KEY' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'
{
  "networks": [
    {
      "network": "ethereum",
      "environment": "production",
      "chainId": "1",
      "delegationContract": "0xb453ba76d9ca952115e9e32ca069c96e846c5d9d",
      "tokens": {
        "usdc": {
          "symbol": "usdc",
          "decimals": 6,
          "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
        },
        "usdt": {
          "symbol": "usdt",
          "decimals": 6,
          "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7"
        }
      }
    },
    {
      "network": "linea",
      "environment": "production",
      "chainId": "59144",
      "delegationContract": "0x9dd23A4a0845f10d65D293776B792af1131c7B30",
      "tokens": {
        "usdc": {
          "symbol": "usdc",
          "decimals": 6,
          "address": "0x176211869ca2b568f2a7d4ee941e073a821ee1ff"
        },
        "usdt": {
          "symbol": "usdt",
          "decimals": 6,
          "address": "0xa219439258ca9da29e9cc4ce5596924745e12b93"
        }
      }
    }
  ],
  "count": 2,
  "_links": {
    "self": "/v1/delegation/chain/config"
  }
}

Overview

This endpoint retrieves blockchain network configuration required to implement wallet delegation in your frontend application. Use this data before initiating the delegation flow to get the correct contract addresses and chain IDs for the user’s selected network.
When to Use: Call this endpoint before Step 2 of the delegation workflow to get the correct contract addresses, chain IDs, and spender addresses for building approval transactions in the user’s wallet provider.

What You’ll Get

  • Chain IDs for each supported network (Linea, Ethereum)
  • Token contract addresses (USDC, USDT) for each network
  • Platform spender addresses that users will approve for token spending
  • Network-specific configuration for building approval transactions
  • Solana token mint addresses and delegate address

Use Case

Use this configuration data in your frontend (Step 2 of delegation) to construct the correct approval transaction with the right contract addresses and chain ID for the user’s wallet provider.

Authentication

x-client-key
string
required
Your public client key for API authentication
Authorization
string
required
Bearer token format: Bearer {access_token}

Query Parameters

network
string
Filter by network name to get configuration for a specific blockchain network.Supported values: ethereum, linea, solana, etherlinkExample: ?network=ethereumNote: If not specified, returns configuration for all supported networks.
region
string
Region identifier for environment routing. Use us for US-specific Linea routing.Example: ?region=us
Alternatively, you can use the x-us-env: true header instead of the region query parameter.

Response

networks
array
required
Array of network configurations matching the query filters
count
integer
required
Number of networks returned in the responseExample: 1 (when filtering by network), 3 (when getting all networks)
HATEOAS links for API navigation
curl --request GET \
  --url 'https://dev.api.baanx.com/v1/delegation/chain/config' \
  --header 'x-client-key: YOUR_PUBLIC_KEY' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'
{
  "networks": [
    {
      "network": "ethereum",
      "environment": "production",
      "chainId": "1",
      "delegationContract": "0xb453ba76d9ca952115e9e32ca069c96e846c5d9d",
      "tokens": {
        "usdc": {
          "symbol": "usdc",
          "decimals": 6,
          "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
        },
        "usdt": {
          "symbol": "usdt",
          "decimals": 6,
          "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7"
        }
      }
    },
    {
      "network": "linea",
      "environment": "production",
      "chainId": "59144",
      "delegationContract": "0x9dd23A4a0845f10d65D293776B792af1131c7B30",
      "tokens": {
        "usdc": {
          "symbol": "usdc",
          "decimals": 6,
          "address": "0x176211869ca2b568f2a7d4ee941e073a821ee1ff"
        },
        "usdt": {
          "symbol": "usdt",
          "decimals": 6,
          "address": "0xa219439258ca9da29e9cc4ce5596924745e12b93"
        }
      }
    }
  ],
  "count": 2,
  "_links": {
    "self": "/v1/delegation/chain/config"
  }
}

Response Codes

CodeDescription
200Blockchain configuration retrieved successfully
401Authentication failed - invalid or expired access token
403Authorization failed - insufficient permissions
404No networks found for the specified filters
498Invalid client key
499Missing client key
500Internal server error

Implementation Example

Here’s how to use this endpoint in a complete delegation workflow:
TypeScript Implementation
interface ChainConfig {
  linea: NetworkConfig;
  ethereum: NetworkConfig;
  solana: SolanaConfig;
}

interface NetworkConfig {
  chain_id: number;
  usdc_address: string;
  usdt_address: string;
  spender_address: string;
}

interface SolanaConfig {
  usdc_mint: string;
  usdt_mint: string;
  delegate_address: string;
}

async function loadBlockchainConfig(accessToken: string): Promise<ChainConfig> {
  const response = await fetch('https://dev.api.baanx.com/v1/delegation/chain/config', {
    method: 'GET',
    headers: {
      'x-client-key': 'YOUR_PUBLIC_KEY',
      'Authorization': `Bearer ${accessToken}`
    }
  });

  if (!response.ok) {
    throw new Error(`Failed to load config: ${response.status}`);
  }

  return await response.json();
}

// Usage in delegation workflow
async function initiateDelegation(
  network: 'linea' | 'ethereum' | 'solana',
  currency: 'usdc' | 'usdt',
  amount: string
) {
  // Step 0: Get blockchain configuration
  const config = await loadBlockchainConfig(userAccessToken);

  if (network === 'solana') {
    // Use Solana configuration
    const mintAddress = currency === 'usdc' 
      ? config.solana.usdc_mint 
      : config.solana.usdt_mint;
    const delegateAddress = config.solana.delegate_address;
    
    // Proceed with Solana delegation logic...
  } else {
    // Use EVM configuration
    const networkConfig = config[network];
    const tokenAddress = currency === 'usdc' 
      ? networkConfig.usdc_address 
      : networkConfig.usdt_address;
    const spenderAddress = networkConfig.spender_address;
    const chainId = networkConfig.chain_id;
    
    // Proceed with EVM delegation logic...
    await approveTokenSpending(tokenAddress, spenderAddress, amount, chainId);
  }
}

async function approveTokenSpending(
  tokenAddress: string,
  spenderAddress: string,
  amount: string,
  chainId: number
) {
  // Verify user's wallet is on correct network
  const currentNetwork = await provider.getNetwork();
  if (currentNetwork.chainId !== chainId) {
    throw new Error(`Please switch to chain ID ${chainId}`);
  }

  // Create approval transaction using configuration
  const tokenContract = new ethers.Contract(tokenAddress, ERC20_ABI, signer);
  const tx = await tokenContract.approve(
    spenderAddress,
    ethers.utils.parseUnits(amount, 6) // Assuming 6 decimals for USDC/USDT
  );

  return await tx.wait();
}

Security Best Practices

  • Always verify contract addresses - Compare received addresses against known good addresses
  • Validate address format - Ensure EVM addresses start with 0x and are 42 characters long
  • Check network compatibility - Verify addresses match the intended blockchain network
  • Use checksummed addresses - Apply EIP-55 checksum validation for Ethereum addresses
  • Cache configuration temporarily - Avoid repeated API calls during user session
  • Implement cache invalidation - Refresh configuration periodically or when errors occur
  • Handle network-specific configs - Store separate configurations for different networks
  • Validate before use - Always verify cached configuration is still valid
  • Handle network failures gracefully - Implement retry logic with exponential backoff
  • Provide fallback mechanisms - Have backup methods if configuration loading fails
  • Log configuration issues - Track when configuration retrieval fails for debugging
  • User-friendly error messages - Explain clearly when configuration cannot be loaded

Common Use Cases

Multi-Network Support

Configure your application to support multiple blockchain networks:
TypeScript Multi-Network
class DelegationManager {
  private config: ChainConfig | null = null;

  async initialize(accessToken: string) {
    this.config = await loadBlockchainConfig(accessToken);
  }

  getNetworkOptions() {
    if (!this.config) throw new Error('Configuration not loaded');
    
    return [
      {
        name: 'Linea',
        chainId: this.config.linea.chain_id,
        currencies: ['USDC', 'USDT']
      },
      {
        name: 'Ethereum',
        chainId: this.config.ethereum.chain_id,
        currencies: ['USDC', 'USDT']
      },
      {
        name: 'Solana',
        currencies: ['USDC', 'USDT']
      }
    ];
  }

  getContractAddress(network: string, currency: string): string {
    if (!this.config) throw new Error('Configuration not loaded');
    
    const networkConfig = this.config[network as keyof ChainConfig];
    if (!networkConfig) throw new Error(`Unsupported network: ${network}`);
    
    if (network === 'solana') {
      const solanaConfig = networkConfig as SolanaConfig;
      return currency === 'usdc' ? solanaConfig.usdc_mint : solanaConfig.usdt_mint;
    } else {
      const evmConfig = networkConfig as NetworkConfig;
      return currency === 'usdc' ? evmConfig.usdc_address : evmConfig.usdt_address;
    }
  }
}

Configuration Validation

Validate configuration data before using in transactions:
JavaScript Validation
function validateChainConfig(config) {
  const requiredFields = {
    linea: ['chain_id', 'usdc_address', 'usdt_address', 'spender_address'],
    ethereum: ['chain_id', 'usdc_address', 'usdt_address', 'spender_address'],
    solana: ['usdc_mint', 'usdt_mint', 'delegate_address']
  };

  for (const [network, fields] of Object.entries(requiredFields)) {
    if (!config[network]) {
      throw new Error(`Missing ${network} configuration`);
    }

    for (const field of fields) {
      if (!config[network][field]) {
        throw new Error(`Missing ${field} in ${network} configuration`);
      }
    }
  }

  // Validate address formats
  const evmAddressRegex = /^0x[a-fA-F0-9]{40}$/;
  if (!evmAddressRegex.test(config.linea.usdc_address)) {
    throw new Error('Invalid Linea USDC address format');
  }

  return true;
}

Further Reading