Skip to content

SEP-41: Clarify allowance behavior - #1918

Open
aristidesstaffieri wants to merge 3 commits into
masterfrom
chore/document-allowances-sep41
Open

SEP-41: Clarify allowance behavior#1918
aristidesstaffieri wants to merge 3 commits into
masterfrom
chore/document-allowances-sep41

Conversation

@aristidesstaffieri

@aristidesstaffieri aristidesstaffieri commented Apr 28, 2026

Copy link
Copy Markdown

Summary

Documents how allowances behave in SEP-41 — most importantly, that approving a spender a second time replaces the previous allowance rather than adding to it.

The question that prompted this: if I approve a spender for 40 XLM, then approve the same spender 50 XLM, is their total allowance 90 or 50? The answer is 50, but that is answerable today only from a security caution on developers.stellar.org — not from SEP-41, and not from CAP-46-6, which specifies the interface rather than these semantics. Discussion: #1919.

The behavior is described in the doc comments of the functions it applies to, in the register ERC-20 uses: what a caller can do, rather than what values change internally. Each function keeps a brief one-line summary for rustdoc, with the added detail in a following paragraph.

Wording only — no new normative requirements and no interface change — so this is a patch bump to Version 0.5.1.

What's in this PR

One file, ecosystem/sep-0041.md:

  • allowance — returns the amount spender is still allowed to transfer from from.
  • approve — permits repeated transfers up to amount, and a second call overwrites the first rather than adding to it.
  • approve notes — an allowance is a spending limit, not a reservation of balance; and zeroing-then-checking before replacing one is a client responsibility, explicitly not a contract requirement.
  • transfer_from / burn_from — reduce the allowance without changing when it expires, and fail if the allowance or the balance is short.
  • Preamble and changelog — Version 0.5.1, Updated: 2026-08-03, with a matching changelog entry.

Deliberately not specified

Review feedback was that the first version of this PR risked over-specifying by reaching into implementation details. These are left to implementations:

  • Storage layout — allowances are not described as keyed per (from, spender) pair, and values are not described as recorded entries.
  • Auth requirements — no require_auth requirement is added to approve.
  • Failure atomicity — that a failed call moves nothing follows from the host, and is not restated as a token-level rule.
  • Allowance events — no event is emitted when an allowance is consumed. Mandating one would be an interface change rather than a clarification, so it is raised separately on Formalize allowance behavior in SEP-41 documentation #1919.
  • Expiry, in allowance's return description — the live_until_ledger argument doc already states that an expired entry is treated as a 0 amount allowance. Restating it on the return value adds nothing, and enumerating every case that returns 0 (never set, revoked, reset) would be noise.

Test plan

  • yarn sep-check clean
  • ecosystem/sep-0041.md is the only file touched, rebased on current master
  • Each question raised in Formalize allowance behavior in SEP-41 documentation #1919 is answerable from the interface block alone: 40-then-50 → 50; does transfer_from decrement → yes; allowance vs. balance → a limit, not a reservation
  • CI green

@aristidesstaffieri aristidesstaffieri self-assigned this Apr 28, 2026
Copilot AI review requested due to automatic review settings April 28, 2026 21:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates SEP-41 (Soroban Token Interface) to explicitly specify the semantics of token allowances (approve/allowance/transfer_from/burn_from), reducing ambiguity for implementers and aligning expectations across implementations.

Changes:

  • Bump SEP-41 metadata to Updated: 2026-04-28 and Version 0.4.2.
  • Add a new Allowances section defining allowance independence, overwrite behavior, consumption rules, expiration semantics, and balance interaction.
  • Extend the changelog with a v0.4.2 entry describing the allowance documentation update.

