Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
ERC7994 proposes a mechanism for combining multiple unlock conditions on ERC20 tokens so that recipients can claim the tokens only when every condition is met.
This article walks through the proposal and discussion linked below.
I have also covered various EIPs, BIPs, SLIPs, CAIPs, ENSIPs, RFCs, and ACPs.
Overview
ERC7994 extends the Purpose Bound Money (PBM) concept introduced by ERC7291 to ERC20 tokens, enabling programmable transfer restrictions by combining multiple unlock conditions.
ERC7291 introduced an ERC1155-based mechanism for restricting how tokens can be used. ERC7994 generalizes that concept to support simultaneous conditions such as time restrictions, identity verification, and restrictions on permitted uses.
The sender locks the tokens, and the recipient can withdraw them through the claim function only when all conditions are met.
An expiry can also be specified, after which the tokens can no longer be claimed if the conditions have not been met.
For more on ERC7291, see the following article.
[EIP7291] Purpose Bound Money (PBM): Payments That Execute When Conditions Are Met
For an introduction to ERC20, see the following article.
[ERC20] ERC20 Explained from the Ground Up
Motivation
ERC7291 introduced a mechanism for restricting how tokens are used, but many real-world use cases require several conditions to be satisfied at once.
Scholarship Disbursement
Consider an educational institution distributing scholarship tokens to students. It might want tokens to become usable only after verifying that a recipient has completed KYC, is under 25, and is enrolled at a university. A single condition could allow someone who passed KYC but exceeds the age limit to receive tokens. Combining conditions enables more precise control over who qualifies.
Humanitarian Aid from NGOs
An NGO distributing aid tokens intended exclusively for food and medicine might also want to impose a time restriction, preventing their use before a specified unlock date. ERC7994 allows these combined conditions to be configured within one binding.
Gradual Unlocking of Payroll Tokens
A company distributing payroll tokens to employees might want to combine a monthly unlocking schedule with a restriction limiting payments to allowlisted service providers, such as banks or healthcare institutions. The intended design would allow tokens to unlock gradually while ensuring that wages are used only for their designated purposes.
The Proposed Solution
By layering multiple unlock conditions on ERC20 tokens, ERC7994 can support a wide range of use cases, including compliance-oriented grants, regulated payments, and conditional incentive programs.
Conditions are defined as an array of UnlockCondition structs, and condition checker contracts are registered as plugins, making it straightforward to add new condition types.
Combining expiry times with unique binding IDs provides a flexible mechanism for conditional transfers with security controls.
Specification
An ERC7994 implementation must implement the IPurposeBoundERC20 interface.
This interface defines functions for creating, verifying, and claiming conditional transfers (purpose bindings).
Interface Definition
pragma solidity 0.8.23;
interface IPurposeBoundERC20 {
struct UnlockCondition {
bytes32 conditionType; // e.g., "TIME", "KYC", "WHITELIST"
bytes conditionData; // e.g., timestamp, Merkle root, etc.
}
function bindPurpose(
address recipient,
uint256 amount,
UnlockCondition[] calldata conditions,
uint256 expiry
) external returns (bytes32 bindingId);
function claim(bytes32 bindingId) external;
function isUnlocked(bytes32 bindingId) external view returns (bool);
}The interface consists of four elements: a struct, a binding creation function, a claim function, and a condition checking function.
The following sequence diagram illustrates the flow from creating a binding to claiming tokens. It retains the Japanese labels from the original article.
sequenceDiagram
participant Sender as 送信者
participant Contract as PurposeBoundERC20
participant Checker as ConditionChecker
participant Recipient as 受取人
Sender->>Contract: bindPurpose(recipient, amount, conditions, expiry)
Contract->>Contract: トークンをロック (_transfer)
Contract-->>Sender: bindingId
Recipient->>Contract: claim(bindingId)
Contract->>Contract: isUnlocked(bindingId)
loop 各条件をチェック
Contract->>Checker: isConditionMet(recipient, conditionData)
Checker-->>Contract: true/false
end
Contract->>Recipient: トークン転送
When a sender calls bindPurpose, the specified amount of tokens is locked in the contract and a unique bindingId is returned.
When the recipient calls claim, the contract runs isUnlocked internally and queries each registered condition checker through isConditionMet in sequence.
The locked tokens are transferred to the recipient only if every condition returns true.
Each element is described in detail below.
Struct
UnlockCondition
struct UnlockCondition {
bytes32 conditionType; // e.g., "TIME", "KYC", "WHITELIST"
bytes conditionData; // e.g., timestamp, Merkle root, etc.
}This struct represents an individual condition that must be met to unlock tokens.
A pair of conditionType and conditionData defines one condition. When creating a binding, the caller can specify multiple conditions as an array of these structs.
conditionType is a 32-byte identifier specifying the type of condition.
"TIME" denotes a time-based unlock condition, while "KYC" denotes completion of identity verification.
"WHITELIST" is used when allowlist membership is required.
The identifier is used to route requests to on-chain condition checker contracts.
conditionData contains the specific data needed to evaluate the condition.
For example, a "TIME" condition encodes the Unix timestamp at which unlocking becomes possible, while a "KYC" condition might encode a Merkle root or off-chain verification data.
Because it uses the bytes type, it can hold data of arbitrary length and accommodate different data structures for different condition types.
| Field | Type | Description |
|---|---|---|
conditionType |
bytes32 |
Identifier for the condition type, such as "TIME", "KYC", or "WHITELIST". |
conditionData |
bytes |
Data required to evaluate the condition, such as an encoded timestamp or Merkle root. |
Functions
bindPurpose
function bindPurpose(
address recipient,
uint256 amount,
UnlockCondition[] calldata conditions,
uint256 expiry
) external returns (bytes32 bindingId);This function creates a binding that conditionally locks tokens for a specified recipient.
Calling the function transfers amount tokens from the sender's balance to the contract itself, locking them.
The recipient (recipient) cannot withdraw the tokens until all conditions are satisfied.
An expiry can be specified in expiry as a Unix timestamp. After that time, the binding becomes invalid and the tokens can no longer be claimed.
An expiry of zero means the binding does not expire.
When a binding is created successfully, a unique bindingId is returned.
The ID is generated by hashing the sender, recipient, amount, conditions, expiry, and block timestamp, so identical parameters at different creation times can produce different IDs.
| Parameter | Type | Description |
|---|---|---|
recipient |
address |
Address of the token recipient. The zero address is not permitted. |
amount |
uint256 |
Amount of tokens to lock. Must be greater than zero. |
conditions |
UnlockCondition[] calldata |
Array of unlock conditions. All conditions must be satisfied before a claim is possible. |
expiry |
uint256 |
Expiry as a Unix timestamp. Zero means no expiry. |
- Return value
bytes32 bindingId — unique identifier of the newly created binding.
claim
function claim(bytes32 bindingId) external;This function allows the recipient to withdraw the bound tokens.
The recipient calls it to claim the tokens associated with a particular bindingId.
The function checks that the caller (msg.sender) matches the recipient recorded in the binding, that the binding has not already been claimed, and that all unlock conditions are met. Only if every check passes are the tokens transferred from the contract to the recipient.
If any condition is not satisfied, the transaction reverts.
| Parameter | Type | Description |
|---|---|---|
bindingId |
bytes32 |
ID of the binding to claim. |
isUnlocked
function isUnlocked(bytes32 bindingId) external view returns (bool);This function checks whether every unlock condition associated with a binding has been satisfied.
It evaluates all the conditions on the specified binding in sequence and returns true only if all of them are met.
For bindings that have already been claimed or have expired, it returns false.
As a view function, it does not modify state and can be queried off-chain without paying transaction gas to check whether the conditions are satisfied.
| Parameter | Type | Description |
|---|---|---|
bindingId |
bytes32 |
ID of the binding to check. |
- Return value
bool — true if all conditions are met, otherwise false.
Additional Considerations
Flexibility
Unlock conditions are designed to be modular and extensible.
A new condition type can be added by defining a conditionType and registering the corresponding condition checker contract.
The modular design is intended to allow the system to be extended without affecting existing bindings or other condition checkers.
Composability
Implementing condition checkers as plugins allows integration into a variety of use cases, including DAOs, payroll management, education, and compliance-oriented tokens.
Different business logic can be achieved simply by changing the combination of condition checkers while retaining the same IPurposeBoundERC20 interface, improving contract reusability.
Off-Chain Verification
When results from off-chain verification, such as KYC, are used on-chain, cryptographic proofs such as Merkle proofs are used to protect data integrity. Supporting off-chain verification with on-chain proofs enables condition evaluation without having to trust the data supplied directly by the claimant.
Reference Implementation
The reference implementation provides a concrete example of the IPurposeBoundERC20 interface.
It includes a plugin architecture for condition checkers and an example of a time-based condition checker.
Condition Checker Interface
interface IConditionChecker {
function isConditionMet(address recipient, bytes calldata conditionData) external view returns (bool);
}This interface allows evaluation logic for each condition to be implemented in an external contract.
It accepts recipient (the recipient's address) and conditionData (condition-specific data), returning true if the condition is met.
Different contracts implement this interface for different condition types, such as "TIME", "KYC", and "WHITELIST".
Main Contract
// SPDX-License-Identifier: CC0-1.0
pragma solidity 0.8.23;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./IPurposeBoundERC20.sol";
import "./IConditionChecker.sol";
contract PurposeBoundERC20 is ERC20, IPurposeBoundERC20 {
struct StoredBinding {
address recipient;
uint256 amount;
UnlockCondition[] conditions;
bool claimed;
uint256 expiry;
}
mapping(bytes32 => address) public conditionResolvers;
mapping(bytes32 => StoredBinding) public boundTransfers;
event PurposeBound(bytes32 indexed bindingId, address indexed from, address indexed to, uint256 amount);
event Claimed(bytes32 indexed bindingId, address indexed recipient);
constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) {
_mint(msg.sender, 1_000_000 ether);
}
function setConditionResolver(bytes32 conditionType, address checker) external {
conditionResolvers[conditionType] = checker;
}
}The StoredBinding struct is an internal data structure used to store all binding information on-chain.
It holds recipient (the recipient), amount (the locked amount), conditions (the array of unlock conditions), claimed (the claim status flag), and expiry (the expiry time).
The conditionResolvers mapping registers the address of the corresponding condition checker contract for each conditionType.
An administrator can register or update condition checkers using the setConditionResolver function.
For production use, access control such as onlyOwner or AccessControl is recommended.
The boundTransfers mapping stores binding information keyed by bindingId.
The PurposeBound event is emitted when a binding is created, and the Claimed event when a claim is completed.
These events allow off-chain systems to track binding creation and claims in real time.
Implementing bindPurpose
function bindPurpose(
address recipient,
uint256 amount,
UnlockCondition[] calldata conditions,
uint256 expiry
) external override returns (bytes32 bindingId) {
require(recipient != address(0), "Invalid recipient");
require(amount > 0, "Invalid amount");
bindingId = keccak256(abi.encodePacked(msg.sender, recipient, amount, conditions, expiry, block.timestamp));
StoredBinding storage stored = boundTransfers[bindingId];
require(stored.amount == 0, "Binding exists");
_transfer(msg.sender, address(this), amount);
for (uint i = 0; i < conditions.length; i++) {
stored.conditions.push(conditions[i]);
}
stored.recipient = recipient;
stored.amount = amount;
stored.expiry = expiry;
emit PurposeBound(bindingId, msg.sender, recipient, amount);
}The binding creation implementation first validates that the recipient is not the zero address and that the amount is greater than zero.
The bindingId is generated using keccak256 over the encoded sender, recipient, amount, conditions, expiry, and current block timestamp.
Including block.timestamp is intended to prevent ID collisions when identical parameters are used at different times.
If the same bindingId already exists, the call reverts.
The _transfer function moves tokens from the sender's balance to the contract itself, locking them.
The condition array is then copied into storage, the recipient, amount, and expiry are set, and the PurposeBound event is emitted.
Implementing isUnlocked
function isUnlocked(bytes32 bindingId) public view override returns (bool) {
StoredBinding storage binding = boundTransfers[bindingId];
if (binding.claimed) return false;
if (binding.expiry > 0 && block.timestamp > binding.expiry) return false;
for (uint i = 0; i < binding.conditions.length; i++) {
UnlockCondition storage cond = binding.conditions[i];
address checker = conditionResolvers[cond.conditionType];
require(checker != address(0), "Checker not set");
if (!IConditionChecker(checker).isConditionMet(binding.recipient, cond.conditionData)) {
return false;
}
}
return true;
}Checking the unlock state involves three stages.
First, if the binding has already been claimed, the function returns false.
Second, if an expiry is configured (expiry > 0) and the current time is past that expiry, it returns false.
Finally, it checks every condition in sequence, retrieves the corresponding checker from the conditionResolvers mapping, and calls isConditionMet.
If the checker is not registered (its address is zero), the call reverts. If any condition is not met, it returns false.
It returns true only after all checks have passed.
Implementing claim
function claim(bytes32 bindingId) external override {
StoredBinding storage binding = boundTransfers[bindingId];
require(msg.sender == binding.recipient, "Not recipient");
require(!binding.claimed, "Already claimed");
require(isUnlocked(bindingId), "Conditions not met");
binding.claimed = true;
_transfer(address(this), binding.recipient, binding.amount);
emit Claimed(bindingId, binding.recipient);
}The claim process verifies three things: that the caller matches the recipient recorded in the binding, that the binding has not already been claimed, and that isUnlocked returns true.
After all checks pass, the function sets the claimed flag to true and then transfers tokens from the contract to the recipient.
Setting the claimed flag before transferring tokens reduces the risk of reentrancy.
Time-Based Condition Checker
contract TimeConditionChecker is IConditionChecker {
function isConditionMet(address, bytes calldata conditionData) external view override returns (bool) {
uint256 unlockTime = abi.decode(conditionData, (uint256));
return block.timestamp >= unlockTime;
}
}This is an example implementation of a condition checker for the "TIME" condition.
It decodes the unlock time (a Unix timestamp) from conditionData and returns true if the current block timestamp is at or after that time.
The recipient argument is ignored because a time condition does not use it.
With condition checkers implemented as plugins, checkers for KYC verification, allowlist membership, geographic restrictions, and other conditions can be developed independently and integrated into the system.
Compatibility
ERC7994 is designed as an extension of ERC20 and does not change the behavior of existing ERC20 tokens. It applies the PBM concept introduced in ERC7291 to ERC20-compatible tokens and can be used independently of the ERC1155-based ERC7291.
Security
Security of Condition Checking
Condition checking mechanisms involving Merkle roots, timestamps, and similar data must be implemented to resist tampering. In particular, when off-chain data such as KYC results is verified on-chain, cryptographic proofs (such as Merkle proofs) should be used to establish the integrity of the data.
Atomic Validation in claim
The claim function must verify all conditions atomically within a single transaction.
If state changes between condition checking and token transfer, unintended token outflows may occur, so validation and execution should be treated as one indivisible operation.
Replay Protection
A unique bindingId and an expiry field should be used to mitigate replay attacks.
The design derives the bindingId from the binding creation parameters and block timestamp to distinguish bindings, while the claimed flag prevents duplicate claims.
Specifying an expiry also prevents expired bindings from being used improperly.
References
Conclusion
This article covered how ERC7994 enables ERC20 tokens with multiple unlock conditions.
If you have questions, feel free to reach out via Twitter DM.
You can also find my work on the following platforms.




