DeFiDataMarket is a decentralized data marketplace built on the Ethereum blockchain. It enables secure and efficient data exchange between data providers and consumers, while facilitating data tokenization, access control, and revenue sharing.
- Data tokenization using non-fungible token (NFT) standards
- Data access control with fine-grained permissioning
- Data subscription model for recurrent revenue streams
- Secure and decentralized data storage using IPFS
- Data pricing and payments using ETH
- Data marketplace for data discovery and trade
- DecentralizedDataMarket.sol
We'll utilize these OpenZeppelin libraries:
ERC721
: For creating non-fungible tokens (NFTs) representing data ownership so we can keep our data asset tight to an specific owner.ERC721URIStorage
: To be able to edit the token URIAccessControl
: For managing roles and access permissions.Ownable
: To implement ownable pattern.
- Node.js
- Truffle
- Ganache (Optionally)
- Clone the repository
- Install required packages
- Compile and deploy contracts
- Interact with contracts using a web3 or ethers library
- Open a terminal and run
npx hardhat node
to run a local hardhat node - Open a new terminal and run
npx hardhat run --network localhost scripts/deploy.js
to deploy the contract in the local network
- Open a new terminal and run
npx hardhat run --network sepolia scripts/deploy.js
to deploy the contract in sepolia testnet Note: There is a contract already deployed in sepolia network at address:0xD5a640fAC82FD990D8594b4618baE3ED56ADE066
Data providers can create NFTs representing their data assets. Each NFT is associated with a unique data hash and stored on IPFS.
- Tokenize data assets: it will be done with ERC721 Open Zeppelin library
- Decentralized storage:
- IPFS Integration: Instead of hardcoding data within the smart contract, we utilize an IPFS library to interact with the InterPlanetary File System. This library allows storing data off-chain in a decentralized and tamper-proof manner.
- Data Hashing: Before storing data on IPFS, it's hashed using a cryptographic function like SHA-256. This creates a unique identifier for the data regardless of its content.
- Enable users to mint tokens representing ownership or access rights to their data assets:
- We’ll provide a function to mint data assets called
mintDataToken
- Mint Function:
- Receives the IPFS hash (the client who is requesting this method already stored the file there).
- Also the client provides a type of access level for specific asset.
- Mints an ERC721 token representing ownership of the data.
- Associates the token with the IPFS hash of the data using
setTokenURI
.
- Mint Function:
- Considerations: we assume we are testing with small media or text files on IPFS for this MVP.
- Observations: for future implementations we can consider use some optimization strategies such as:
- IPFS chunking: Break down large files into smaller chunks stored and referenced separately on IPFS.
- Off-chain storage: Consider leveraging off-chain storage solutions like Arweave for large media while maintaining on-chain control and references.
- Gas optimization: Choose efficient IPFS libraries and carefully evaluate function gas costs.
- We’ll provide a function to mint data assets called
Data providers can define access rules for their NFTs, specifying who can access the data and under what conditions.
Data consumers can purchase subscriptions to access data for a specific period of time.
A marketplace allows data providers to list their NFTs for sale and data consumers to discover and purchase them.
Data providers can earn revenue by selling their data or by setting up subscription plans.
Here are some notes showing how I would improve the code given more time.
- Provide the ability to modify platform fees, minting fees and subscription fees. Now they are hardcoded and unable to change.
- Provide a DataCategory admin manager so Administrators can add/remove category types as they want.
- Add a Subscription.sol contract to treat this logic separately. Now is in the main contract.
- Provide different types of subscription models. The current logic charges an specific amount for 1 month of subscription