From 585b7f26a2669573a6b701e132f037d470a6c46b Mon Sep 17 00:00:00 2001 From: Randy Pen Date: Wed, 29 May 2024 11:11:15 +0800 Subject: [PATCH] sbt record --- src/sbt-record.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/sbt-record.md diff --git a/src/sbt-record.md b/src/sbt-record.md new file mode 100644 index 0000000..5aef122 --- /dev/null +++ b/src/sbt-record.md @@ -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, +} +``` + +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(&mut ticket.record, object::id(&game), true); + }; + ... +} +``` + +Upon users redeeming their rewards for an activity, the participation record should be archived or removed. + +## Examples +