Comment on page
➗
MRV aggregation and splitting for minting tokens
For a demo example of following steps, here is the policy timestamp: 1675266693.102366003
MRV documents feature a numerical measurement field. The values in this field are periodically aggregated, in this example we will use 1 minute period.
The purpose of the aggregation is to mint tokens, in this example 1 token will be minted for each part which equal to 1000 of the aggregated value.
Create a token and 2 schemas (User and Report). For simplicity the token will not require a KYC.
Build the first part of the document entry:
.png?alt=media)
image1.png
- 1.Add ‘aggregateDocumentBlock' after saving the document in the database. This is the block which would accumulate documents/values until the condition is met (which in this case is the event from the timer).
1.1 Put 'aggregateDocumentBlock' in a separate container to avoid it from interfering with the working of 'interfaceStepBlock'
.png?alt=media)
Adding aggregateDocumentBlock
.png?alt=media)
Adding aggregateDocumentBlock in separate container
1.2 Pass the document to the ‘aggregateDocumentBlock' after it is saved.
%20(1).png?alt=media)
Passing the saved document to the aggregateDocumentBlock
- 2.Timer is a separate block called 'timerBlock'
2.1 For each user there is a separate timer execution context (i.e., each user has an independent timer). For this it requires a document owned by the user to be passed into this. To ensure this, let’s add the timer immediately after user registration.
.png?alt=media)
Adding timerBlock after user registration
2.2 Set the timer to trigger every minute
.png?alt=media)
Setting the timer for every minute
2.3 Now after the timer is launched, it would create a ‘TimerEvent’ periodically every minute. And then connect it with ‘aggregateDocumentBlock':
.png?alt=media)
Connecting TimerBlock with aggregateDocumentBlock
- 1.To split the document into equal parts, add 'splitBlock'
1.1 Add 'splitBlock' immediately after the 'aggregateDocumentBlock'
.png?alt=media)
Adding splitBlock after aggregateDocumentBlock
1.2 Configure the document field which would be used for splitting/aggregation
.png?alt=media)
Configuring Source Field
1.3 Set a ‘Threshold’ to configure the value for splitting the document.
%20(2).png?alt=media)
Setting the Threshold for split
Add 'mintDocumentBlock' immediately after ‘splitBlock' to mint tokes and configure the minting rule
.png?alt=media)
Adding mintDocumentBlock after splitBlock
Last modified 1mo ago