Skip to content

[38] Add Soroban token-allowance withdrawal pattern for QuestEngine employer-funding #38

Description

@merlik787-droi

Problem Statement

quest-engine::create_build_quest requires the employer to call with sufficient balance and approve the transfer at the same time. This forces employers to send a transaction with their balance at the moment of quest creation. If the create_build_quest call is assembled with the wrong amount or wrong token, the whole call reverts.

A pattern where the employer could pre-authorize the QuestEngine to pull funds on demand (Soroban token allowance) would be more flex-protocol-friendly.

Why It Matters

  • Reduces friction for employer integration.
  • Allows multi-quest setup with a single allowance.

Expected Outcome

  • New function set_escrow_allowance(env, employer, max_amount) (an internal flow — actually, this is just the SAC token allowance, so this concerns caller UX, not contract invocations).
  • Add a helper function create_build_quest_with_allowance that uses token::Client::transfer_from (requires SAC support for allowances) if and when the network supports it.

Acceptance Criteria

  • Document uses the helper pattern in employer guides.
  • Tests for the allowance flow.

Implementation Notes

Files / Modules Affected

  • contracts/quest-engine/src/lib.rs
  • contracts/quest-engine/README.md

Dependencies

Requires SAC token allowance support.

Difficulty

Medium.

Estimated Effort

1–2 days.

Suggested Labels

feature, ux, P3, quest-engine


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions