---
eip: 7721
label: ERC-7721
title: Lockable Extension for ERC-1155
status: Draft
type: Standards Track
category: ERC
created: 2023-05-25
requires: 165, 1155
official: https://eips.ethereum.org/EIPS/eip-7721
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7721.md
canonical: https://eips.huatuo.xyz/eip-7721/
lang: en
tldr: An ERC-1155 extension that lets holders lock token amounts in their own wallet under a designated locker, enabling loans and rentals without escrow.
tags: [erc-1155, nft, lock, nftfi, token]
---

# ERC-7721: Lockable Extension for ERC-1155

> Interface for enabling locking of ERC-1155 using locker and token id based approvals

**TL;DR:** An ERC-1155 extension that lets holders lock token amounts in their own wallet under a designated locker, enabling loans and rentals without escrow.

## What problem does it solve?

To use an NFT as loan collateral or rent it out today, you usually transfer it into the protocol's escrow contract. While it sits there you lose its utility (game access, Discord roles, etc.), you can't combine it with other financial tools, and you are exposed to bugs in that escrow contract.

ERC-7721 adds a native lock to [ERC-1155](/eip-1155/) tokens. The token stays in the owner's wallet, but a chosen *locker* address controls when a given amount can move again. The same idea for ERC-721 is [ERC-7066](/eip-7066/).

## How it works

Locking is per `tokenId`, per `account`, per `locker`, and per **amount** (ERC-1155 balances are quantities):

- `lock(tokenId, account, locker, amount)`: the owner locks `amount` and names a separate `locker`.
- `lock(tokenId, account, amount)`: the owner or an approved operator locks `amount`, and the caller becomes the locker.
- `unlock(tokenId, account, amount)`: only the locker can release it.
- `setApprovalForId(tokenId, operator, amount)`: a finer-grained approval than ERC-1155's all-or-nothing `setApprovalForAll`.
- `transferAndLock(from, to, tokenId, amount, setApprove)`: transfer to a recipient and lock it there in one step, optionally giving the caller approval so it can take the tokens back later (useful for rentals or buy-now-pay-later).
- `getLocked(tokenId, account, operator)` returns how much is locked.

`safeTransferFrom` must revert if it would move locked units: the maximum transferable amount is `balance - locked`. `Lock` and `Unlock` events let indexers track state.

## Sample code

Interface and a helper that enforces the transfer rule:

```solidity
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

interface IERC7721 is IERC1155 {
    event Lock(uint256 indexed tokenId, address account, address _locker, uint256 amount);
    event Unlock(uint256 indexed tokenId, address account, address _locker, uint256 amount);

    function lock(uint256 tokenId, address account, uint256 amount) external;
    function lock(uint256 tokenId, address account, address _locker, uint256 amount) external;
    function unlock(uint256 tokenId, address account, uint256 amount) external;
    function transferAndLock(address from, address to, uint256 tokenId, uint256 amount, bool setApprove) external;
    function getLocked(uint256 tokenId, address account, address operator) external view returns (uint256);
    function setApprovalForId(uint256 tokenId, address operator, uint256 amount) external;
}

// Inside an implementation's transfer hook:
// uint256 free = balanceOf(from, id) - totalLocked[id][from];
// require(amount <= free, "ERC7721: amount locked");
```

Checking locked amount from TypeScript (ethers v6):

```ts
const lockable = new Contract(tokenAddr, [
  "function getLocked(uint256,address,address) view returns (uint256)",
], provider);
const locked = await lockable.getLocked(tokenId, holder, lenderContract);
```

## Things to know

- **Status: Draft.** Function signatures may still change.
- The interface comment on `getLocked` mentions returning a wallet, while the spec text says it returns an amount; implementations follow the amount interpretation.
- If the locker is an inaccessible address or a contract without an unlock path, the tokens can be locked forever. Review the locker before locking.
- Marketplaces should check locked amounts before listing, since a transfer of locked units will revert.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-7721
