DEVELOPER DOCS
API Docs
withdrawBalance()

bundlr.withdrawBalance(amount)

Withdraws the supplied amount. The parameter value must in atomic units.

Parameters

- amount: The amount to withdraw. Value should be in atomic units.

Returns

- response: Either a 400 or 200 code, combined with the following values:

400 - something went wrong
response.data = "Not enough balance for requested withdrawal"
 
200 - Ok
response.data = {
	requested, // the requested amount,
	fee, // the reward required by the network (network fee)
	final, // total cost to your account (requested + fee)
	tx-id, // the ID of the withdrawal transaction
}
try {
  // 1. Get current balance
  const curBalance = await bundlr.getLoadedBalance();
  // 2. Withdraw all
  const response = await bundlr.withdrawBalance(curBalance);
 
  console.log(
    `Funds withdrawn txID=${response.data.tx_id} amount requested=${response.data.requested}`
  );
} catch (e) {
  console.log("Error funding node ", e);
}