@pwngh/economy-lab
    Preparing search index...

    Variable grantPromoConst

    grantPromo: (
        fields: FieldsOf<K>,
    ) => {
        actor: Principal;
        amount: Amount;
        expiresAt: number;
        idempotencyKey: string;
        kind: "grantPromo";
        userId: string;
    } = ...

    Builds a grantPromo operation: issues expiring marketing credit. It credits the user's promo account against PROMO_FLOAT; promo credit needs no USD backing, is drawn before the buyer's own money on the next spend, and is spendable but never paid out. After expiresAt the worker's expiry sweep reverses whatever is unspent, so the timestamp must be strictly in the future (a past one would let the sweep claw the credit straight back) and no more than five years out. Restricted to a system or operator actor — the operation mints credit into an arbitrary account. It has no rejected path: every failure is a thrown fault. A retry under the same idempotencyKey returns the original grant as duplicate.

    Type Declaration

      • (
            fields: FieldsOf<K>,
        ): {
            actor: Principal;
            amount: Amount;
            expiresAt: number;
            idempotencyKey: string;
            kind: "grantPromo";
            userId: string;
        }
      • Parameters

        • fields: FieldsOf<K>

        Returns {
            actor: Principal;
            amount: Amount;
            expiresAt: number;
            idempotencyKey: string;
            kind: "grantPromo";
            userId: string;
        }

    const outcome = await economy.submit(grantPromo({
    idempotencyKey: idempotencyKey('promo', 'summer26', 'usr_buyer'),
    actor: systemActor('marketing'),
    userId: 'usr_buyer',
    amount: toAmount('CREDIT', 25_000n), // 250 credits
    expiresAt: Date.now() + 30 * 86_400_000,
    }));