EIPs Explained

ERC-5604 · Draft · ERC · 2022-09-05

ERC-5604: NFT Lien

A draft extension to ERC-721 that lets a contract record liens on an NFT, so a lender or other creditor can be registered as having a claim against a specific token.

What problem does it solve?

In traditional finance a lien is a legal claim on a piece of property that secures a debt or obligation: a bank holds a lien on a car until the loan is repaid, or on a house until the mortgage is cleared. Anyone looking at the asset can see that someone else has a claim on it.

NFTs are increasingly used to represent things that can carry such claims, for example a tokenised deed. ERC-721 itself has no way to say "this token is encumbered and this address holds a claim on it". ERC-5604 proposes a minimal, shared interface for placing, removing and checking liens, so lending protocols, marketplaces and wallets could all read the same on-chain signal.

How it works

A compliant contract is a full ERC-721 token that also supports ERC-165 and adds three functions and two events:

Member Purpose
addLienHolder(tokenId, holder, extraParams) Place a lien on a token for holder; must fail if that holder already has one on the token
removeLienHolder(tokenId, holder, extraParams) Remove a holder's lien
hasLien(tokenId, holder, extraParams) Query whether holder has an active lien on the token
OnLienPlaced / OnLienRemoved Events emitted on success, so indexers can track liens

extraParams is an opaque bytes field reserved for future extensions or implementation-specific data.

The spec deliberately leaves several things out:

  • Access control is up to the implementation. Adding and removing are separate functions precisely because they usually need different permissions (for example, the owner may add a lien holder, but only the lien holder should be able to release it).
  • The amount of debt is not recorded.
  • What a lien blocks (for example, whether transfers are allowed while a lien is active) is not specified.

Sample code

An illustrative implementation in which the owner grants a lien and only the lien holder may release it. Transfers are blocked while any lien is active; that rule is an implementation choice, not part of the spec.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

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

contract LienableDeed is ERC721 {
    event OnLienPlaced(uint256 tokenId, address holder, bytes extraParams);
    event OnLienRemoved(uint256 tokenId, address holder, bytes extraParams);

    mapping(uint256 => mapping(address => bool)) private _lien;
    mapping(uint256 => uint256) private _lienCount;

    constructor() ERC721("Deed", "DEED") {}

    function addLienHolder(uint256 tokenId, address holder, bytes calldata extraParams) external {
        require(ownerOf(tokenId) == msg.sender, "not owner");
        require(!_lien[tokenId][holder], "lien exists");
        _lien[tokenId][holder] = true;
        _lienCount[tokenId]++;
        emit OnLienPlaced(tokenId, holder, extraParams);
    }

    function removeLienHolder(uint256 tokenId, address holder, bytes calldata extraParams) external {
        require(msg.sender == holder && _lien[tokenId][holder], "not lien holder");
        _lien[tokenId][holder] = false;
        _lienCount[tokenId]--;
        emit OnLienRemoved(tokenId, holder, extraParams);
    }

    function hasLien(uint256 tokenId, address holder, bytes calldata) external view returns (bool) {
        ownerOf(tokenId); // reverts if the token does not exist
        return _lien[tokenId][holder];
    }

    function _update(address to, uint256 tokenId, address auth) internal override returns (address) {
        address from = _ownerOf(tokenId);
        if (from != address(0)) require(_lienCount[tokenId] == 0, "encumbered");
        return super._update(to, tokenId, auth);
    }
}

Things to know

  • Status: Draft. The interface may still change and the Security Considerations section is marked "needs discussion".
  • An on-chain lien is only a record. Whether it is legally enforceable depends on off-chain agreements and jurisdiction; the standard does not address that.
  • The spec targets ERC-721 only; ERC-20 and ERC-1155 are explicitly out of scope.
  • The reference interface in the spec is written loosely (for example public functions in an interface and calldata in event parameters), so real implementations need to adapt the signatures to compile.

#nft #erc-721 #lien #defi #collateral

Details

Authors
Zainan Victor Zhou (@xinbenlv), Allen Zhou <[email protected]>, Alex Qin <[email protected]>
Status
Draft
Type
Standards Track / ERC
Created
2022-09-05
Requires

Machine-readable: Markdown · JSON