<!-- markdownlint-disable MD036 -->

# Example: Blacklist Pattern

**Blacklist** (blocklist) = explicitly **blocked** addresses cannot send or receive. CX3Script has no single `@blacklist` decorator in core examples; the usual pattern is a **`mapping blocked: address => bool`** (or `denied`) plus owner-governed setters and `require !blocked[...]` on `transfer`.

Below is a **minimal CX30 token** (CX3JS) that compiles and shows the pattern&nbsp;end-to-end.

## `BlacklistDemo.cxs`

```cxs
@CX30
@target(CX3JS)
@mintable
token BlacklistDemo {
    name = "BL Demo"
    symbol = "BLD"
    totalSupply = 0
    owner = sender
    mapping balances: address => uint256
    mapping blocked: address => bool
    event Transfer(from: address, to: address, amount: uint256)
    event BlocklistUpdated(addr: address, value: bool)

    @onlyOwner
    mint(to: address, amount: uint256) {
        require amount > 0, "amt"
        totalSupply = totalSupply + amount
        balances[to] = balances[to] + amount
    }

    transfer(to: address, amount: uint256) {
        require !blocked[sender], "sender_blocked"
        require !blocked[to], "recipient_blocked"
        require balances[sender] >= amount, "bal"
        balances[sender] = balances[sender] - amount
        balances[to] = balances[to] + amount
        emit Transfer(sender, to, amount)
    }

    @onlyOwner
    setBlocked(addr: address, v: bool) {
        blocked[addr] = v
        emit BlocklistUpdated(addr, v)
    }

    @view
    isBlocked(a: address) -> bool {
        return blocked[a]
    }
}
```

## Notes

- Production policies often combine **KYC** (**Examples #4**), **whitelist** (**#5**), **blacklist** (**#6**), and policy / audit decorators (`@auditable`, freezes, etc.); keep rules in one place and record every state change.
- **Example: Whitelist (CX300 RWA)** - complementary allow-list style on an `asset` contract (**#5**).
- This is a **hand-written pattern demo**, not a built-in decorator or standard method name. The wizard's **CX30 Enterprise** template has blacklist controls (`addToBlacklist` / `removeFromBlacklist` / `isBlacklisted`, `@onlyAdmin`, events **`Blacklisted`** / **`Unblacklisted`**; see **Example: CX30 (Wizard Template)**), and **CX31** / **CX300** carry the same owner-managed blacklist. Method names differ from the sample's `setBlocked` / `isBlocked` / `BlocklistUpdated` above.

## Next

**Example: Soulbound (CX3192)**
