DeltaDeFi
  • About
    • 👋Introduction
    • 📖Learn
      • Architecture
        • Account
        • App Vault
        • Hydra
        • Intent and Process
        • Order Book
      • Trade
        • Order Types
      • Whitepaper
  • Start Trading
    • ⚡Getting Started
      • Create Account
      • Deposit
      • Place Order
      • Cancel Order
      • Withdrawal
      • API Key / Dashboard
    • ⚙️Developers
      • Introduction
        • Base Url
        • Auth
        • Assets
      • Getting started
        • Deposit funds
        • Place a new order
        • Cancel an order
        • Withdraw funds
      • API Documentation
        • Account
          • Create new api key
          • Build deposit transaction
          • Submit deposit transaction
          • Deposit records
          • Withdrawal records
          • Order records
          • Build withdrawal transaction
          • Submit withdrawal transaction
          • Balances
        • App
          • Get mock USDX (testnet only)
          • Submit USDX transaction (testnet only)
        • Market
          • Market Price
          • Market Depth
          • Aggregated trades
        • Order
          • Build order transaction
          • Submit order Transaction
          • Build cancel Order Transaction
          • Submit cancel order transaction
      • Websocket Endpoints
        • Account streams
        • Market price streams
        • Market depth streams
      • SDK
        • Typescript
        • Python
  • FAQ
    • General
    • Product
    • Cardano
    • Disclaimer
Powered by GitBook
On this page
  1. Start Trading
  2. Developers
  3. Getting started

Withdraw funds

PreviousCancel an orderNextAPI Documentation

Last updated 1 month ago

1

Build withdrawal transaction

Please note only free balances are able to withdraw from the current hydra cycle.

For in-depth API details Build withdrawal transaction

In the following example we're withdrawing 10 Ada, equivalent to 10_000_000 lovelace.

curl --location 'https://api-staging.deltadefi.io/accounts/withdrawal/build' \
--header 'x-api-key: <your_api_key>' \
--header 'Content-Type: application/json' \
--data '{
	"withdrawal_amount": [
		{
			"unit": "lovelace",
			"quantity": "1000000"
		},
	]
}'

const axios = require('axios');
let data = JSON.stringify({
  "withdrawal_amount": [
    {
      "unit": "lovelace",
      "quantity": "1000000"
    },
  ]
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api-staging.deltadefi.io/accounts/withdrawal/build',
  headers: { 
    'x-api-key': '<your_api_key>', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://api-staging.deltadefi.io/accounts/withdrawal/build"
  method := "POST"

  payload := strings.NewReader(`{
	"withdrawal_amount": [
		{
			"unit": "lovelace",
			"quantity": "10000000"
		},
	]
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("x-api-key", "<your_api_key>")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

2

Submit withdrawal transaction

With the returned tx_hex from step 1, you will need to before submitting it.

For in-depth API details Submit withdrawal transaction

curl --location 'https://api-staging.deltadefi.io/accounts/withdrawal/submit' \
--header 'X-API-KEY: <your_api_key>' \
--header 'Content-Type: application/json' \
--data '{
    "signed_tx": ""
}'
const axios = require('axios');
let data = JSON.stringify({
  "signed_tx": ""
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api-staging.deltadefi.io/accounts/withdrawal/submit',
  headers: { 
    'X-API-KEY': '<your_api_key>', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://api-staging.deltadefi.io/accounts/withdrawal/submit"
  method := "POST"

  payload := strings.NewReader(`{
    "signed_tx": ""
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("X-API-KEY", "<your_api_key>")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}


Verifying withdrawal

After you have made a successful withdrawal request, you can check your latest account balance via the Balances API.

curl --location 'https://api-staging.deltadefi.io/accounts/balance' \
--header 'X-API-KEY: <your_api_key>'
const axios = require('axios');

let config = {
  method: 'get',
  maxBodyLength: Infinity,
  url: 'https://api-staging.deltadefi.io/accounts/balance',
  headers: { 
    'X-API-KEY': '<your_api_key>'
  }
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {

  url := "https://api-staging.deltadefi.io/accounts/balance"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("X-API-KEY", "<your_api_key>")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

Your requested withdrawal amount will be converted from Free will to Locked , and will be distributed during the next hydra closed.

Your Response should look something like below:

[
    {
        "asset": "ada",
        "asset_unit": "",
        "free": 0,
        "locked": 100
    }
]

Related FAQ

⚙️
✅
sign it
How can I sign a Cardano transaction?
What is the minimum amount of deposit and withdrawal?
How long does it take to deposit & withdraw?
What are locked and free balances?
#free-and-locked-balances