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

    Variable grantEntitlementConst

    grantEntitlement: (
        fields: FieldsOf<K>,
    ) => {
        actor: Principal;
        attrs?: EntitlementAttributes;
        idempotencyKey: string;
        kind: "grantEntitlement";
        sku: string;
        userId: string;
    } = ...

    Builds a grantEntitlement operation: records that a user owns a SKU. Ownership is a record, not a balance — no money moves, no ledger legs post, and the committed transaction is a lifecycle marker. A spend grants the buyer's entitlement itself; this direct grant is for manual fulfillment, migration, or a comp. The grant is a full overwrite of any prior record for the user and SKU, and the optional attrs (quantity, version, expiresAt, source) are stored, not enforced — no sweep expires an entitlement. Restricted to a system or operator actor. It has no rejected path: a well-formed grant always commits, and a retry under the same idempotencyKey returns the earlier marker as duplicate without rewriting the record.

    Type Declaration

      • (
            fields: FieldsOf<K>,
        ): {
            actor: Principal;
            attrs?: EntitlementAttributes;
            idempotencyKey: string;
            kind: "grantEntitlement";
            sku: string;
            userId: string;
        }
      • Parameters

        • fields: FieldsOf<K>

        Returns {
            actor: Principal;
            attrs?: EntitlementAttributes;
            idempotencyKey: string;
            kind: "grantEntitlement";
            sku: string;
            userId: string;
        }

    const outcome = await economy.submit(grantEntitlement({
    idempotencyKey: idempotencyKey('comp', 'usr_owner', 'wrld_pass'),
    actor: systemActor('fulfillment'),
    userId: 'usr_owner',
    sku: 'wrld_pass',
    }));
    // read.entitled('usr_owner', 'wrld_pass') now resolves true