Crypto Withdraw

This guide explains the process of withdrawing crypto from the Saber Money wallet, particularly in cases of failed or uncompleted sell transactions. We will walk you through the necessary steps, the API calls involved, and the expected responses.

Overview of the Withdrawal Process

When a sell transaction fails or is not created after a deposit, you can withdraw the crypto from the user’s Saber Money wallet. The process for initiating a withdrawal consists of the following three steps:

  1. Fetch the User Wallet Balance (refer to user operations)
  2. Create a Withdraw Transaction
  3. Wait for the Success Callback Webhook

Create Withdraw Transaction

Once the balance is confirmed, you can proceed to initiate the withdrawal transaction. This step involves calling the appropriate API to create the withdrawal request.

API Endpoint:
POST /api/v1/wallet/withdraw/?address={address}&coin={coin}&amount={amount}&network={network}

Request:

curl --location --request POST '<https://mudrex.com/api/v1/wallet/withdraw/?address=0x1b3e8b01632f6d891ae1538a8151c70e634e06bc&coin=USDT&amount=19.7&network=MATIC'>  
--header 'X-Timestamp: {{timestamp}}'  
--header 'X-Client-Id: 18e963ea-39fd-4a1b-b1e6-decbfe791d31'  
--header 'X-Request-Id: 4'  
--header 'X-User-Id: 9df1da6c-0eb1-4c32-936c-026d2faf768a'  
--header 'X-Secret-Key;'

{  
  "success": true,  
  "data": {  
    "msg": "Withdrawal request submitted successfully",  
    "data": {  
      "id": 16430,  
      "status": "Created",  
      "address": "0x1b3e8b01632f6d891ae1538a8151c70e634e06bc",  
      "network": "Polygon",  
      "symbol": "USDT",  
      "created_at": "11 Oct 22 11:07 AM"  
    }  
  }  
}

Fetch Withdraw Status

After the withdrawal transaction has been created, you need to monitor the status to confirm the success of the transaction.

API Endpoint to Fetch Transaction Status:
GET /api/v1/wallet/withdraw/{transaction_id}

Request:

curl --location '<https://mudrex.com/api/v1/wallet/withdraw/6db8ce0d-edec-4e22-bea5-6512a4f4427e'>  
--header 'X-Timestamp: {{timestamp}}'  
--header 'X-Client-Id: •••••••'  
--header 'X-Request-Id: qeyrtyry'  
--header 'X-User-Id: •••••••'  
--header 'X-Secret-Key: •••••••'  
--header 'Host;'  
--data ''
{  
  "success": true,  
  "data": {  
    "id": "6db8ce0d-edec-4e22-bea5-6512a4f4427e",  
    "status": "COMPLETED",  
    "amount": 5,  
    "network": "MATIC",  
    "address": "0x1b3e8b01632f6d891ae1538a8151c70e634e06bc",  
    "txn_hash": "Internal transfer 127771103959"  
  }  
}

Fetch All Withdrawals for a User

This endpoint can be used to fetch all past withdrawal transactions for a given user.

API Endpoint:
GET /api/v1/wallet/withdraw_history?per_page=10&page=0

Request:

curl --location '<https://mudrex.com/api/v1/wallet/withdraw_history?per_page=10&page=0'>  
--header 'X-Timestamp: {{timestamp}}'  
--header 'X-Client-Id: 18e963ea-39fd-4a1b-b1e6-decbfe791d31'  
--header 'X-Request-Id: d'  
--header 'X-User-Id: 9df1da6c-0eb1-4c32-936c-026d2faf768a'  
--header 'X-Secret-Key;'  
--data ''

{  
  "success": true,  
  "data": {  
    "history": [  
      {  
        "id": 16430,  
        "amount": "9.70000000",  
        "status": "Reverted",  
        "address": "0x1b3e8b01632f6d891ae1538a8151c70e634e06bc",  
        "network": "Polygon",  
        "currency": "USDT",  
        "created_at": "11 Oct 22 11:07 AM"  
      }  
    ]  
  }  
}

Fetch Network List

If you need to determine which networks are available for withdrawals for a specific coin, you can use the following API to retrieve the list of supported networks for that coin.

API Endpoint:
GET /api/v1/wallet/coin/info?coins={coin}

Request:

curl --location '<https://mudrex.com/api/v1/wallet/coin/info?coins=USDT'>  
--header 'X-Client-Id: •••••••'  
--header 'X-Request-Id: 9'  
--header 'X-User-Id: •••••••'  
--header 'X-Secret-Key: •••••••'  
--header 'X-Timestamp: {{timestamp}}'

{  
  "success": true,  
  "data": \[  
    {  
      "name": "TetherUS",  
      "symbol": "USDT",  
      "network_list": \[  
        {  
          "network": "MATIC",  
          "name": "Polygon",  
          "address_regex": "^(0x)[0-9A-Fa-f]{40}$",  
          "processing_time": "Typically takes 30 mins"  
        }  
      ]  
    }  
  ]  
}

Important Notes

  • Withdrawal through Dashboard: The withdrawal functionality is also available on the dashboard and can be executed through our UI as well.
  • Address Validation: Make sure to use the correct format for the recipient’s address as per the selected network. For instance, the Polygon network requires addresses starting with “0x”.
  • Processing Time: Network processing times can vary. Most withdrawals are processed within 15–30 minutes depending on the network.
  • Withdrawal Limits: Ensure that the user has sufficient funds in their wallet to complete the withdrawal. Transaction fees, if any, will be deducted from the amount being withdrawn.

By following these steps and using the provided API calls, you can efficiently manage withdrawals from the Saber Money wallet in case of failed or uncompleted transactions.

More details here.