This dApp is a DeFi & Cross-chain Interoperability Hackathon submission and consists of two parts:
- front-end dApp, this repository
- a custom cw721-compatible contract with metadata extension
dNFT is a dApp that give NFT collectors an opportunity to mint derivtive NFT artworks based on the NFTs they already own. The derivative NFTs are procedurally generated based original NFTs and are fully owned by a collector. dNFT is completely decentralized, has no backend and all magic happens right in your browser.
This proof-of-concept dApp supports one generation method - Nerual Style Transfer. However, in the future, dNFT will support several generation methods and would allow adding new as plugins.
The smart contract behind dNFT is based on cw721 standard with metadata extension (see dcw721-contract repository). Any derivative NFT stores links (token_id
) of the original NFTs and generation parameters. This allows to
- traceback any derivative back to the original artwork
- prove the ownership of the original NFTs in time of minting a derivative
- deterministically recreate any derivative artwork from sources
- make derivatives unique: an owner can't mint several derivatives with the same "derivation" method
When dNFT is fully developed into an NFT marketplace, it will allow the creators earn royalties from sale and re-sale of the derivatives based on their original NFTs.
Connect to Terra Extension and wait for your collection to be loaded. Choose a content NFT (left) and apply to it the style of a another NFT (right). Try different parameeters and model settings. The resulting image can be minted as a derivative NFT. Click "Reload NFT Collection" to see your minted derivative.
To build dNFT dApp, install Yarn, go to the repository root and execute:
yarn install
yarn build
To launch dNFT locally, run:
yarn run start
Open the dApp in Google Chrome with Terra Extension installed.
The live demo is available here: https://dare2defy.xyz
A link to vide demo: https://youtu.be/rsoNpKQ0HUo
You can use one of the following ready-made test accounts with original, pre-minted NFTs:
Account | Address | Mnemonic |
---|---|---|
test5 | terra18wlvftxzj6zt0xugy2lr9nxzu402690ltaf4ss |
second render cat sing soup reward cluster island bench diet lumber grocery repeat balcony perfect diesel stumble piano distance caught occur example ozone loyal |
test7 | terra17tv2hvwpg0ukqgd2y5ct2w54fyan7z0zxrm2f9 |
noble width taxi input there patrol clown public spell aunt wish punch moment will misery eight excess arena pen turtle minimum grain vague inmate |
test9 | terra1333veey879eeqcff8j3gfcgwt8cfrg9mq20v6f |
index light average senior silent limit usual local involve delay update rack cause inmate wall render magnet common feature laundry exact casual resource hundred |
test11 | terra1jh0v64kew5agna23gzg6akuyqd46nrsk8kudks |
october next pepper inject angry climb observe enable merry rebuild worry rhythm shallow throw panda cloud capital sunset insane badge maximum shoot destroy flag |
You can use them to test the dApp and derivative minting using a pre-deployed contract terra1zzf3207sepmhs2t8f2j0zwsklgahrtchn5hxth
on Bombay-12 testnet.
Note that only original minter, which is set when contract is created, can mint original NFTs. If you want to mint new original NFTs, you can use minter's account terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp
with mnemonics
quality vacuum heart guard buzz spike sight swarm shove special gym robust assume sudden deposit grid alcohol choice devote leader tilt noodle tide penalty
Alternatively, you can deploy a brand new contract and make the dApp work with your contract by following the instruction below.
Before you start, you will need Chrome with Terra Extention installed.
- Create two Terra accounts: an original minter's account and an ownwer's account. They both will need some LUNA balance to pay for gas fees. For illustration, we are going to use
terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp
as a minter's accountterra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95
as an NFT owner's account
- First, we need to login to Terra Extention and authorize in https://station.terra.money/contracts with the minter's account
- Click "Upload" button, and upload cw721terra.wasm from the contract repository (see
artifacts
directory)
- In the "History" tab, find "Store" transaction for the code upload. You will see code_id 18145 in the transaction title.
- Alternatively, look at the transaction details and locate store code_id:
- Next, create a new contract with Code 18145 and InitMsg json as follows:
{"name":"dnft7", "symbol":"SMB", "minter":"terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp"}
Fields name
and symbol
can be arbitrary, the only important field in minter
. Only this address can mint original NFTs, which could be later used by their owners to produce derivative artwork.
- After creating the contract, go to History tab and find
MsgInstantiateContract
transaction
- In this transaction details, locate
contract_address
field
- Your contract address is
terra1zzf3207sepmhs2t8f2j0zwsklgahrtchn5hxth
. Openindex.html
, findCONTRACT_ADDRESS
in the<head>
section and change it to your contract address:
<script>
const CONTRACT_ADDRESS = "terra1zzf3207sepmhs2t8f2j0zwsklgahrtchn5hxth";
</script>
Currently, dNFT allows to mint only derivative NFTs. Original NFTs should be minted manually. Below are the sample transaction minting several NFTs with terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95
as an owner.
-
{"mint":{"token_id":"vitalik_nakamoto", "owner":"terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95", "extension": {"external_url": "https://ipfs.infura.io/ipfs/Qmf1FKrkPeipuhMdw8LUCXcwgd2QibB9vUmyJsaZXPkBeD"}}}
-
{"mint":{"token_id":"becca_notices", "owner":"terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95", "extension": {"external_url": "https://ipfs.infura.io/ipfs/QmYvKtfCLZaNbM9D1f2TsCPSaaDYNu6dB6f8M5gcVCu7uU"}}}
-
{"mint":{"token_id":"bored_ape", "owner":"terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95", "extension": {"external_url": "https://ipfs.infura.io/ipfs/QmUZw1yGJexUyvsCeX6QPYsFJJfShCsqvkvEhdDHJuzMWZ"}}}
-
{"mint":{"token_id":"towers", "owner":"terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95", "extension": {"external_url": "https://ipfs.infura.io/ipfs/QmYgfE5seqrh2khVH8WTdLTLMySA4Wzse18ghQ5i5Kdh5C"}}}
-
{"mint":{"token_id":"trees", "owner":"terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95", "extension": {"external_url": "https://ipfs.infura.io/ipfs/QmeXTrnoVsPdqiUpzkcrmZRWC8jC6e4FK23HYFhc1sDDGw"}}}
-
{"mint":{"token_id":"lizard", "owner":"terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95", "extension": {"external_url": "https://ipfs.infura.io/ipfs/QmQP321saFCEJPMA86sY2pCkUNFn1NQ9woLuLtYHmn5nz5"}}}
-
{"mint":{"token_id":"tyler", "owner":"terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95", "extension": {"external_url": "https://ipfs.infura.io/ipfs/QmQVDGwSvigtCZwG8N3j7a1b6LWsgudwgcsTjakncmrXte"}}}
-
{"mint":{"token_id":"f1", "owner":"terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95", "extension": {"external_url": "https://ipfs.infura.io/ipfs/QmerJuL4RPs9s6huJyGQT3sPp32RonHg6vnRgxVe5YpNGZ"}}}
-
{"mint":{"token_id":"78022", "owner":"terra1757tkx08n0cqrw7p86ny9lnxsqeth0wgp0em95", "extension": {"external_url": "https://ipfs.infura.io/ipfs/QmeeeLBTgMKSGybSMj44SoWR5XseiJHB8ratq25qggUaGs"}}}
Note: If you mint new NFTs, make sure that they have unique token_id
values.