Author: Kautuk Kundan, Manan @Stackr Labs; Compiler: Leia @TEDAO p>
Translator's introduction:
As an incentive mechanism, the points system can promote the interaction between users and the protocol, thereby promoting the development of the protocol and growth. It is a tool, not a goal. Points should not be the only reason for users to use the product, the product itself should be attractive. At the same time, users need clear and predictable rules to understand how to earn points, and on-chain points can avoid the "black box" problem of traditional points systems.
Micro- Rollup,as a way to implement a points system on-chain, provides a cost-effective and efficient way. It not only ensures the speed and flexibility of operations, but also ensures the verifiability and security of data by performing logical operations off-chain and then pushing the verification results to the chain.
This is not only It provides developers with a new tool and provides the entire crypto ecosystem with a new way of thinking about how to apply technological innovation to improve user engagement and incentive mechanisms.
Recently, points have quickly become The catalyst for user participation in the crypto ecosystem has led to the successful practices of many top teams and protocols. The concept is not complicated: Users interact with the protocol by promoting its development, thereby receiving rewards from the protocol in the form of points. This mechanism is similar to the experience point (XP) system common in many video games. Players improve their ranking by continuously accumulating experience points; and the improvement in ranking will encourage players to continue working hard and strive for higher ranking.
Many protocols use points as a prelude to the introduction of protocol governance tokens (tokens). Indicates that the distribution of tokens will be based on the number of points accumulated by users. This strategy buys the protocol and team valuable time before releasing details about the token, while also delaying the scrutiny they would face if they make a mistake. Point accumulation operates similarly to yield farming, but without direct economic incentives, it provides a broader way of user participation and rewards.
Now, using points to motivate users and promote the development of the protocol has become a new trend. Interestingly, the supply of points could theoretically be unlimited, which puts a new twist on the traditional airdrop mechanism and sets it apart from actual tokens.
Points problem p>
PMF should not be understood as "Points Market Fit". If a product cannot gain traction among users without a points system, then adding a points system on top of it and calling it a PMF will not help. Points should not be the key factor in deciding whether a user chooses product X or product Y. Rather, both products X and Y should provide intrinsic value to the user.
Another big problem is thatmost points Systems are "black boxes" whose computational properties are unpredictable over time. This opacity has both advantages and disadvantages—the upside is that it gives teams more flexibility to adjust the system’s rules; the downside is that it also takes away perceived control or influence from users. .
The rules for obtaining experience points (i.e. points) in the game should be clear And predictable!
If the points system is auditable, transparent and predictable , while remaining flexible enough for teams to design activities around it, what would it be like?
On-chain points p>
Implementing a points system on-chain is an attractive idea, but it shouldn’t be done just to create another A guise for ERC-20 tokens. There have been protocols that launched a pre-release token with the promise that it would eventually be converted into another token (essentially points in disguise), only to flood the ecosystem with unnecessary tokens.
Consider points on the chain as a different existence from ERC-20 tokens. Through the combination of points system, unique experiences can be created for users. However, implementing an on-chain points tracking system at the Layer-1 or Layer-2 level requires high costs, which raises a very critical question: Why not directly use ERC-20 tokens to represent points?
This situation highlights why the on-chain points system is as micro on Stackr -Ideal for development with -rollup. Delving into the issues faced by the existing points system infrastructure, the team worked through the night and conducted internal research sprints, ultimately developing a dedicated virtual machine (VM) to track and manage the protocol's points.
Micro-Rollups Quick Start
Micro-Rollup end-to-end workflow
Micro-rollups are essentially state machines that can perform specific logical operations off-chain and then outsource execution verification to a software called "Vulcan " validation layer. Vulcan is responsible for validating status updates and submitting calculated data to the chain.
-The state machine has a defined state shape and will Initialization condition (genesis condition) to determine the starting state of the state machine.
-The state machine contains a set of actions (can be understood as transaction types), when When called, these actions trigger state transition functions on the state machine.
-State Transition Function (STF) is responsible for performing calculations and updating The state of the state machine. After the STF is executed, these actions will be packaged into a block and sent to Vulcan.
Finally, Vulcan will:
Pessimistically assume the calculation result of STF There may be errors or malicious tampering. Re-execute the actions in the block to ensure the correctness of the results.
Generate metadata for verified blocks .
Complete settlement on Layer-1 and DA .
Micro-rollup updated status is sent to DA.
The metadata of the verified block and The updated state root is placed in the micro-rollup inbox contract on Layer-1.
The above process together constitutes the working principle of Stackr's Micro-Rollup framework.
Point system Micro-Rollup
So, why are micro-rollups particularly suitable for building a points system? ?
Micro-rollups provide a fast, flexible, self-hosted execution environment.
This ensures that the issuance of points will not cause "on-chain ” overhead, and all status updates happen as quickly as possible.
Micro-rollups support verifiable off-chain calculations.
Despite being self-hosted, the framework is still guaranteed to be Any data that enters the system and changes status can be fully verified before the data is settled to Layer-1. This ensures that the system operates in a predictable manner and cannot be tampered with.
Micro-rollups make the status available audit.
Once the state machine is deployed, the logic of the STF cannot be Change. This provides users with a guarantee that the rules of the system will not be modified at will by the provider.
Micro-rollups can be directly Settlement takes place on Layer-1.
Since micro-rollups can be performed directly on Layer-1 Settlement and status proof can be used directly within the contract to achieve on-chain operations. The verification layer can greatly shorten the settlement cycle by providing pre-settlement guarantees.
Exploration of building a points system Journey
Disclaimer: This demo is for display only It is a version without any optimization and is not suitable for production environments. Please understand this content as an illustrative example and not as a final product.
When developing micro-rollup, in the form of state machine It is crucial to think of logic. This requires careful consideration of the state of the micro-rollup (i.e. the data it will save), and the actions that determine the behavior of the STF (the function operates on the state).
Thinking about application construction from the perspective of a state machine
< span style="font-size: 18px;">Adhering to the above concept, we used Stackr's SDK (development tool kit) to start designing the micro-rollup state.
Design
When the user is on the platform When executing off-chain or on-chain actions, events will be triggered. Administrators can also assign events to users.
Points are stored in a state machine off-chain .
The system contains an STF that is used to determine the grant The time and amount of user points.
The event will trigger the STF and the status will be based on the user updated with the latest points.
Every time a set time period passes ( epoch), a block will be generated containing the details of the user event and the updated score table status.
The block is sent to the Vulcan network for verification .
If the block conforms to the rules of the state machine, is approved.
The block data is split into two parts. Settlement is performed on Layer-1 and DA respectively.
p>
Points system in Micro-rollup architecture
Define base state
First, we addadmins ( Administrator) andeventRegistry(event registry):
admins: Can register event entities and create events for users The address to which points are allocated.
event: Any type of entity for which users can earn points. It can be an on-chain event or a custom event added manually. For example: "sign-up" registration event (custom) can get 200 points, "swap" redemption event (on-chain) can get 500 points, etc.
p>
Next, we need a way to track the events that a user qualifies for points.
A user may perform There has been 1 sign-up event and 5 swap events. Each event is an entry in the eventLog.
We added eventLog in the state to track all on-chain events corresponding to each user and the maximum points for each event. Currently, we don't need the integral subfield as it can be obtained from the eventRegistry. But in order to make the system more flexible for future expansion, we still added this field.
Add status update processing< /p>
After setting the minimum viable state, we need to define reducers that update the state.
Add logEventReducer, responsible for creating log entries for user events.
p>
The detailed disassembly is as follows:
The administrator calls the logEvent action using the event name and user identifier ( This article does not contain a detailed discussion of this operation).
This action will trigger the state machine and call logEventReducer .
This Reducer will then:
For example: span>
The administrator calls logEvent({user: mg-labs.eth, event: "deposit"})
Reducer will find the deposit action in eventRegistry and record the deposit event and its corresponding points for user mg-labs.eth.
At this point, we have built a minimal A viable points system.
Smart contract vs Micro-rollup
If we want to calculate the user's total points, we need to traverse the user's event log, and each This process is repeated each time the total points are calculated.
If the points system is built as a smart contract, this may be feasible approach, but storage costs in EVM are extremely high compared to micro-rollup, and this design may not be ideal.
The micro-rollup we are building has a relatively lower cost and can be more Gain the freedom and flexibility to manage state and computation so you can prioritize user experience over cost tradeoffs.
Storage calculated points
Add userPoints to status
It will be responsible for saving the total points assigned to the user.
When an event is logged, we also update the logEventReducer to update the user's points.
Done!
Build an event-driven integration with on-chain traceability The system is that simple! Is it easy to give on-chain superpowers to backend servers?
Off-chain points on-chain - airdrops and more possibilities✨
The beauty of this system is that it allows points to be Seamlessly used on-chain without high overhead.
As mentioned at the beginning of the article, the state root of micro-rollup will be in Layer- 1 on settlement. It is worth noting that developers can choose which state data is settled on Layer-1 and which is put as metadata on DA, thus enabling hybrid security assumptions.
In this example, if we extract userPoints and Merkle them When the root is settled on Layer-1, the user's inclusion proofs in the Merkle tree can be directly realized.
This feature allows us to seamlessly build a variety of on-chain experiences, including trustless token exchange, point rewards, and on-chain secondary points. market and so on. By introducing user points data onto the chain by including proofs, the possibilities for on-chain experience will be greatly expanded!
This method realizes the integration of points on the chain without the need to Points are placed entirely on-chain (significantly reducing costs and optimizing user experience).
Imagination
The points system currently constructed in this article is just the tip of the iceberg and can be greatly modified. Expand to implement many functions. Here are some possible expansion directions:
Multipliers ( Multiple)
Teams often like to set time-limited multipliers on base points for certain events or activities,because this is a very effective mechanism that can be used with Cooperate with other projects, increase community and protocol activity, etc. In this version of the points system, we already store the points that should be assigned to an event at a specific time, so iterating and implementing multipliers is very simple.
First, update the EventRegistry save the list of multipliers for each event.
As shown above, each event has a set of multipliers that can be activated and deactivated by the team, allowing for flexible event design.
In order to support the above status updates, we updated logEventReducer to make it applicable Multipleliers.
The above logic can not only apply one multiplier, but also superimpose multiple multipliers when calculating the number of points assigned to an event.
Recommended
Similar to multipliers , recommendation systems are also key to many point systems. Recommendation systems are difficult to build entirely on-chain as their structures can be quite complex.
For example, MarginFi has a multi-level recommendation system -< /span>
Building the points system as a micro-rollup gives you the freedom to implement the above mechanisms, no matter how complex, in their own independent execution environment.
Points Automation
The above system provides a lot of flexibility, but also requires additional infrastructure for the administrator (or Robots) update user points to increase workload.
We can transfer all user events from The selected contracts are imported into micro-rollup; at the same time, Rollup's STF focuses on the algorithm for calculating user points and transparently displays the point calculation method, so that we can improve the autonomy of the system.
Points are reputation p>
Points can easily be thought of as experience points or reputation points in the social economy. They are a form of recognition for making a valuable contribution to a protocol or product. In the social economy, using points systems as reputation trackers provides a vast space for creating on-chain experiences, full of exciting opportunities for engagement and innovation.
For example, if Reddit’s Karma points were built on micro-rollup , perhaps making what have been jokingly called “useless Internet points” available on-chain immediately.
Using this framework, it may only take a few days of work The existing Karma points system can be ported to the chain.
Conclusion
The points system has shown great potential at the intersection of Web2 and Web3, and a novel hybrid architecture is needed to accomplish. This is where micro-rollups offer opportunities.
Micro-rollups provide the freedom to flexibly choose the degree of decentralization . They allow developers to build applications according to their preferences, whether pursuing full decentralization, full decentralization, or an entirely new model that has yet to be revealed.