---
eip: 5058
label: ERC-5058
title: Lockable Non-Fungible Tokens
status: Stagnant
type: Standards Track
category: ERC
created: 2022-04-30
requires: 20, 165, 721
official: https://eips.ethereum.org/EIPS/eip-5058
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5058.md
canonical: https://eips.huatuo.xyz/eip-5058/
lang: en
tldr: "An ERC-721 extension that lets an approved operator lock an NFT in its owner's wallet until a block number, so staking or lending no longer requires handing the NFT over."
tags: [nft, erc-721, locking, staking, nftfi]
---

# ERC-5058: Lockable Non-Fungible Tokens

> Lockable EIP-721 tokens

**TL;DR:** An ERC-721 extension that lets an approved operator lock an NFT in its owner's wallet until a block number, so staking or lending no longer requires handing the NFT over.

## What problem does it solve?

NFT staking, lending and similar "NFTFi" products usually require you to transfer the NFT into the protocol's contract. That exposes it to the contract's bugs, removes it from your wallet (so it no longer shows as your profile picture or proves membership), and means airdrops sent to holders go to the protocol instead of you.

ERC-5058 adds a native lock to ERC-721: the NFT stays in the owner's wallet, but cannot be transferred until the lock expires or the locker releases it.

## How it works

The pattern mirrors ERC-721's own approvals, but for locking instead of transferring:

| Function | Purpose |
| --- | --- |
| `lockApprove(to, tokenId)` | Allow one address to lock one token |
| `setLockApprovalForAll(operator, approved)` | Allow an operator to lock any of your tokens in this collection |
| `lock(tokenId, expired)` | Lock until block number `expired` (must be in the future) |
| `unlock(tokenId)` | Early release; only the address that locked it may call |
| `isLocked`, `lockerOf`, `lockExpiredTime` | Read lock state |
| `getLockApproved`, `isLockApprovedForAll` | Read lock approvals |

Events `Locked`, `Unlocked`, `LockApproval` and `LockApprovalForAll` let indexers and marketplaces track status. Transfers of a locked token must fail; once the current block passes `expired`, the token is automatically transferable again. All other properties (ownership, metadata, airdrop eligibility) are unaffected.

The rationale also sketches an optional **bound NFT**: a transferable mirror token minted while the original is locked and destroyed on unlock, which could be lent or used as a staking receipt, created via a CREATE2 factory.

## Sample code

A staking contract using the lock instead of custody:

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

interface IERC5058 {
    function lock(uint256 tokenId, uint256 expired) external;
    function unlock(uint256 tokenId) external;
    function isLocked(uint256 tokenId) external view returns (bool);
}

interface IERC721Owner {
    function ownerOf(uint256 tokenId) external view returns (address);
}

contract NonCustodialStaking {
    address public immutable nft;
    mapping(uint256 => address) public stakerOf;

    constructor(address nft_) { nft = nft_; }

    /// Owner must first call nft.setLockApprovalForAll(address(this), true).
    function stake(uint256 tokenId, uint256 blocks) external {
        require(IERC721Owner(nft).ownerOf(tokenId) == msg.sender, "not owner");
        IERC5058(nft).lock(tokenId, block.number + blocks);
        stakerOf[tokenId] = msg.sender;
    }

    function unstakeEarly(uint256 tokenId) external {
        require(stakerOf[tokenId] == msg.sender, "not staker");
        delete stakerOf[tokenId];
        IERC5058(nft).unlock(tokenId); // only the locker may unlock
    }
}
```

## Things to know

- Status: **Stagnant**. Locking must be built into the NFT contract itself, so it only helps collections deployed with it.
- Lock expiry is measured in **block numbers**, not timestamps.
- A malicious or buggy locker can freeze your NFT until expiry; grant lock approval as carefully as a transfer approval.
- Related approaches: [ERC-5192](/eip-5192/) (minimal permanent "soulbound" lock signal), [ERC-5753](/eip-5753/) (another lockable extension, also Stagnant), [ERC-6982](/eip-6982/) (lock-status events) and [ERC-4907](/eip-4907/) (rental via a separate user role).


---

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