API Docs
withdrawBalance()

irys.withdrawBalance(amount)

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

Parameters

- amount: The amount to withdraw. Value must 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
}

Example

const irys = await getIrys();
 
try {
	// 1. Get current balance
	const curBalance = await irys.getLoadedBalance();
	// 2. Withdraw all
	const response = await irys.withdrawBalance(curBalance);
	console.log(`Successfully withdrew ${irys.utils.fromAtomic(curBalance)} ${irys.token}`);
} catch (e) {
	console.log("Error uploading data ", e);
}