XChain Platform Action - WITHDRAW
This action withdraws tokens from a contract’s derived address back to the contract owner.
PARAMS
| Name | Type | Description |
|---|---|---|
VERSION |
String | Format Version |
CONTRACT_ACTION_INDEX |
Integer | Action index of the deployed contract |
TICK |
String | Ticker name or Ticker ID |
QUANTITY |
String | Amount of TICK to withdraw |
Formats
Version 0
VERSION|CONTRACT_ACTION_INDEX|TICK|QUANTITY
Examples
WITHDRAW|0|12345|MYTOKEN|500
Withdraw 500 MYTOKEN from contract 12345 (debits C:BTC:12345, credits the owner)
WITHDRAW|0|12345|^99|250
Withdraw 250 of the token with TICK_ID 99 from contract 12345
Rules
- Available on all chains
- The contract identified by
CONTRACT_ACTION_INDEXmust exist - Only the contract owner (the address that broadcast the original
DEPLOYaction) may withdraw - From the
OWNER_WITHDRAW_OPT_INflag day, judged after the owner check: for a contract whoseDEPLOYlands at or after the activation, WITHDRAW is valid only when the contract’s exported meta declaresownerWithdraw: true; anything else (the key absent,false, or any non-truevalue) fails withinvalid: CONTRACT_ACTION_INDEX (owner withdraw not enabled). A contract deployed before the activation keeps the pre-flag-day behavior: the owner may withdraw regardless of meta. See contract identity manifest. - The contract’s derived address (
C:<CHAIN>:<CONTRACT_ACTION_INDEX>) must hold a sufficient balance ofTICKto coverQUANTITY SOURCEmust not be sleeping (an address-levelSLEEPin effect at the block): the action fails withinvalid: SOURCE (sleeping).TICKmust not be sleeping (a token-levelSLEEPin effect at the block): the action fails withinvalid: TICK (sleeping), the same refusalDEPOSITand every other token-moving action makes, so a sleeping token cannot be pulled out of contract custody.- Both sleep refusals are judged after the balance check and in that order,
SOURCEthenTICK: a withdrawal the contract cannot cover failsinvalid: insufficient contract balanceeven when the source or the token is sleeping (xchain-indexer/src/actions/withdraw.jsvalidateTokenAndBalance). They are judged before the controller guards below, so a sleeping withdrawal runs no guard and pays no guard gas. - From the
CONTROLLER_CUSTODY_GUARDflag day, a withdrawal runs the token’stransferorallcontroller guard and then the withdrawer’s own address controller guard. The guarded move is from the contract custody addressC:<CHAIN>:<index>to the withdrawer (SOURCE), where<index>isCONTRACT_ACTION_INDEX. This applies to balances deposited before the flag day, and a denial leaves the balance in custody. See the controller guard model. - The metered guard gas for both runs is paid by
SOURCEinGASand burned. On BTC the action fails withinsufficient funds (guard gas)whenSOURCEcannot cover the reservation; on other chains no reservation is taken, that verdict never occurs, and the charge is capped atSOURCE’s balance (see Controller-Bound Tokens: Gas). - An unbound token moved by an unbound address runs neither guard and pays no guard gas.
QUANTITYmust be a positive value with valid decimal format for the token
Notes
- Withdrawn tokens are debited from the contract’s derived address and credited to the contract owner’s address in the standard ledger
- The solvency check uses the standard
balancestable viagetAddressBalances()on the derived address - Use
DEPOSITto add tokens to a contract’s derived address - Use
^(caret) as a prefix when passingTICK_IDfor theTICKfield (e.g.^1234=TICK_ID1234) - Contracts may also return tokens to users via emitted SEND actions triggered by
EXECUTE;WITHDRAWis specifically for owner-initiated withdrawals - WITHDRAW does not require the contract to be active; a disabled contract’s owner can still recover tokens this way, but only when the contract is opted in (
meta.ownerWithdraw: true) or was deployed before theOWNER_WITHDRAW_OPT_INactivation. A disabled contract that never opted in has no owner-side recovery path; its tokens leave only through the contract’s own emitted SENDs, if its code still triggers any while disabled.
Copyright © 2025–2026 Dankest, LLC
Based on XChain Platform by Dankest, LLC – https://dankest.llc
Licensed under the GNU Affero General Public License v3.0 (AGPL-3.0-or-later) with a commercial license available for proprietary use.
You may use, modify, and distribute this material under the terms of the License. See LICENSE and NOTICE for full terms. See the licensing overview.