Skip to main content
GET
/
v1
/
wallet
/
credit
/
withdraw-estimation
{
  "wei": "6219123007416",
  "eth": "0.000006219123007416",
  "usdc": "0.01644666445335518319452825472"
}

Overview

This endpoint calculates the estimated gas fees for withdrawing funds from a credit wallet to an external wallet address. Network fees vary based on blockchain congestion and are deducted from the withdrawal amount. Always call this endpoint before initiating a withdrawal to inform users of the net amount they will receive. Use Cases:
  • Display estimated fees to users before withdrawal confirmation
  • Calculate net amount user will receive after fees
  • Compare fee estimates across different times to optimize for lower costs
  • Provide transparency in withdrawal costs
Network Support:
  • Currently supports Linea network only
  • Returns fees in multiple denominations (wei, ETH, USDC)

Authentication

x-client-key
string
required
Your public API client key that identifies your environment
Authorization
string
required
Bearer token obtained from OAuth flow or direct login

Query Parameters

x-us-env
boolean
default:false
Set to true to route request to US backend environment (if available for your client)

Response

wei
string
Gas fee estimate in wei (smallest ETH unit)
eth
string
Gas fee estimate in ETH
usdc
string
Gas fee estimate converted to USDC at current exchange rate
{
  "wei": "6219123007416",
  "eth": "0.000006219123007416",
  "usdc": "0.01644666445335518319452825472"
}

Code Examples

curl -X GET "https://dev.api.baanx.com/v1/wallet/credit/withdraw-estimation" \
  -H "x-client-key: YOUR_CLIENT_KEY" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Best Practices

Fee Calculation: Fees are estimates based on current network conditions. Actual fees may vary slightly when the transaction is executed. Always add a small buffer for production implementations.
User Experience: Display both the fee amount and the net amount the user will receive. This transparency helps users make informed decisions about timing their withdrawals.
Fee Volatility: Gas fees on blockchains fluctuate based on network congestion. During high-traffic periods, fees can increase significantly. Consider implementing fee alerts or maximum fee thresholds.

Edge Cases

High Network Congestion

During peak network usage, gas fees can spike:
  • Fees may temporarily exceed the withdrawal amount for small transactions
  • Consider implementing minimum withdrawal amounts to ensure economical transactions
  • Poll this endpoint periodically to catch fee reductions

Fee Precision

Fee amounts include many decimal places for accuracy:
  • Always use decimal or BigInt types, never floating-point arithmetic
  • Round displayed values appropriately for user presentation
  • Store full precision values for accounting purposes

Network Limitations

Currently Linea network only:
  • Other networks will return an error
  • Check user’s registered external wallet network before calling
  • Future updates may support additional networks

Calculation Example

Example: Net Amount Calculation
// User wants to withdraw 100 USDC
const withdrawalAmount = 100.00;

// Fetch current fee estimate
const fees = await fetchFeeEstimate();
const feeUSDC = parseFloat(fees.usdc); // e.g., 0.01644666

// Calculate what user receives
const netAmount = withdrawalAmount - feeUSDC; // 99.98355334 USDC

// Display to user
console.log(`Withdrawal: ${withdrawalAmount} USDC`);
console.log(`Network Fee: ${feeUSDC.toFixed(6)} USDC`);
console.log(`You receive: ${netAmount.toFixed(2)} USDC`);