Skip to content

LendingNFT is a smart contract that realizes lending and borrowing of NFT.

License

Notifications You must be signed in to change notification settings

akasata/lending-nft

Repository files navigation

LendingNFT

LendingNFT is a smart contract that realizes lending and borrowing of NFT.

The purpose of this repository is to provide BorrowableNFT that people who do not have NFTs can freely borrow NFTs, and Lendable NFT that can be rented by NFT owners.

Currently only BorrowableNFT is implemented.

Getting started

  • npm i
  • create .env file. See .env.example

Commands

  • npm run

BorrowableNFT

Borrowable NFT provides a mechanism that allows people who do not have NFTs to borrow NFTs freely. Borrowable NFT implements the following two Contracts.

  • BaseNFT
  • BorrowableWrapper

BaseNFT is a regular NFT Contract that inherits from ERC721AQueryable.

BorrowableWrapper has two features. One implements an ERC721 interface and acts as a wrapper for the Base NFT, and the other implements a borrow function for people who don't have an NFT to borrow an NFT.

When the borrower calls the BorrowableWrapper#borrow(uint tokenId) function, the borrower's balance is incremented by 1 and the owner's balance is decremented by 1. After the period specified in the Contract (1 day by default), the NFT is returned to the owner, the borrower's balance is -1 and the owner's balance is +1.

This mechanism allows BorrowableWrapper to be used in content gates to provide an NFT renting experience.

TODO

  • Make BorrowableWrapper dependent on ERC721AQueryable or ERC721Enumerable instead of BaseNFT
  • Implementation of Lendable Wrapper that realizes NFT lending
  • Add deploy and usage documentation

BorrowableNFT Demo

You can actually experience BorrowableNFT with A Wizard of Tono NFT that applies this mechanism.

  1. Access BorrowableWrapper contract page(EtherScan)

  2. Open "Contract" tab

Open "Contract" tab

  1. Select "Write Contract"

Select "Write Contract"

  1. Connect your Wallet

Connect your Wallet

  1. Open "borrow", input tokenId and push "Write"(Gas fees are required at this timing.)

About tokenId: You can specify any tokenId from any NFT sold. You can also search by Twitter's #youcanborrowawizardoftono hashtag.

start transaction

Note: If your gas fees is unusually high or if you point out a possible error, please refer to the Troubleshooting.

Now you can use this NFT for 24 hours! Access token-gated website, you can download the e-book in either EPUB, mobi or PDF.

Troubleshooting

An abnormally high gas fees or an error is predicted

If the NFT cannot be borrowed, the following error/alert may be displayed. (This is a screenshot of Metamask.)

es_005

The following causes are possible.

  • Owner of NFT
    • If the NFT Owner wants to try BorrowableNFT, try it on a wallet that doesn't own an NFT.
  • NFT has already been borrowed
  • NFT not for sale yet

If you want to find a BorrowableNFT tokenId that you can borrow, please search on Twitter #youcanborrowawizardoftono hashtag.

About

This Smart Contract is an OSS version of A Wizard of Tono Book NFT.

About

LendingNFT is a smart contract that realizes lending and borrowing of NFT.

Resources

License

Stars

Watchers

Forks

Packages

No packages published