Withdraw Remaining Funds

This function is used to withdraw funds that are stuck in escrow and cannot be withdrawn due to the way multi-release escrow works, since disputes in this case are handled at the milestone level.

In single-release escrow accounts, this endpoint is not necessary because disputes are handled at the escrow account level, so if there is any remaining balance in the contract, a dispute is opened and the remaining balance is withdrawn.

Headers

Name
Value

Content-Type

application/json

x-api-key

<token>

Open API

post
Authorizations
Body
contractIdstringRequired

ID (address) that identifies the escrow contract

Example: CAZ6UQX7...
disputeResolverstringRequired

Address of the user defined to resolve disputes in an escrow

Example: GDISPUTE...XYZ
Responses
post
/escrow/multi-release/withdraw-remaining-funds
POST /escrow/multi-release/withdraw-remaining-funds HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 188

{
  "contractId": "CAZ6UQX7...",
  "disputeResolver": "GDISPUTE1234567890...",
  "distributions": [
    {
      "address": "GAPPROVER1234567890...",
      "amount": 150
    },
    {
      "address": "GRECEIVER1234567890...",
      "amount": 850
    }
  ]
}
{
  "status": "SUCCESS",
  "unsignedTransaction": "AAAAAgAAAAAtWsgedQ...."
}

What this Endpoint returns?

This endpoint returns the transaction unsigned so that the transaction can be signed by means of a customer wallet.

Use Example:

import axios from "axios";

const http = axios.create({
  baseURL: "https://dev.api.trustlesswork.com",
  timeout: 10000,
  headers: {
    "Content-Type": "application/json",
    "x-api-key": your_api_key,
  },
});

export const useExample = async () => {
    // Get the signer address
    const { address } = await kit.getAddress();

    const response = await http.post(
      "/escrow/multi-release/withdraw-remaining-funds",
      {
        // body requested for the endpoint
      },
    ); 
    
    // Get the unsigned transaction hash
    const { unsignedTransaction } = response.data;

    // Sign the transaction by wallet
    const { signedTxXdr } = await signTransaction(unsignedTransaction, {
      address,
      networkPassphrase: WalletNetwork.TESTNET,
    });

    // Send the transaction to Stellar Network
    const tx = await http.post("/helper/send-transaction", {
      signedXdr: signedTxXdr,
    });

    const { data } = tx;

    return data;
}

Last updated

Was this helpful?