ERC-8316 Programmable Settlement Lock (Programmable Settlement Locks)
Draft · Vaults & DeFi · created 2026-06-25
A common interface that lets contracts using different asset models, such as transparent tokens versus privacy-preserving tokens, coordinate atomic settlement through a single lock with pre-committed spend and cancel paths.
Why it is needed
Contracts increasingly need to store and coordinate value across systems that use a growing variety of visibility and verification models. Unlike transparent tokens such as ERC-20, which expose public balances and transfer history directly, privacy-preserving assets like shielded tokens leave only opaque evidence such as commitments, proofs, encrypted values, and nullifiers. Existing settlement patterns such as approvals, escrow, and hashed timelocks (HTLC) rely on the assumption that state is public and ownership can be transferred, so they do not fit well on the leg of a settlement where shielded balances, private recipients, encrypted amounts, or off-chain verification are involved. Custom coordination logic can be built per contract type, but without a standard it is hard to reason about finality guarantees or build general-purpose solutions that span multiple contract types.
What to implement
event LockCreated( bytes32 indexed lockId, address indexed owner, address indexed spender, bytes32 spendCommitment, bytes32 cancelCommitment, bytes data );: Emitted when a new lock is created via a createLock call, recording the lockId, owner, spender, and the initial spend and cancel commitments.event LockUpdated( bytes32 indexed lockId, address indexed owner, bytes32 spendCommitment, bytes32 cancelCommitment, bytes data );: Emitted when commitments are updated via updateLock, recording the changed spend and cancel commitments.event LockDelegated( bytes32 indexed lockId, address indexed previousSpender, address indexed newSpender, bytes data );: Emitted when the current spender changes via delegateLock, recording the previous spender and the new spender.event LockSpent( bytes32 indexed lockId, address indexed spender, bytes data );: Emitted when spendLock succeeds and the lock is spent and deactivated.event LockCancelled( bytes32 indexed lockId, address indexed spender, bytes data );: Emitted when cancelLock succeeds and the lock is cancelled and deactivated.function createLock( bytes calldata createArgs, bytes32 spendCommitment, bytes32 cancelCommitment, bytes calldata data ) external returns (bytes32 lockId);: Creates a new lock, returning a unique lockId, setting the caller as owner and initial spender, and initializing the spend and cancel commitments.function updateLock( bytes32 lockId, bytes calldata updateArgs, bytes32 spendCommitment, bytes32 cancelCommitment, bytes calldata data ) external;: Updates the spend and cancel commitments of an existing lock only when the spender is the same as the owner.function delegateLock( bytes32 lockId, bytes calldata delegateArgs, address newSpender, bytes calldata data ) external;: Lets the current spender hand over control of the lock to another address, designating it as the new spender.function spendLock( bytes32 lockId, bytes calldata spendArgs, bytes calldata data ) external;: Lets the current spender spend and deactivate the lock after spendArgs is validated against spendCommitment.function cancelLock( bytes32 lockId, bytes calldata cancelArgs, bytes calldata data ) external;: Lets the current spender cancel and deactivate the lock after cancelArgs is validated against cancelCommitment.function getLock(bytes32 lockId) external view returns (LockInfo memory info);: Queries the information (owner, spender, commitments) of an active lock, and reverts if the lock is inactive.function isLockActive(bytes32 lockId) external view returns (bool active);: Returns whether the lock for the given lockId is active.
In depth
Lock lifecycle and state
A lock is either active or inactive. The active state further splits into two cases: in the undelegated state the owner directly controls the lock and can update, spend, cancel, or delegate it, while in the delegated state only the spender, not the owner, can spend, cancel, or re-delegate, and spendCommitment and cancelCommitment can no longer be changed. A lock that does not exist, or has already been spent or cancelled, is inactive, and an inactive lock cannot be spent, cancelled, updated, or delegated. createLock must create a lock that is active, spendLock or cancelLock must transition the lock to inactive on success, and once a lock becomes inactive it can never become active again.
Authority model: owner and spender
Each lock has an owner, the creator of the lock, and a spender, the address currently authorized to control the lock. At creation, owner == spender == msg.sender, and while the lock is active there is always exactly one current spender. Only the current spender can delegate via delegateLock, spend via spendLock, or cancel via cancelLock.
Commitment immutability guarantee
A lock's execution conditions are defined by spendCommitment and cancelCommitment. These commitments can only be updated while spender == owner, and cannot be modified once spender != owner. In other words, from the moment control is delegated to a spender other than the owner, neither the owner nor the delegated spender can change the lock's structure, and updates become possible again only once authority returns to the owner.
Execution guarantee: the current spender must not be blocked
If a lock is active and msg.sender is the current spender, an implementation must not block the success of spendLock or cancelLock beyond validating the provided arguments against the relevant commitment. Expiration, timeouts, owner or admin overrides, pausing, cancellation rights, upgrades, or changes to verification policy must not be imposed as additional conditions unless they are uniquely bound to spendCommitment or cancelCommitment and evaluated only as part of validating that commitment. Execution conditions must be captured in the lock's commitments, or enforced externally by the current spender, which may be a coordination smart contract.
Requirements for creation, update, and delegation
createLock must create a new lock with a unique lockId, set owner and spender to msg.sender, initialize it with the given commitments, and emit LockCreated. updateLock must revert with LockNotActive if the lock is inactive, with LockUnauthorized if the caller is not the current spender, and with LockImmutable if spender != owner; if these conditions are satisfied, it updates the commitments and emits LockUpdated. delegateLock must revert under the same conditions, or with LockInvalidSpender if newSpender is the zero address; on success it replaces the current spender and emits LockDelegated. After delegation, the previous spender loses all authority and the new spender becomes the sole current spender.
Spend and cancel: two finality paths
spendLock must revert with LockNotActive if the lock is inactive and with LockUnauthorized if the caller is not the current spender; if the lock is active, the caller is the current spender, and the provided spendArgs satisfy implementation-specific validation against spendCommitment, it must succeed, transition the lock to inactive, and emit LockSpent. cancelLock follows the same structure, validating cancelArgs against cancelCommitment, and on success deactivates the lock and emits LockCancelled. Both paths finalize the lock into a state where it cannot be reused.
View functions and implementation-specific details
getLock must return the active lock information for a lockId, and revert with LockNotActive if it is inactive. isLockActive must return true only if the lock is active. By contrast, the structure and encoding of createArgs, updateArgs, delegateArgs, spendArgs, and cancelArgs, how spendCommitment and cancelCommitment are constructed, the logic for validating execution arguments against commitments, and the meaning of the underlying operation a lock represents are all implementation-specific details that each implementation must define.
A proposal that has not yet been finalized
This standard is currently in Draft status, and its provisions may change or the proposal may be abandoned based on further discussion or implementation experience.
Things to watch out for
- Separation of execution model and coordination responsibility: This standard provides only lock-level finality guarantees, not end-to-end guarantees for the coordination protocol as a whole. Implementations must not use expiration, timeouts, cancellation rights, upgrades, pausing, or admin control that are not bound to the relevant commitments to block valid finalization of an active lock, and coordination rules that are not part of the lock's commitments must be enforced by the current spender, which may be a coordination smart contract. The safety of settlement across multiple locks or multiple systems depends on the correctness of that coordination contract.
- Commitment and metadata exposure: Implementations must validate spendArgs and cancelArgs against spendCommitment and cancelCommitment respectively. A commitment must uniquely bind the context needed to prevent replay, substitution, or misuse, such as the implementing contract, chain identifier, recipient, amount, proof statement, and nullifier. Implementers should review whether createArgs, updateArgs, delegateArgs, spendArgs, cancelArgs, and data expose sensitive information, so that transaction observation alone cannot enable replay, front-running, preemption, or exposure of private settlement information.
- Risks of delegation: Delegation hands full control of the lock to the designated spender. Once delegated to a spender other than the owner, the owner can no longer modify the spend or cancel commitments and cannot block valid finalization by the current spender. Delegating to an incorrect, malicious, or incompatible address can result in irreversible loss of control. If the current spender is a coordination smart contract, its logic determines when the lock is spent, cancelled, or re-delegated.
- General security practices for implementers: Functions that interact with external contracts, such as spendLock and cancelLock, should apply reentrancy protections and update state first, such as marking the lock inactive before making external calls. lockId must be generated so as not to collide with existing active locks; it is recommended to derive it deterministically from immutable inputs where possible, with sufficient domain separation to prevent reuse across contracts, chains, or deployments. Upgradeable or admin-controlled implementations must not use privileged actions, such as upgrades, pausing, or cancellation rights that are not bound to the relevant commitments, to block valid finalization of an active lock.