Estimate Credit Withdrawal Fees
curl --request GET \
--url https://api.example.com/v1/wallet/credit/withdraw-estimation \
--header 'Authorization: <authorization>' \
--header 'x-client-key: <x-client-key>'import requests
url = "https://api.example.com/v1/wallet/credit/withdraw-estimation"
headers = {
"x-client-key": "<x-client-key>",
"Authorization": "<authorization>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'x-client-key': '<x-client-key>', Authorization: '<authorization>'}
};
fetch('https://api.example.com/v1/wallet/credit/withdraw-estimation', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/wallet/credit/withdraw-estimation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"x-client-key: <x-client-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/wallet/credit/withdraw-estimation"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-client-key", "<x-client-key>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v1/wallet/credit/withdraw-estimation")
.header("x-client-key", "<x-client-key>")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/wallet/credit/withdraw-estimation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-client-key"] = '<x-client-key>'
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"wei": "6219123007416",
"eth": "0.000006219123007416",
"usdc": "0.01644666445335518319452825472"
}
{
"message": "Not authenticated"
}
{
"message": "Not authorized"
}
{
"message": "Internal server error"
}
Wallet
Estimate Credit Withdrawal Fees
Calculate network fees for withdrawing funds from the credit wallet
GET
/
v1
/
wallet
/
credit
/
withdraw-estimation
Estimate Credit Withdrawal Fees
curl --request GET \
--url https://api.example.com/v1/wallet/credit/withdraw-estimation \
--header 'Authorization: <authorization>' \
--header 'x-client-key: <x-client-key>'import requests
url = "https://api.example.com/v1/wallet/credit/withdraw-estimation"
headers = {
"x-client-key": "<x-client-key>",
"Authorization": "<authorization>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'x-client-key': '<x-client-key>', Authorization: '<authorization>'}
};
fetch('https://api.example.com/v1/wallet/credit/withdraw-estimation', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/wallet/credit/withdraw-estimation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"x-client-key: <x-client-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/wallet/credit/withdraw-estimation"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-client-key", "<x-client-key>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v1/wallet/credit/withdraw-estimation")
.header("x-client-key", "<x-client-key>")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/wallet/credit/withdraw-estimation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-client-key"] = '<x-client-key>'
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"wei": "6219123007416",
"eth": "0.000006219123007416",
"usdc": "0.01644666445335518319452825472"
}
{
"message": "Not authenticated"
}
{
"message": "Not authorized"
}
{
"message": "Internal server error"
}
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
- Currently supports Linea network only
- Returns fees in multiple denominations (wei, ETH, USDC)
Authentication
string
required
Your public API client key that identifies your environment
string
required
Bearer token obtained from OAuth flow or direct login
Query Parameters
boolean
default:false
Set to
true to route request to US backend environment (if available for your client)Response
string
Gas fee estimate in wei (smallest ETH unit)
string
Gas fee estimate in ETH
string
Gas fee estimate converted to USDC at current exchange rate
{
"wei": "6219123007416",
"eth": "0.000006219123007416",
"usdc": "0.01644666445335518319452825472"
}
{
"message": "Not authenticated"
}
{
"message": "Not authorized"
}
{
"message": "Internal server error"
}
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"
import requests
from decimal import Decimal
url = "https://dev.api.baanx.com/v1/wallet/credit/withdraw-estimation"
headers = {
"x-client-key": "YOUR_CLIENT_KEY",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
response = requests.get(url, headers=headers)
fees = response.json()
withdrawal_amount = Decimal("100.00")
fee_usdc = Decimal(fees['usdc'])
net_amount = withdrawal_amount - fee_usdc
print(f"Withdrawal Amount: {withdrawal_amount} USDC")
print(f"Network Fee: {fee_usdc} USDC")
print(f"You will receive: {net_amount} USDC")
const response = await fetch(
'https://dev.api.baanx.com/v1/wallet/credit/withdraw-estimation',
{
method: 'GET',
headers: {
'x-client-key': 'YOUR_CLIENT_KEY',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
}
);
const fees = await response.json();
const withdrawalAmount = 100.00;
const feeUSDC = parseFloat(fees.usdc);
const netAmount = withdrawalAmount - feeUSDC;
console.log(`Fee: $${feeUSDC.toFixed(4)} USDC`);
console.log(`Net amount: $${netAmount.toFixed(2)} USDC`);
interface WithdrawalFeeEstimate {
wei: string;
eth: string;
usdc: string;
}
async function estimateWithdrawalFees(): Promise<WithdrawalFeeEstimate> {
const response = await fetch(
'https://dev.api.baanx.com/v1/wallet/credit/withdraw-estimation',
{
method: 'GET',
headers: {
'x-client-key': 'YOUR_CLIENT_KEY',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
}
);
return await response.json();
}
const fees = await estimateWithdrawalFees();
const withdrawalAmount = BigInt('100000000');
const feeWei = BigInt(fees.wei);
const netAmount = withdrawalAmount - feeWei;
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`);
Related Endpoints
- Withdraw from Credit Wallet - Execute withdrawal after estimating fees
- Get Credit Wallet Balance - Check available balance before withdrawal
- Get External Wallets - View registered external wallets for withdrawal destination
Was this page helpful?