Documentation Index
Fetch the complete documentation index at: https://docs.snagsolutions.io/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Token rewards let a loyalty rule pay an on-chain ERC-20 amount directly into the user’s wallet on rule completion. Examples:- A “mint NFT” rule that grants $50 in FLOW.
- A “10k impressions” rule that grants $10 in ETH.
- A quest chain that grants $5 in USDC on the final step.
How it works
Token rewards reuse the existing loyalty ledger via a hiddenLoyaltyCurrency. When you create a token rule:
- The backend resolves (or creates) a hidden
LoyaltyCurrencybound to the chosen contract, withdecimals: 18(so fractional amounts like0.5work correctly). - It also creates an
OnchainTokenrow withdistributionType = transferand the chosen relayer. - Rule completion writes a normal
LoyaltyTransactionEntryagainst that hidden currency — same code path as points. - The on-chain token sync worker picks up the entries, batches recipients/amounts, and submits a
disperseTokencall to the Disperse.app contract via the relayer. - The payout transaction hash is written back to each
LoyaltyTransactionEntry.distributeNativeTokensTxHash.
Distribution types on OnchainToken
| Type | What it does |
|---|---|
mint | Existing flow. Calls batchAdminMint / batchAdminBurn on the hybrid ERC-20 contract from the relayer. |
transfer | New flow. Encodes a batched disperseToken(token, recipients[], amounts[]) call to the Disperse contract; the relayer’s wallet is the funding source. Used for token rewards. |
Decimals — important for fractional amounts
Token rewards depend on the existingLoyaltyCurrency.decimals field. The loyalty system stores raw amounts in the smallest units of the currency; everything user-facing converts via formatLoyaltyAmountForDisplay(rawAmount, decimals) (frontend) or fromDecimalToNumber(decimals, rawAmount) (backend).
If you add a custom display path for loyalty amounts, route it through formatLoyaltyAmountForDisplay — otherwise an 18-decimal currency will show as 1000000000000000000 instead of 1.
When a user completes a token-reward rule, the success modal includes the line “It may take a few minutes to appear in your wallet.” — payout is asynchronous (driven by the on-chain token sync worker), with a 5-minute upper bound under normal load.
Plan gating
Token rewards require Pro (specificallyenableStratusRelayers). The rule will reject at create time and at run time on lower plans with a pricing-plan error.
Configuration
In the rule form:- Pick Tokens in the reward-type toggle.
- Pick a Relayer — the dropdown filters to relayers on the chain of any contract you’ve already chosen.
- Pick a Token (the contract) — filtered to the relayer’s chain.
- Set the amount per completion (
0.01minimum).
LoyaltyCurrency + OnchainToken linkage on first save; subsequent rules pointing at the same (contract, relayer) reuse them.