@masa-finance/masa-contracts-marketplace
v2.1.26
Published
## π Introduction
Downloads
399
Keywords
Readme
π Masa Data Marketplace: DataPoints.sol, DataPointsMulti.sol, DataStaking.sol Overview
π Introduction
The Masa Data Marketplace is a decentralized data marketplace where users can share their data and earn rewards π. Utilizing DataPointsMulti.sol
and DataStaking.sol
, the platform represents users' data interactions within the Masa Network as Soulbound tokens π€. These tokens, known as DataPoints, can be "staked" into Data Pools using DataStaking.sol
, allowing users to contribute their data to the network and receive rewards in return π°. This system enables users to realize value from their Masa data footprint in a secure and transparent manner π.
π DataPoints (DataPoints.sol
)
DataPoints.sol
is an ERC20-based smart contract designed to represent accumulated data points as Soulbound tokens π«π. This contract includes functionalities for minting and burning tokens, with distinct roles for each action and an admin role for role management. The non-transferability of these tokens ensures they serve purely as a representation of earned points rather than tradable assets π‘οΈ.
Key Features:
- Minting and Burning: Only addresses with the appropriate roles can mint or burn tokens, ensuring controlled distribution and redemption of DataPoints π.
- Role-Based Access Control: Utilizes OpenZeppelin's AccessControl to manage roles and permissions within the contract π.
- Soulbound: Overrides ERC20's transfer and transferFrom functions to prevent token transfers, ensuring DataPoints remain tied to the original recipient π«.
π DataPointsMulti (DataPointsMulti.sol
)
DataPointsMulti.sol
extends the ERC1155 standard to create a Soulbound multi-token contract, where each token ID represents a different data interaction type within the Masa Network π¨. Similar to DataPoints.sol
, it features minting and burning capabilities, role-based access control, and non-transferability of tokens.
Key Features:
- Multiple Data Types: Supports various data interaction types, such as 'pageView', 'login', 'mint', etc., each represented by a unique token ID π.
- Dynamic URI Mechanism: Implements the ERC1155 URI mechanism to provide on-chain metadata for each token type, facilitating dynamic metadata updates π.
- Soulbound: Ensures tokens cannot be transferred between addresses once minted, focusing on the representation of data points π«.
Example Metadata
For a 'pageView' data type, the metadata might look like this:
{
"name": "pageView",
"merkle_root": "4e07408562bedb8b60ce05c1decfe3ad16b7224e",
"zkp": "0x123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0",
"description": "This metadata incorporates a Merkle root and a Zero-Knowledge Proof (ZKP) to validate and identify the pageView event with its full offchain data. The Merkle root ensures data integrity, while the ZKP provides privacy-preserving verification, maintaining the authenticity of events tracked through the Masa Network without revealing underlying data.",
"image": "https://masa.finance/pageView.png",
"weight": 0.5
}
This metadata provides a clear description of the data type, an associated image, and a weight that could represent the relative value or rarity of this data point within the ecosystem.
DataStaking.sol
is a smart contract that enables users to stake their non-transferable tokens, which are represented by DataPointsMulti.sol
, to earn rewards over time πΈ. This contract is a crucial component of the Masa Network's ecosystem, allowing users to participate actively by staking their accumulated data points in exchange for rewards. The contract leverages the ERC20 standard for the rewards mechanism, distributing rewards in the form of ERC20 tokens.
Key Features:
- Staking Mechanism: Users can stake their non-transferable tokens by interacting with the
DataStaking
contract. This process involves specifying the token ID and the amount they wish to stake πΌ. - Reward Calculation: The contract calculates rewards based on the amount of tokens staked, the duration of the stake, and a predefined reward rate for each token ID π. This incentivizes users to participate in the staking process.
- Role-Based Access Control: Utilizes OpenZeppelin's AccessControl to manage roles and permissions, ensuring that only authorized addresses can set reward rates and durations for staking π.
- Event Emission: The contract emits events such as
Staked
andRewardsClaimed
to provide transparency and traceability for staking actions and reward claims π£.
π Staking Tokens for Rewards
The user journey for earning rewards through staking begins with users holding non-transferable tokens, represented by DataPointsMulti.sol
, acquired from various activities within the ecosystem π€οΈ. Users can stake these tokens via the DataStaking
contract to earn rewards over time. The process involves:
- Initiating Staking: Users stake their tokens by interacting with the
DataStaking
contract, specifying the token ID and the amount they wish to stake. This decision is driven by the anticipation of earning rewards, which are influenced by the staked token's duration and reward rate β±οΈ. - Understanding Staking Parameters: The duration for which tokens must be staked and the reward rate for each token ID are predetermined by the contract's administrator through the
setRewardRateAndDuration
function. Users are aware that these parameters directly affect the potential rewards from staking their tokens π. - Claiming Rewards: Upon the completion of the staking period, users claim their rewards by calling the
claimRewards
function, specifying the token ID. The contract calculates the reward based on the staked amount, the staking duration, and the reward rate for the token ID πΈ. - Receiving Rewards: Rewards are distributed in the form of an ERC20 token, transferred to the user's address, allowing them to use or manage these tokens within the ecosystem or elsewhere π¦.
Summary:
- Staking Tokens: Users stake specific tokens to earn rewards, with each token ID having its unique reward rate and staking duration π.
- Claiming Rewards: After the staking period, users claim their rewards, which are paid out in an ERC20 token π.
- Events for Tracking: The contract emits events (
Staked
andRewardsClaimed
) to ensure transparency and traceability for staking actions and reward claims π.
Users can stake their DataPoints into Data Pools to share their data with the Masa Network. By contributing their data, users participate in the data marketplace, enabling data consumers to access aggregated and anonymized data sets. In return, users earn rewards based on the value their data brings to the network π.
π Conclusion
The Masa Data Marketplace introduces a novel approach to data sharing and monetization in the crypto space π. By representing user data as non-transferable tokens and allowing users to stake these tokens in Data Pools, the platform creates a secure, transparent, and user-centric data economy π. The Masa Data Marketplace empowers users to take control of their data and earn rewards for their contributions to the network π.