-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# SBT Record | ||
|
||
||| | ||
|-|-| | ||
| **Name** | SBT Record | | ||
| **Origin** | [Pika](https://github.com/RandyPen) | | ||
| **Example** | | | ||
| **Depends on** | None | | ||
| **Known to work on** | Move | | ||
|
||
## Summary | ||
|
||
In many fully on-chain applications, it is necessary to record the activities that users have participated in, to help them remember which activities they have engaged in and to allow them to check results or claim rewards. | ||
|
||
Soulbound Tokens (SBTs) can be distributed to users, encapsulating a record of their engagement with various activities. | ||
|
||
Define SBT. | ||
```move | ||
public struct Ticket has key { | ||
id: UID, | ||
record: Table<ID, bool>, | ||
} | ||
``` | ||
|
||
When users participate in activities. | ||
|
||
```move | ||
public fun participant_activity(ticket: &mut Ticket, game: &mut Game, ...) { | ||
... | ||
if (!table::contains(&ticket.record, object::id(&game))) { | ||
table::add<ID, bool>(&mut ticket.record, object::id(&game), true); | ||
}; | ||
... | ||
} | ||
``` | ||
|
||
Upon users redeeming their rewards for an activity, the participation record should be archived or removed. | ||
|
||
## Examples | ||
|