Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porting Clawback documentation to xrpl.org #2111

Merged
merged 9 commits into from
Sep 11, 2023
1 change: 1 addition & 0 deletions content/_snippets/clawback-disclaimer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_Clawback functionality is part of the proposed [XLS-39d-clawback](https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-39d-clawback) extension :not_enabled: to the XRP Ledger protocol. You can use the clawback feature on test networks, but there isn't an official amendment and they aren't available on the production Mainnet. Until there is an amendment, the details documented on these pages are subject to change._ <!-- SPELLING_IGNORE: 39d -->
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved
41 changes: 41 additions & 0 deletions content/concepts/tokens/clawing-back-tokens.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
html: clawing-back-tokens.html
parent: tokens.html
blurb: Issuers can claw back their tokens for compliance purposes if they enable the Clawback feature before issuing tokens.
labels:
- Tokens
status: not_enabled
---
# Clawing Back Tokens
{% include '_snippets/_clawback-disclaimer.md' %}
For regulatory purposes, some issuers need the ability to recover tokens after they are distributed to accounts. For example, if an issuer were to discover that tokens were sent to an account sanctioned for illegal activity, the issuer could recover, or *claw back*, the funds.

Issuers can gain the ability to claw back their tokens by enabling the **Allow Clawback** flag on their issuing account. This flag cannot be enabled if the issuer has already issued tokens.

**Note:** You can only claw back issued tokens created by your account. You cannot claw back XRP in this way.

Clawback is disabled by default. To use clawback, you must send an [AccountSet transaction][] to enable the **Allow Clawback** setting. **An issuer with any existing tokens cannot enable Clawback.** You can only enable Allow Clawback if you have a completely empty owner directory, meaning you must do so before you set up any trust lines, offers, escrows, payment channels, checks, or even signer lists.

If you attempt to set `lsfAllowTrustLineClawback` while `lsfNoFreeze` is set, the transaction returns `tecNO_PERMISSION`, because clawback cannot be enabled on an account that has already disclaimed the ability to freeze trust lines.
Conversely, if you try to set `lsfNoFreeze` while `lsfAllowTrustLineClawback` is set, the transaction also returns `tecNO_PERMISSION`.

## Example Clawback Transaction

```json
{
"TransactionType": "Clawback",
"Account": "rp6abvbTbjoce8ZDJkT6snvxTZSYMBCC9S",
"Amount": {
"currency": "FOO",
"issuer": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
"value": "314.159"
}
}
```

If successful, this transaction would claw back at most 314.159 FOO issued by rp6abvbTbjoce8ZDJkT6snvxTZSYMBCC9S and held by rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW.

<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ The available AccountSet flags are:
| Flag Name | Decimal Value | Corresponding Ledger Flag | Description |
|:----------------------------------|:--------------|:----------------------------------|:--------------|
| `asfAccountTxnID` | 5 | (None) | Track the ID of this account's most recent transaction. Required for [`AccountTxnID`](transaction-common-fields.html#accounttxnid) |
| `asfAllowClawback` | 16 | `lsfAllowTrustlineClawback` | Allow account to claw back tokens it has issued. |
| `asfAuthorizedNFTokenMinter` | 10 | (None) | Enable to allow another account to mint non-fungible tokens (NFTokens) on this account's behalf. Specify the authorized account in the `NFTokenMinter` field of the [AccountRoot](accountroot.html) object. To remove an authorized minter, enable this flag and omit the `NFTokenMinter` field. _(Added by the [NonFungibleTokensV1_1 amendment][].)_ |
| `asfDefaultRipple` | 8 | `lsfDefaultRipple` | Enable [rippling](rippling.html) on this account's trust lines by default. |
| `asfDepositAuth` | 9 | `lsfDepositAuth` | Enable [Deposit Authorization](depositauth.html) on this account. _(Added by the [DepositAuth amendment][].)_ |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
html: clawback.html
parent: transaction-types.html
blurb: Claw back tokens you've issued.
labels:
- Tokens
status: not_enabled
---
# Clawback

[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/app/tx/impl/Clawback.cpp "Source")

<embed src="/snippets/_clawback-disclaimer.md" />
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved

