- Part 1: sending account creates a payment, or ClaimableBalanceEntry, using the Create Claimable Balance operation
- Part 2: destination account(s), or claimant(s), accepts the ClaimableBalanceEntry using the Claim Claimable Balance operation
op_no_trust error.
It is important to note that if a claimable balance isn’t claimed, it sits on the ledger forever, taking up space and ultimately making the network less efficient. For this reason, it is a good idea to put one of your own accounts as a claimant for a claimable balance. Then you can accept your own claimable balance if needed, freeing up space on the network.
Each ClaimableBalanceEntry is a ledger entry, and each claimant in that entry increases the source account’s minimum balance by one base reserve.
Once a ClaimableBalanceEntry has been claimed, it is deleted.
Operations
Create Claimable Balance
For basic parameters, see the Create Claimable Balance entry in our List of Operations section.Additional parameters
Claim_Predicate_ Claimant — an object that holds both the destination account that can claim the ClaimableBalanceEntry and a ClaimPredicate that must evaluate to true for the claim to succeed.
A ClaimPredicate is a recursive data structure that can be used to construct complex conditionals using different ClaimPredicateTypes. Below are some examples with the Claim_Predicate_ prefix removed for readability. Note that the SDKs expect the Unix timestamps to be expressed in seconds.
- Can claim at any time -
UNCONDITIONAL - Can claim if the close time of the ledger, including the claim is before X seconds + the ledger close time in which the ClaimableBalanceEntry was created -
BEFORE_RELATIVE_TIME(X) - Can claim if the close time of the ledger including the claim is before X (Unix timestamp) -
BEFORE_ABSOLUTE_TIME(X) - Can claim if the close time of the ledger, including the claim is at or after X seconds + the ledger close time in which the ClaimableBalanceEntry was created -
NOT(BEFORE_RELATIVE_TIME(X)) - Can claim if the close time of the ledger, including the claim is at or after X (Unix timestamp) -
NOT(BEFORE_ABSOLUTE_TIME(X)) - Can claim between X and Y Unix timestamps (given X < Y) -
AND(NOT(BEFORE_ABSOLUTE_TIME(X)),BEFORE_ABSOLUTE_TIME(Y)) - Can claim outside X and Y Unix timestamps (given X < Y) -
OR(BEFORE_ABSOLUTE_TIME(X),NOT(BEFORE_ABSOLUTE_TIME(Y))
ClaimableBalanceID ClaimableBalanceID is a union with one possible type (CLAIMABLE_BALANCE_ID_TYPE_V0). It contains an SHA-256 hash of the OperationID for Claimable Balances.
A successful Create Claimable Balance operation will return a Balance ID, which is required when claiming the ClaimableBalanceEntry with the Claim Claimable Balance operation.
Claim Claimable Balance
For basic parameters, see the Claim Claimable Balance entry in our List of Operations section. This operation will load the ClaimableBalanceEntry that corresponds to the Balance ID and then search for the source account of this operation in the list of claimants on the entry. If a match on the claimant is found, and the ClaimPredicate evaluates to true, then the ClaimableBalanceEntry can be claimed. The balance on the entry will be moved to the source account if there are no limit or trustline issues (for non-native assets), meaning the claimant must establish a trustline to the asset before claiming it.Clawback Claimable Balance
This operation claws back a claimable balance, returning the asset to the issuer account, burning it. You must claw back the entire claimable balance, not just part of it. Once a claimable balance has been claimed, use the regular clawback operation to claw it back. Clawback claimable balances require the claimable balance ID. Learn more about clawbacks in our Clawback Guide.Example
The below code demonstrates via both the JavaScript and Go SDKs how an account (Account A) creates a ClaimableBalanceEntry with two claimants: Account A (itself) and Account B (another recipient). Each of these accounts can only claim the balance under unique conditions. Account B has a full minute to claim the balance before Account A can reclaim the balance back for itself. Note: there is no recovery mechanism for a claimable balance in general — if none of the predicates can be fulfilled, the balance cannot be recovered. The reclaim example below acts as a safety net for this situation.Click here to see helper functions
Click here to see helper functions
ClaimableBalanceEntry exists in the ledger, but we’ll need its Balance ID to claim it. You can call the RPC’s getLedgerEntries endpoint to do this.