# Drawstep engine · Effects · `mayPay` > May pay — Optional payment with If you do / When you do and an optional failure branch (CR 118.12, 603.12). Engine: Magic: The Gathering (`mtg`). This is one primitive of the Drawstep card vocabulary; field names and the discriminator are exact. Wiki page: https://drawstep.xyz/wiki/mtg/effects#mayPay ## Where it goes One step of an ability's `effects[]` (a spell's, a trigger's, an activated ability's, a mode's): `{ "effect": "mayPay", … }`. Steps resolve in order. Printed words that point here (search aliases): you may pay if you do. ## Fields | Field | Type | Required | Description | |---|---|---|---| | `paymentForm` | `"unlessPrefix" \| "anyPlayer"` | no | CR 118.12: equivalent printed payment form; does not alter who pays or which branch resolves | | `repeatable` | `boolean` | no | CR 118.12, 603.12: pay zero or more times; then runs once if paid, with timesPaid resolution bound to the payment count | | `cost` | `CostDef` | yes | The cost (CostDef) | | `then` | `EffectDef[]` | yes | Effects that follow ("then …", "if you do …") | | `else` | `EffectDef[]` | no | Effects run when the condition / choice / payment fails ("otherwise …", "if you don't …") | | `who` | `"anyPlayer" \| "you" \| "controller" \| "abilityController" \| "sourceController" \| "owner" \| "eachOpponent" \| "eachPlayer" \| "target" \| "triggeringPlayer" \| "defendingPlayer" \| "attackingPlayer" \| "activ …` | no | Who is offered the payment: anyPlayer = in APNAP order, the first payer prevents the else branch (CR 101.4, 118.12); a player selector ("that player may pay {2}") offers it to those players — the then / else branches still belong to the source's controller ("If the player doesn't, you create a Treasure token") | | `target` | `TargetDef` | no | CR 118.12, 601.2c: player target or an object/stack target whose controller may pay (who: affectedController). Selected before evaluating the cost; branches read mode affected | | `chooseX` | `{ min?: number; max?: ValueDef }` | no | Choose X at resolution within these bounds, then pay that value; the body reads the paid X (CR 107.3) | ## Minimal form ```json {"effect":"mayPay","cost":{"mana":"{1}"},"then":[]} ``` The engine reads that minimal form as: “you may pay {1}”. ## Stock examples - **Energy Foundry** — “” ```json {"effect":"mayPay","cost":{"payCounters":{"counter":"energy","amount":{"kind":"var","name":"X"}}},"then":[{"effect":"createToken","token":{"name":"Aetherborn","types":["Creature"],"subtypes":["Aetherborn"],"colors":["B"],"power":{"kind":"var","name":"X"},"toughness":{"kind":"var","name":"X"}}}],"chooseX":{"min":1,"max":{"kind":"playerCounters","counter":"energy","who":"you"}}} ``` - **Shared Offering** — “” ```json {"effect":"mayPay","cost":{"sacrifice":{"of":"object","mode":"chosen","filter":{"types":["Land"]}}},"then":[{"effect":"drawCards","amount":1}],"who":"anyPlayer"} ``` - **Iteration 53 Any-Payment** — “” ```json {"effect":"mayPay","cost":{"mana":"{2}"},"then":[],"else":[{"effect":"gainLife","amount":4}],"who":"anyPlayer"} ``` ## Related - [Effects](https://drawstep.xyz/wiki/mtg/effects.md) — the whole topic - [Filters & targets](https://drawstep.xyz/wiki/mtg/targets.md) — how `target` / `filter` select objects and players (selection algebra) - [Values](https://drawstep.xyz/wiki/mtg/values.md) — every number kind an `amount` accepts - [Effects](https://drawstep.xyz/wiki/mtg/effects.md) — the steps a nested `effects` / `then` list may contain - [Start here](https://drawstep.xyz/wiki/mtg/start.md) — the rules, the output contract and the index of every primitive