ERC-7794 Cross-chain grant registry (Grant Registry)
Draft · Other · created 2024-10-22
Enables tracking of grant registrations, participants, milestones, and disbursement status across multiple blockchains using standardized events in a single registry contract.
Why it is needed
Each grant program has its own interface and management approach, forcing both funders and grantees to learn different procedures, and making it difficult to aggregate data for grants spanning multiple chains in one place. Milestone progress and disbursement status cannot be recorded in a standardized way, reducing transparency and making it hard to compare programs or analyze outcomes. Even when a grantee team's composition changes, there is no way to record this consistently on-chain, making it difficult for external protocols to reliably use grant data.
What to implement
event GranteeAdded(bytes32 indexed grantId, address indexed grantee);: Emitted when a new grantee is added to a grant.event GranteeRemoved(bytes32 indexed grantId, address indexed grantee);: Emitted when a grantee is removed from a grant.event StartDateSet(bytes32 indexed grantId, uint256 startDate);: Emitted when a grant's start date is set.event MilestoneDateAdded(bytes32 indexed grantId, uint256 milestoneDate);: Emitted when a new milestone date is added to a grant.event MilestoneDateRemoved(bytes32 indexed grantId, uint256 milestoneDate);: Emitted when a milestone date is removed from a grant.event DisbursementRemoved(bytes32 indexed grantId, uint256 milestoneDate);: Emitted when disbursement information for a specific milestone is deleted.event ExternalLinkAdded(bytes32 indexed grantId, string link);: Emitted when an external link, such as an off-chain document, is added to a grant.event ExternalLinkRemoved(bytes32 indexed grantId, string link);: Emitted when an external link is removed from a grant.function transferOwnership(bytes32 grantId, address newGrantManager) external;: Transfers management authority over the grant to a new grantManager address.function addGrantee(bytes32 grantId, address grantee) external;: Adds a new grantee address to the grant.function removeGrantee(bytes32 grantId, address grantee) external;: Removes a grantee address from the grant.function setStartDate(bytes32 grantId, uint256 startDate) external;: Sets the start date of the grant.function addMilestoneDate(bytes32 grantId, uint256 milestoneDate) external;: Adds a new milestone date to the grant.function removeMilestoneDate(bytes32 grantId, uint256 milestoneDate) external;: Removes a milestone date from the grant.function removeDisbursement(bytes32 grantId, uint256 milestoneDate) external;: Deletes the disbursement information for a specific milestone.function addExternalLink(bytes32 grantId, string memory link) external;: Adds an external link related to the grant, such as an off-chain document URL.function removeExternalLink(bytes32 grantId, uint256 index) external;: Removes the external link specified by an array index.function getGrant(bytes32 grantId) external view returns (Grant memory);: Retrieves the grant's immutable information containing the id, chainid, and community label.function getGrantManager(bytes32 grantId) external view returns (address);: Retrieves the address of the current grant manager.
In depth
Separation of identifiers from data structures
A grant is divided into immutable identifying information consisting of id, chainid, and community, and mutable information consisting of grantManager, grantees, milestones, disbursements, and external links. grantId is generated by hashing id, chainid, community, and block.timestamp with keccak256, so it is uniquely determined at each registration. community cannot be an empty string, grantManager cannot be the zero address, and an already-registered grantId cannot be registered again (GrantAlreadyRegistered).
Grant manager permission model
transferOwnership, addGrantee, removeGrantee, setStartDate, addMilestoneDate, removeMilestoneDate, addDisbursement, removeDisbursement, setDisbursementStatus, addExternalLink, and removeExternalLink can all only be called by the current grantManager. The reference implementation's _requireManager reverts with InvalidGrantManager if msg.sender differs from grantManager. Ownership can be transferred to another address via transferOwnership, and the new address also cannot be the zero address.
Grantee management
grantees is managed as an EnumerableSet.AddressSet, which prevents duplicate additions and supports listing and removal. Calling addGrantee again on an already-added address triggers GranteeAlreadyAdded, and calling removeGrantee on a nonexistent address triggers GranteeNotFound. The zero address cannot be added as a grantee.
Milestones and start date
setStartDate records the grant's start date, and addMilestoneDate and removeMilestoneDate add or remove milestone dates in an EnumerableSet.UintSet. Adding a date that already exists triggers MilestoneDateAlreadyAdded, and removing or referencing a date that does not exist triggers MilestoneDateNotFound. getMilestonesDates returns the start date together with the array of milestone dates.
Per-milestone disbursements
addDisbursement records fundingToken and fundingAmount for a specific milestoneDate, overwriting any existing values. The milestoneDate must already exist on the grant before calling it; otherwise MilestoneDateNotFound is triggered. setDisbursementStatus updates only the isDisbursed flag to indicate whether the disbursement has actually been made, and removeDisbursement deletes the disbursement data for that milestone.
Off-chain integration via external links
addExternalLink lets you add a grant-related URL to a string array, and an empty string is rejected with InvalidExternalLink. removeExternalLink removes a link by array index; the reference implementation is built by moving the last element into that index and popping the array, so link order is not preserved. If the index is out of the array's bounds, InvalidIndex is triggered.
Modularity with off-chain disbursement programs
According to the Rationale, not all grant programs disburse funds on-chain, so the design records only the disbursement status (isDisbursed) in the registry while leaving the actual disbursement to be handled via external links or off-chain procedures. This allows both on-chain and off-chain disbursement programs to track status in the same registry.
Standard status
This ERC is currently in Draft status, a proposal still undergoing community review and change.