Comment thread ecosystem/sep-0041.md Outdated
aristidesstaffieri added a commit that referenced this pull request Apr 28, 2026
CAP-46-6 specifies the interface and a couple of behaviors (live_until_ledger
expiration semantics, events), but several allowance rules in this section
(overwrite-not-increment, independence per (from, spender), no reset-to-0
requirement, atomic failure of transfer_from, balance interaction) are not
specified there. Reword so SEP-41 is the normative source for these rules,
with CAP-46-6 cited as the matching reference implementation.

Addresses Copilot review on PR #1918.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

This pull request is stale because it has been open for 30 days with no activity. It will be closed in 30 days unless the stale label is removed.

@github-actions github-actions Bot added stale and removed stale labels May 29, 2026
@leighmcculloch
leighmcculloch marked this pull request as draft June 9, 2026 06:35
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

This pull request is stale because it has been open for 30 days with no activity. It will be closed in 30 days unless the stale label is removed.

@github-actions github-actions Bot added the stale label Jul 9, 2026
  SEP-41 specifies the allowance functions but not how allowances behave.
  The question that prompted this -- whether approving a spender a second
  time replaces the first allowance or adds to it -- is answerable today
  only from a security caution on developers.stellar.org, not from the SEP
  or from CAP-46-6.

  Per review feedback, describe the behavior briefly in the doc comments of
  the functions it applies to, in the register ERC-20 uses, rather than in a
  standalone section enumerating state changes:

  - allowance returns what spender is still allowed to withdraw, or 0 once
    the allowance has expired.
  - approve allows repeated withdrawals up to amount, and overwrites the
    current allowance rather than adding to it. Notes that an allowance is a
    spending limit rather than a reservation of balance, and that clients,
    not contracts, should zero and check an allowance before replacing it.
  - transfer_from and burn_from draw on the allowance and fail if it or the
    balance is short.

  Storage layout and auth requirements are deliberately left unspecified:
  allowances are not described as keyed per (from, spender) pair, values are
  not described as recorded entries, and no require_auth requirement is
  added.
@aristidesstaffieri
aristidesstaffieri force-pushed the chore/document-allowances-sep41 branch from 4905a34 to cf7c874 Compare July 31, 2026 16:25
@aristidesstaffieri
aristidesstaffieri marked this pull request as ready for review July 31, 2026 16:26
@aristidesstaffieri aristidesstaffieri changed the title chore: Document allowance semantics in SEP-41 SEP-41: Clarify allowance behavior Jul 31, 2026
@leighmcculloch
leighmcculloch requested a review from sisuresh August 3, 2026 05:23

@leighmcculloch leighmcculloch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple minor suggestions inline.

Comment thread ecosystem/sep-0041.md Outdated
Comment thread ecosystem/sep-0041.md Outdated
Comment thread ecosystem/sep-0041.md Outdated
  SEP-41 specifies the allowance functions but not how allowances behave.
  The question that prompted this -- whether approving a spender a second
  time replaces the first allowance or adds to it -- is answerable today
  only from a security caution on developers.stellar.org, not from the SEP
  or from CAP-46-6.

  Describe the behavior in the doc comments of the functions it applies
  to, in the register ERC-20 uses, rather than in a standalone section
  enumerating state changes. Each function keeps a brief summary line for
  rustdoc, with the added detail in a following paragraph:

  - allowance returns what spender is still allowed to transfer from from.
  - approve allows repeated transfers up to amount, and overwrites the
    current allowance rather than adding to it. Notes that an allowance is
    a spending limit rather than a reservation of balance, and that
    clients, not contracts, should zero and check an allowance before
    replacing it.
  - transfer_from and burn_from reduce the allowance without changing when
    it expires, and fail if the allowance or the balance is short.

  Storage layout and auth requirements are deliberately left unspecified:
  allowances are not described as keyed per (from, spender) pair, values
  are not described as recorded entries, and no require_auth requirement
  is added.

@sisuresh sisuresh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@leighmcculloch

Copy link
Copy Markdown
Member

I'll merge this change in 7 days from today if there are no new feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants