---
eip: 6682
label: ERC-6682
title: NFT Flashloans
status: Draft
type: Standards Track
category: ERC
created: 2023-03-12
requires: 20, 721, 3156
official: https://eips.ethereum.org/EIPS/eip-6682
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-6682.md
canonical: https://eips.huatuo.xyz/eip-6682/
lang: en
tldr: "A draft extension of the ERC-3156 flash-loan standard for NFTs: borrow a specific ERC-721 token, use it inside one transaction, return it and pay a fee in a separate token or ETH."
tags: [nft, flashloan, defi, erc-721, erc-3156]
---

# ERC-6682: NFT Flashloans

> Minimal interface for ERC-721 NFT flashloans

**TL;DR:** A draft extension of the ERC-3156 flash-loan standard for NFTs: borrow a specific ERC-721 token, use it inside one transaction, return it and pay a fee in a separate token or ETH.

## What problem does it solve?

A flash loan lends an asset with no collateral, on the condition that it comes back before the transaction ends; if not, everything reverts. [ERC-3156](/eip-3156/) standardized this for fungible [ERC-20](/eip-20/) tokens only.

Many actions only check that you **own** an NFT at the moment of the call: claiming an airdrop, collecting staking rewards, or an in-game action such as harvesting resources. ERC-6682 defines how a lender can flash-lend a particular [ERC-721](/eip-721/) token so a contract can do such an action and give the NFT back in the same transaction.

## How it works

Lenders implement the normal `IERC3156FlashLender` functions plus two new ones:

```solidity
interface IERC6682 {
    function flashFeeToken() external view returns (address);                 // address(0) = ETH
    function availableForFlashLoan(address token, uint256 tokenId) external view returns (bool);
}
```

- `flashFeeToken()` says which token the fee is paid in. NFTs are not divisible, so the fee is charged in another currency.
- `availableForFlashLoan(token, tokenId)` must return `false`, not revert, when that NFT cannot be borrowed.
- The ERC-3156 `amount` arguments carry the **token id** instead: `flashFee(token, tokenId)` and `flashLoan(receiver, token, tokenId, data)`.
- `maxFlashLoan(token)` makes little sense for NFTs; the spec recommends returning `1`, meaning one NFT per call.

Flow: the lender transfers the NFT to the borrower contract, calls its `onFlashLoan(initiator, token, tokenId, fee, data)` (which must return `keccak256("ERC3156FlashBorrower.onFlashLoan")`), checks that it owns the NFT again, then collects the fee.

## Sample code

A borrower that claims something with the NFT and returns it. It assumes the fee is paid in an ERC-20 that the lender pulls from the initiator, as in the spec's reference lender:

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

interface IERC721 { function safeTransferFrom(address from, address to, uint256 id) external; }
interface IClaim { function claim(uint256 tokenId) external; }

contract NftBorrower {
    address public immutable lender;
    IClaim public immutable target;

    constructor(address lender_, IClaim target_) { lender = lender_; target = target_; }

    function onFlashLoan(address, address token, uint256 tokenId, uint256, bytes calldata)
        external returns (bytes32)
    {
        require(msg.sender == lender, "untrusted lender");
        target.claim(tokenId);                                       // action that checks ownership
        IERC721(token).safeTransferFrom(address(this), lender, tokenId); // give it back
        return keccak256("ERC3156FlashBorrower.onFlashLoan");
    }

    function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) {
        return this.onERC721Received.selector;
    }
}
```

## Things to know

- **Status: Draft.** The interface may still change; Security Considerations is marked "Needs discussion".
- `flashFeeToken()` could point to a malicious contract. Borrowers should check it against an expected address before interacting with it.
- Projects that hand out rewards based on a single ownership check are exposed to NFT flash loans. If that matters, use snapshots or minimum holding periods instead of `ownerOf` at call time.
- The borrower must be able to receive ERC-721 via `safeTransferFrom` (implement `onERC721Received`).


---

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