In the movescription contract, locking and returning SUI is a crucial aspect, especially in the process of minting, managing, and burning (Movescription). Let's analyze the security of the SUI you pay during the process of minting an inscription.

Locking SUI

  1. Minting Process: When a new Movescription is minted, a certain amount of SUI fee is charged. This fee is encapsulated in the balance of the Movescription object. The relevant code for this process can be found in the do_mint function, where the minting fee (fee_coin) is converted into a balance (fee_balance) and stored in the Movescription object.
public fun do_mint(
        tick_record: &mut TickRecord,
        fee_coin: Coin<SUI>,
        clk: &Clock,
        ctx: &mut TxContext
    ) {
        // Code omitted for brevity
    }

  1. Inscription Structure: Each Movescription struct includes a field called acc of type Balance<SUI>. This field holds the locked SUI balance associated with the inscription.
struct Movescription has key, store {
    // ... other fields ...
    acc: Balance<SUI>,
    // ... other fields ...
}

  1. Fee Handling: When an inscription is minted, the SUI fee is locked in the acc field of the Movescription. This is evident in the do_mint function, where fee_balance is the result of processing fee_coin.

Returning SUI After Burning

  1. Burning Process: The burn function allows users to burn an inscription. When this happens, any locked SUI associated with the inscription should be returned to the user.
public entry fun burn(
        tick_record: &mut TickRecord,
        inscription: Movescription,
        ctx: &mut TxContext
    ) {
        // Code omitted for brevity
    }

  1. Converting Balance to Coin: In the do_burn function, the acc balance of the inscription is converted back into a Coin<SUI> object. This is done using the coin::from_balance<SUI> function, effectively unlocking the SUI and making it available for transfer.
public fun do_burn(
        tick_record: &mut TickRecord,
        inscription: Movescription,
        ctx: &mut TxContext
    ) : Coin<SUI> {
        // Code omitted for brevity
    }

  1. Returning SUI to the User: After the conversion, the burn function uses transfer::public_transfer to send the unlocked SUI back to the user (sender) who initiated the burn transaction.

Summary

In the Movescription contract, SUI is locked as a fee during the minting process and stored in the balance field of the Movescription struct. When an inscription is burned, the locked SUI is converted back into a Coin<SUI> and returned to the user. This mechanism ensures that SUI is securely locked during inscription minting and can be retrieved by the user (sender) at any time by burning the inscription.