Skip to content

XSC-0002: Permit

XSC-0002 extends the fungible-token interface with signature-based approvals.

Canonical Function

python
@export
def permit(
    owner: str,
    spender: str,
    value: float,
    deadline: str,
    signature: str,
):
    ...

Expected Behavior

  • the owner signs an approval message off-chain
  • anyone can submit that signed permit on-chain before deadline
  • the contract verifies the signature and writes the allowance
  • the permit must be single-use

deadline is checked against contract now, which means finalized block time. So permit validity depends on the timestamp of the block that includes the transaction, not on local wallet clock time or mempool arrival time.

The canonical currency contract does that by hashing a permit message, verifying it with crypto.verify, and storing the used permit hash:

python
permits[permit_hash] = True
balances[owner, spender] = value

Message Construction

The current canonical message includes:

  • owner
  • spender
  • value
  • deadline
  • ctx.this
  • chain_id

Including the contract name and chain id prevents replay across contracts or networks.

Event Expectations

Successful permits emit the same approval event used by XSC-0001 so off-chain tools only need one approval event model.