Claw back tokens issued by your account. This only works if you have enabled the **Allow Clawback** flag before issuing the tokens.

## Example Clawback JSON

```json
{
"TransactionType": "Clawback",
"Account": "rp6abvbTbjoce8ZDJkT6snvxTZSYMBCC9S",
"Amount": {
"currency": "FOO",
"issuer": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
"value": "314.159"
}
}
```

[Clawback example transaction. >](websocket-api-tool.html?server=wss%3A%2F%2Fs.devnet.rippletest.net%2F&tx=%7B%22id%22%3A%22example_Clawback%22%2C%22command%22%3A%22Clawback%22%2C%22Account%22%3A%22rp6abvbTbjoce8ZDJkT6snvxTZSYMBCC9S%22%2C%22Amount%22%3A%7B%22currency%22%3A%22FOO%22%2C%22issuer%22%3A%22rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW%22%2C%22value%22%3A%22314.159%22%7D%7D)
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved

## Clawback Fields

In addition to the common fields, `Clawback` transactions use the following fields:
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved


| Field | JSON Type | [Internal Type][] | Description |
|:-------------------|:----------|:------------------|:------------------|
| `TransactionType` | string | `UINT16` | Indicates the new transaction type `Clawback`. The integer value is `30`. The name is `ttCLAWBACK`. |
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved
| `Account` | string | `ACCOUNT ID` | The account executing this transaction. The account must be the issuer of the asset being clawed back. Note that in the XRP Ledger, trust lines are bidirectional and, under some configurations, both sides can be seen as the "issuer" of an asset. In this specification, the term *issuer* is used to mean the side of the trust line that has an outstanding balance (that is, 'owes' the issued asset) that it wants to claw back.|
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved
| `Flags` | number | `UINT32` | (Optional) The universal transaction flags that are applicable to all transactions (for example, `tfFullyCanonicalSig`) are valid. This proposal introduces no new transaction-specific flags. |
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved
| `Amount` | object | `AMOUNT` | Indicates the amount being clawed back, as well as the counterparty from which the amount is being clawed back. |
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved

It is not an error if the amount exceeds the holder's balance; in that case, the maximum available balance is clawed back. It returns `temBAD_AMOUNT` if the amount is zero.
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved

It is an error if the counterparty listed in `Amount` is the same as the `Account` issuing this transaction; the transaction fails execution with `temBAD_AMOUNT`.
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved

If there doesn't exist a trust line with the counterparty or that trust line's balance is 0, the error `tecNO_LINE` is returned.
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved

The sub-field `issuer` within `Amount` represents the token holder's account ID rather than the issuer's.
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved

## lsfAllowTrustLineClawback
DennisDawson marked this conversation as resolved.
Show resolved Hide resolved

Clawback is disabled by default. To use clawback, you must set the `lsfAllowTrustLineClawback` flag through an `AccountSet` transaction. The `AccountSet` transaction only succeeds if the account has an empty owner directory, meaning that the account has no trust lines, offers, escrows, payment channels, or checks. After you set this flag, it cannot reverted. The account permanently gains the ability to claw back issued assets on trust lines.

If you attempt to set `lsfAllowTrustLineClawback` while `lsfNoFreeze` is set, the transaction returns `tecNO_PERMISSION`, because clawback cannot be enabled on an account that has already disclaimed the ability to freeze trustlines.
Conversely, if you try to set `lsfNoFreeze` while `lsfAllowTrustLineClawback` is set, the transaction also returns `tecNO_PERMISSION`.


<!-- {# common link defs #} -->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}
12 changes: 12 additions & 0 deletions dactyl-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,12 @@ pages:
targets:
- ja

# TODO - Translate
- md: concepts/tokens/clawback-of-issued-currency.md
targets:
- en
- ja

- md: concepts/tokens/freezes.md
targets:
- en
Expand Down Expand Up @@ -2287,6 +2293,12 @@ pages:
targets:
- ja

# TODO: Translate
- md: references/protocol-reference/transactions/transaction-types/clawback.md
targets:
- en
- ja

- md: references/protocol-reference/ledger-data/ledger-object-types/depositpreauth.md
targets:
- en
Expand Down