You will need some ERC-721 in your account to test this.
- yarn should be installed
- npm should be installed
- Node.js >= v14
- Browser with Metamask extension installed
After checking out the main
branch of this project:
yarn install
to install dependenciesyarn compile
to compile smart contractsyarn test
to run unit tests
- Start a new terminal, and run
yarn hardhat node
- We will make use of the generated account's private keys for testing, so please take note of:
- Account 1: Lender of NFT, deployer of contracts
- Account 2: Borrower of NFT
- We will make use of the generated account's private keys for testing, so please take note of:
- A local hardhat node should be running, and you'll see:
Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/
- Leave the terminal running until the end of tests, and use another one for the subsequent steps
yarn hardhat run scripts/testing/deploy_w_testtokens.ts --network localhost
to- deploy test NFT to local hardhat node
- Take note of NFT address printed in console
- mint 3 NFTs to account 1
- Take note that minted NFTs have token-ids
0
,1
, and2
- Take note that minted NFTs have token-ids
- deploy the lender contract.
- Take note of the
Lender
contract
- Take note of the
- deploy test NFT to local hardhat node
- Use the lender contract address from step 7.3.1 and update the following variables in
frontend/src/App.svelte
const lenderAddress = '<>'; // address from step 7.3.1 const contractCreationBlock = 0; // set this to 0
cd frontend
npm install
to install frontend dependenciesnpm run build
to build the frontendnpm run dev
to start the frontend, it should be deployed to http://localhost:5000
0x8C67b4AAF78CF53b624d8bcB63Ca7513A5634203
The application will provide an interface that allows a user (user A) to lend out an NFT to another user (user B) for set period of time (eg. 1 day). The borrower (user B) can freely transfer the temporary ownership (represented by a wrapper NFT). The application will also provide an interface for anyone to check the current owner of a lent NFT. A borrower should be able to return the borrowed NFT by burning the wrapper NFT.
- Enter website
- Login with Metamask
- Enter NFT Token address, token id, and borrower address
- Click 'Lend'
- Use the 'verify ownership' form to check that the contract is returning the borrower's address as the virtual owner.
- Enter website
- Connect with Metamask
- Observe that the borrowed NFT is showing up under 'borrowed' section.
- After the lending duration has expired, enter the website
- Connect with Metamask
- Click on 'Collect' on an NFT under the 'lent' section
- Use the 'verify ownership' to check that you are the new virtual owner. NFT contract should also say that you are the current owner.
- Enter the website
- Connect with Metamask
- Click on 'Return' to burn the wrapped token and return the lent token to the original owner.
frontend
: Project's React frontend.contracts
: Smart contracts that are deployed in the Ropsten testnet.test
: Tests for smart contracts.
This is only required for deployment
- Make a copy of
env.example
and name itenv
. Update it with the below values: - Etherscan_api_key is not required.
- You need an alchemy account or some other ropsten endpoint
- Private key will be the private key of the account that you'll be using for deployment
ETHERSCAN_API_KEY=
ROPSTEN_URL=https://eth-ropsten.alchemyapi.io/v2/<YOUR ALCHEMY KEY>
PRIVATE_KEY=
- UI for returning of NFT
- UI to display status of lent/borrowed NFTs, and to enable filtering
- Use ERC-1155 to track lending instead
- Support for lending out ERC-1155 tokens