Skip to main content

Point-Conversion

The process of giving users an on-chain representation of the off-chain points they collected on a particular protocol is called point-conversion. Let's break down this process into steps:

  • Company Part
    • An onboarded company uploads an updated version of their users' off-chain point balance periodically (depends on the company | could be daily, twice a week, etc...).
  • User Part
    • A user connects their wallet account to Monet platform. They will be able to see the different off-chain point balances they have over different protocols, -collected using this wallet account-.
    • A user can see their total collected off-chain points -according to the most recent point balance sheet submitted to Monet by the company-, their already-converted points, and their convertible points (total off-chain points minus already-converted points).
  • Website Level
    • When a user decides to convert some off-chain points into on-chain points, they will be asked to select the number of off-chain points they want to convert. This number should be less than or equal to the convertible points value (mentioned in Step2).

    • Once the user chooses the amount of points they want to convert, and hit the submit button, a chain of actions will be triggered, as described in the next lines:

    • First, the UI will ensure that the amount the user is trying to convert is less than or equal to this user’s convertible points. When that’s assured, the backend will build a unique message that includes details such as:

      • the user’s address.
      • the amount of points to-be-converted.
      • a unique nonce of the user.
      • the point contract address. Along with other details.
    • This message will be hashed, then signed using Monet account’s private key.

    • This signature (the signed hashed-message) will be used later on the smart contract level to validate the conversion of points.

    • The process of the signature creation:

      Signature Creation

    • Then, the frontend will ask the user to sign a transaction. This transaction represents a function call (The function that mints on-chain points in the point contract), and includes -as arguments- the amount of points that the user wants to convert on-chain, along with the signature created by the backend.

  • Smart Contract Level
    • When the mint function of the smart contract gets called, it will decode the signature that got passed to it. The result of decoding the right signature is a hashed message, along with the Signer of it (the hashed-message built in the backend in step3, along with the signer of that message, which is Monet account).

    • If the signer that the contract got after decoding the signature is not Monet, it means that the signature is invalid. The transaction will revert, and no points will be minted (created).

    • If the signer turns out to be Monet, the contract will start rebuilding the hashed message that was created at the website level (in step3).

    • The process of rebuilding the hashed message goes as follows:

      Rebuilding the hashed message

    • Once the message is rebuilt, it gets hashed, then compared with the hashed-message that was created at the website level and extracted from the signature.

    • If the two hashes are the same, this means that this is a valid signature, and the minting process goes through.

    • If the two hashes are not the same, the transaction will revert, and no points will be minted.

    • When a valid signature is used, it gets stored in the contract, and it can’t be used again.