Prepare a withdrawal request
curl --request POST \
--url https://xreserve-api-testnet.circle.com/v1/prepare-withdrawal \
--header 'Content-Type: application/json' \
--data '
{
"batches": [
{
"token": "USDC",
"remoteDomain": 2,
"remoteDepositor": "<string>",
"finalDestinationDomain": 1,
"finalDestinationRecipient": "<string>",
"useCircleForwarding": true,
"valueExcludingFees": "10.00",
"valueIncludingFees": "10.00",
"finalDestinationCaller": "<string>",
"salt": "<string>",
"forwardingOptions": {
"maxFee": "<string>",
"hookData": "<string>",
"usesFastFinality": true
}
}
]
}
'import requests
url = "https://xreserve-api-testnet.circle.com/v1/prepare-withdrawal"
payload = { "batches": [
{
"token": "USDC",
"remoteDomain": 2,
"remoteDepositor": "<string>",
"finalDestinationDomain": 1,
"finalDestinationRecipient": "<string>",
"useCircleForwarding": True,
"valueExcludingFees": "10.00",
"valueIncludingFees": "10.00",
"finalDestinationCaller": "<string>",
"salt": "<string>",
"forwardingOptions": {
"maxFee": "<string>",
"hookData": "<string>",
"usesFastFinality": True
}
}
] }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
batches: [
{
token: 'USDC',
remoteDomain: 2,
remoteDepositor: '<string>',
finalDestinationDomain: 1,
finalDestinationRecipient: '<string>',
useCircleForwarding: true,
valueExcludingFees: '10.00',
valueIncludingFees: '10.00',
finalDestinationCaller: '<string>',
salt: '<string>',
forwardingOptions: {maxFee: '<string>', hookData: '<string>', usesFastFinality: true}
}
]
})
};
fetch('https://xreserve-api-testnet.circle.com/v1/prepare-withdrawal', 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://xreserve-api-testnet.circle.com/v1/prepare-withdrawal",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'batches' => [
[
'token' => 'USDC',
'remoteDomain' => 2,
'remoteDepositor' => '<string>',
'finalDestinationDomain' => 1,
'finalDestinationRecipient' => '<string>',
'useCircleForwarding' => true,
'valueExcludingFees' => '10.00',
'valueIncludingFees' => '10.00',
'finalDestinationCaller' => '<string>',
'salt' => '<string>',
'forwardingOptions' => [
'maxFee' => '<string>',
'hookData' => '<string>',
'usesFastFinality' => true
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://xreserve-api-testnet.circle.com/v1/prepare-withdrawal"
payload := strings.NewReader("{\n \"batches\": [\n {\n \"token\": \"USDC\",\n \"remoteDomain\": 2,\n \"remoteDepositor\": \"<string>\",\n \"finalDestinationDomain\": 1,\n \"finalDestinationRecipient\": \"<string>\",\n \"useCircleForwarding\": true,\n \"valueExcludingFees\": \"10.00\",\n \"valueIncludingFees\": \"10.00\",\n \"finalDestinationCaller\": \"<string>\",\n \"salt\": \"<string>\",\n \"forwardingOptions\": {\n \"maxFee\": \"<string>\",\n \"hookData\": \"<string>\",\n \"usesFastFinality\": true\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://xreserve-api-testnet.circle.com/v1/prepare-withdrawal")
.header("Content-Type", "application/json")
.body("{\n \"batches\": [\n {\n \"token\": \"USDC\",\n \"remoteDomain\": 2,\n \"remoteDepositor\": \"<string>\",\n \"finalDestinationDomain\": 1,\n \"finalDestinationRecipient\": \"<string>\",\n \"useCircleForwarding\": true,\n \"valueExcludingFees\": \"10.00\",\n \"valueIncludingFees\": \"10.00\",\n \"finalDestinationCaller\": \"<string>\",\n \"salt\": \"<string>\",\n \"forwardingOptions\": {\n \"maxFee\": \"<string>\",\n \"hookData\": \"<string>\",\n \"usesFastFinality\": true\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://xreserve-api-testnet.circle.com/v1/prepare-withdrawal")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"batches\": [\n {\n \"token\": \"USDC\",\n \"remoteDomain\": 2,\n \"remoteDepositor\": \"<string>\",\n \"finalDestinationDomain\": 1,\n \"finalDestinationRecipient\": \"<string>\",\n \"useCircleForwarding\": true,\n \"valueExcludingFees\": \"10.00\",\n \"valueIncludingFees\": \"10.00\",\n \"finalDestinationCaller\": \"<string>\",\n \"salt\": \"<string>\",\n \"forwardingOptions\": {\n \"maxFee\": \"<string>\",\n \"hookData\": \"<string>\",\n \"usesFastFinality\": true\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"batches": [
{
"burnIntents": [
{
"maxBlockHeight": "1000000",
"maxFee": "100000",
"spec": {
"version": 1,
"sourceDomain": 0,
"destinationDomain": 1,
"sourceContract": "0x000000000000000000000000a0b86a33e6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6",
"destinationContract": "0x000000000000000000000000b1c97a44e7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7",
"sourceToken": "0x000000000000000000000000c2d8b55f8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c",
"destinationToken": "0x000000000000000000000000d3e9c66f9d9d9d9d9d9d9d9d9d9d9d9d9d9d9d9d",
"sourceDepositor": "0x000000000000000000000000e4fad77fadadadadadadadadadadadadadadadad",
"destinationRecipient": "0x000000000000000000000000f5abc88abebebebebebebebebebebebebebebebe",
"sourceSigner": "0x000000000000000000000000a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0",
"destinationCaller": "0x000000000000000000000000b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1",
"value": "1000000",
"salt": "0xc3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4",
"hookData": {
"remoteDomain": 10001,
"remoteDepositor": "0x000000000000000000000000a0b86a33e6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6",
"remoteToken": "0x000000000000000000000000b1c97a44e7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7",
"forwardingContractAddress": "0x0000000000000000000000000000000000000000",
"forwardingCalldata": "0x"
}
}
}
],
"encoded": "<string>",
"messageHashToSign": "<string>"
}
]
}{
"success": false,
"message": "Error message"
}{
"success": false,
"message": "Error message"
}Prepare a withdrawal request
Turns the user’s burn transaction data on the remote chain into fully encoded burn intents to send to the /withdraw endpoint. This endpoint performs the following:
- Resolves contract and token addresses across networks.
- Determines the optimal forwarding strategy, such as redepositing to another xReserve remote domain or forwarding to a CCTP domain.
- Calculates transfer amounts and fees.
- Encodes forwarding call data with the calculated transfer amounts.
- Generates
maxBlockHeightandmaxFeevalues with safety buffers. - Returns data in the structure expected by the withdraw endpoint.
Note: The /withdraw endpoint requires signatures and the remote chain burnTxId in addition to the burn intent prepared by this endpoint.
POST
/
v1
/
prepare-withdrawal
Prepare a withdrawal request
curl --request POST \
--url https://xreserve-api-testnet.circle.com/v1/prepare-withdrawal \
--header 'Content-Type: application/json' \
--data '
{
"batches": [
{
"token": "USDC",
"remoteDomain": 2,
"remoteDepositor": "<string>",
"finalDestinationDomain": 1,
"finalDestinationRecipient": "<string>",
"useCircleForwarding": true,
"valueExcludingFees": "10.00",
"valueIncludingFees": "10.00",
"finalDestinationCaller": "<string>",
"salt": "<string>",
"forwardingOptions": {
"maxFee": "<string>",
"hookData": "<string>",
"usesFastFinality": true
}
}
]
}
'import requests
url = "https://xreserve-api-testnet.circle.com/v1/prepare-withdrawal"
payload = { "batches": [
{
"token": "USDC",
"remoteDomain": 2,
"remoteDepositor": "<string>",
"finalDestinationDomain": 1,
"finalDestinationRecipient": "<string>",
"useCircleForwarding": True,
"valueExcludingFees": "10.00",
"valueIncludingFees": "10.00",
"finalDestinationCaller": "<string>",
"salt": "<string>",
"forwardingOptions": {
"maxFee": "<string>",
"hookData": "<string>",
"usesFastFinality": True
}
}
] }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
batches: [
{
token: 'USDC',
remoteDomain: 2,
remoteDepositor: '<string>',
finalDestinationDomain: 1,
finalDestinationRecipient: '<string>',
useCircleForwarding: true,
valueExcludingFees: '10.00',
valueIncludingFees: '10.00',
finalDestinationCaller: '<string>',
salt: '<string>',
forwardingOptions: {maxFee: '<string>', hookData: '<string>', usesFastFinality: true}
}
]
})
};
fetch('https://xreserve-api-testnet.circle.com/v1/prepare-withdrawal', 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://xreserve-api-testnet.circle.com/v1/prepare-withdrawal",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'batches' => [
[
'token' => 'USDC',
'remoteDomain' => 2,
'remoteDepositor' => '<string>',
'finalDestinationDomain' => 1,
'finalDestinationRecipient' => '<string>',
'useCircleForwarding' => true,
'valueExcludingFees' => '10.00',
'valueIncludingFees' => '10.00',
'finalDestinationCaller' => '<string>',
'salt' => '<string>',
'forwardingOptions' => [
'maxFee' => '<string>',
'hookData' => '<string>',
'usesFastFinality' => true
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://xreserve-api-testnet.circle.com/v1/prepare-withdrawal"
payload := strings.NewReader("{\n \"batches\": [\n {\n \"token\": \"USDC\",\n \"remoteDomain\": 2,\n \"remoteDepositor\": \"<string>\",\n \"finalDestinationDomain\": 1,\n \"finalDestinationRecipient\": \"<string>\",\n \"useCircleForwarding\": true,\n \"valueExcludingFees\": \"10.00\",\n \"valueIncludingFees\": \"10.00\",\n \"finalDestinationCaller\": \"<string>\",\n \"salt\": \"<string>\",\n \"forwardingOptions\": {\n \"maxFee\": \"<string>\",\n \"hookData\": \"<string>\",\n \"usesFastFinality\": true\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://xreserve-api-testnet.circle.com/v1/prepare-withdrawal")
.header("Content-Type", "application/json")
.body("{\n \"batches\": [\n {\n \"token\": \"USDC\",\n \"remoteDomain\": 2,\n \"remoteDepositor\": \"<string>\",\n \"finalDestinationDomain\": 1,\n \"finalDestinationRecipient\": \"<string>\",\n \"useCircleForwarding\": true,\n \"valueExcludingFees\": \"10.00\",\n \"valueIncludingFees\": \"10.00\",\n \"finalDestinationCaller\": \"<string>\",\n \"salt\": \"<string>\",\n \"forwardingOptions\": {\n \"maxFee\": \"<string>\",\n \"hookData\": \"<string>\",\n \"usesFastFinality\": true\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://xreserve-api-testnet.circle.com/v1/prepare-withdrawal")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"batches\": [\n {\n \"token\": \"USDC\",\n \"remoteDomain\": 2,\n \"remoteDepositor\": \"<string>\",\n \"finalDestinationDomain\": 1,\n \"finalDestinationRecipient\": \"<string>\",\n \"useCircleForwarding\": true,\n \"valueExcludingFees\": \"10.00\",\n \"valueIncludingFees\": \"10.00\",\n \"finalDestinationCaller\": \"<string>\",\n \"salt\": \"<string>\",\n \"forwardingOptions\": {\n \"maxFee\": \"<string>\",\n \"hookData\": \"<string>\",\n \"usesFastFinality\": true\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"batches": [
{
"burnIntents": [
{
"maxBlockHeight": "1000000",
"maxFee": "100000",
"spec": {
"version": 1,
"sourceDomain": 0,
"destinationDomain": 1,
"sourceContract": "0x000000000000000000000000a0b86a33e6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6",
"destinationContract": "0x000000000000000000000000b1c97a44e7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7",
"sourceToken": "0x000000000000000000000000c2d8b55f8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c",
"destinationToken": "0x000000000000000000000000d3e9c66f9d9d9d9d9d9d9d9d9d9d9d9d9d9d9d9d",
"sourceDepositor": "0x000000000000000000000000e4fad77fadadadadadadadadadadadadadadadad",
"destinationRecipient": "0x000000000000000000000000f5abc88abebebebebebebebebebebebebebebebe",
"sourceSigner": "0x000000000000000000000000a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0",
"destinationCaller": "0x000000000000000000000000b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1",
"value": "1000000",
"salt": "0xc3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4",
"hookData": {
"remoteDomain": 10001,
"remoteDepositor": "0x000000000000000000000000a0b86a33e6b6b6b6b6b6b6b6b6b6b6b6b6b6b6b6",
"remoteToken": "0x000000000000000000000000b1c97a44e7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7",
"forwardingContractAddress": "0x0000000000000000000000000000000000000000",
"forwardingCalldata": "0x"
}
}
}
],
"encoded": "<string>",
"messageHashToSign": "<string>"
}
]
}{
"success": false,
"message": "Error message"
}{
"success": false,
"message": "Error message"
}Body
application/json
Contains data that prepares burn intents for withdrawal.
Array of burn intent batches.
Show child attributes
Show child attributes
Response
Successfully prepared burn intents ready for withdrawal.
Contains prepared burn intents.
List of prepared burn intents.
Show child attributes
Show child attributes
Was this page helpful?
⌘I