Allowance By Signatures

Signature-based allowance authorization allows a token holder to sign a message offchain that a third party can later submit onchain. This enables delegation of transaction construction, batched authorizations, and offline signing workflows.

In effect, you can authorize statements like:

"I, owner of 0x123, permit 0x456 to increase their allowance by 1000 tokens using nonce 42 before timestamp 15250"

Ethereum Signature-based Allowance

On Ethereum, the permit() function sets allowance to an absolute value using ECDSA where the public key is recovered from signature components.

Ethereum permitsolidity
permit(address owner,
    address spender,
    uint256 value,      // Absolute allowance value
    uint256 deadline,   // Unix timestamp
    uint8 v, bytes32 r, bytes32 s  // ECDSA signature
) external;

OP_NET Signature-based Allowance

On OP_NET, the OP20 base class supports offchain allowance management through Schnorr signatures. The increaseAllowanceBySignature() and decreaseAllowanceBySignature() methods enable users to authorize allowance changes without submitting immediate onchain transactions.

Allowance by signaturesassemblyscript
increaseAllowanceBySignature(owner: Address,
    spender: Address, 
    amount: u256, 
    deadline: u64, 
    signature: u8[]): void;

decreaseAllowanceBySignature(owner: Address, 
    spender: Address, 
    amount: u256, 
    deadline: u64, 
    signature: u8[]): void;
!!!! Add Example here
The following example demonstrates how to sign an allowance increase offchain, submit it onchain, and spend the resulting allowance:
Using allowance by signatures exampleassemblyscript

OP20 nonce Management

A nonce prevents replay attacks where the same signature could be submitted multiple times to repeat an allowance change. Without nonces, a signed increase of 1000 tokens could be submitted repeatedly until the attacker drains funds through accumulated allowances.

Each owner address maintains a single nonce sequence stored in the contract. When increaseAllowanceBySignature() or decreaseAllowanceBySignature() executes, the contract reads the current nonce from storage, includes it in the message hash reconstruction, verifies the signature against that hash, then increments the nonce if verification succeeds.

Signers must query nonceOf(owner) beforehand to know which nonce to include in their signed message. If the signed nonce does not match the stored nonce at execution time, verification fails.

Both increase and decrease operations share the same nonce sequence. Signing an increase with nonce 5 and a decrease with nonce 5 means only one can execute; whichever lands first invalidates the other.

Ethereum vs OP_NET Summary

Feature Ethereum OP_NET
Signature ECDSA. Schnorr.
Operation Set absolute value. Increase or decrease.
Deadline Unix timestamp. Block number.
Provide deterministic expiration.
Nonce!!!! Query with nonces(address) before signing. Query with nonceOf(address) before signing.