It seems extremely likely that NFTs (non-fungible tokens) will become ubiquitous in many aspects of our digital (and physical) world in the mid to long-term future. As NFTs become more widely adopted, multiple parties may wish to share ownership of a single NFT. Dividing the ownership of NFTs is possible on smart programming platforms by locking the NFT in a contract in return for a specified quantity of tokens that each represent partial ownership of the locked NFT. These tokens may then be distributed to multiple accounts. This process is known as "fractionalization" of an NFT. The aim of this project is to implement a simple EVM-based dapp (decentralized application) that allows a user to fractionalize their ERC721 NFTs into ERC20 tokens. The most popular example of a dapp that implements this functionality is fractional.art.
Actions:
As a side effect, the above functionality also allows the dapp to act as a simple marketplace (or escrow) for accounts to sell NFTs in exchange for ether.
(also checked in at ./FractionalizeNFTScreencast.mp4.
.github/workflows
: For github actions (currently the contracts are compiled and unit-tested automatically).client
: Frontend for the FractionalizeNFT contract.docs
: Additional documentation.contracts
: FractionalizeNFT and helper smart contracts.tests
: Python unit tests (executed via brownie).python3 -m venv venv # Create a local virtual environment to install packages in.
source venv/bin/activate # Bash, activate scripts for shells available in same folder.
pip install --upgrade pip
pip install -r requirements.txt
The contracts are compiled and tested upon push in Github CI, the results can be seen under Github Actions.
To run the tests locally run brownie test
(this will start ganache-cli for you):
source venv/bin/activate # If virtual environment not already activated
brownie test
Or, with gas profiling and coverage enabled (slower):
brownie test --gas --coverage
The scripts/deploy.py
script can be used to deploy the contracts locally and populate the FractionalizeNFT contract with some NFTs
ready for manual testing:
source venv/bin/activate # If virtual environment not already activated
brownie console
nft_contract, frac_contract = run("deploy", "main_dev")
A mnemonic may be added to .env
in the form
MNEMONIC=YOUR MNEMONIC ... PHRASE HERE
This mnemonic value will be used in the brownie config and applied when starting ganache-cli.
Note: See "Deploying for Manual Testing" for how to deploy the contract and populate it with fractionalized NFTs ready for use with the frontend.
cd client
yarn install
yarn start
Deploy to Ropsten (and verify source code via Etherscan):
brownie run deploy.py --network ropsten
Source code verification additionally requires:
.env
entry in the form:
ETHERSCAN_TOKEN=<TOKEN>
0x7b13c2F7AaA8C772Bd0a13A86B0CF633fAf790B0
(danceratopz.eth)
Solidity:
fracNFTs
if it is no longer in use, i.e., when:
Frontend: