ERC-8464 Agent priority repayment recipient (Agent Repay-First Payees)
Draft · Vaults & DeFi · created 2026-10-20
A standard that normalizes the payee address into which an AI agent's earnings arrive, so that at sweep time, registered creditors are repaid in priority order and only the remaining money is sent to the owner.
Why it is needed
When lending money against an AI agent's earnings as collateral, the safest approach is for repayment to happen automatically as soon as the earnings arrive. However, an agent's earnings today only arrive at an address the agent itself designates, such as the receiving address for x402 payments, the provider address for ERC-8183 tasks, or an ERC-8004 wallet, with nothing defined about how that money is used once it arrives. Even if a lender intercepts the earnings with its own contract, that contract can only be trusted by the lender itself, and no one else can check whether that address is already pledged as collateral. Without a common standard, multiple lenders have no way to share a single earnings address with a defined priority order, a newly arriving lender cannot check existing claims already placed on it, and the agent must change the very address it gets paid at every time it switches lenders.
What to implement
event CreditorAdded(address indexed creditor, uint16 maxShareBps);: Emitted when a new creditor is registered and its share (bps) is set.event CreditorRemoved(address indexed creditor);: Emitted when a creditor is removed from the list.event BeneficiarySet(address indexed beneficiary);: Emitted when the owner designates a new beneficiary address.event Swept(address indexed token, uint256 toCreditors, uint256 forwarded);: Announces, after settlement is complete, the total amount that went to creditors and the amount delivered to the beneficiary.event Reserved(address indexed creditor, address indexed token, uint256 amount);: Announces the new reserve amount when a given creditor's per-token reserve changes.function identityRegistry() external view returns (address);: Returns the address of the ERC-721 registry where the agent identity this recipient belongs to is registered.function agentId() external view returns (uint256);: Returns the token ID of the agent identity this recipient represents.function beneficiary() external view returns (address);: Returns the address that receives the money remaining after creditors have taken their share.function creditors() external view returns (address[] memory);: Returns the registered creditors in priority order (the order in which they were registered).function maxShareBps(address creditor) external view returns (uint16);: Returns, in bps, the maximum share that creditor can receive at each settlement.function reserved(address creditor, address token) external view returns (uint256);: Returns the reserve that creditor has accumulated but not yet taken for a given token.function addCreditor(address creditor, uint16 maxShareBps) external;: The owner registers a new creditor at the lowest priority.function removeCreditor(address creditor) external;: The creditor itself, or the owner if no claim remains, removes the creditor.function setBeneficiary(address beneficiary) external;: The owner designates the address that will receive the remaining earnings.function sweep(address token) external returns (uint256 toCreditors, uint256 forwarded);: Anyone can call this to execute settlement, distributing the accumulated tokens to creditors and the beneficiary.function amountOwed(uint256 agentId, address token) external view returns (uint256);: The creditor itself reports the amount it can currently receive from that agent.function hasClaim(uint256 agentId) external view returns (bool);: Reports whether the creditor still has an outstanding claim against that agent.function collect(uint256 agentId, address token, uint256 amount) external returns (uint256 applied);: Processes and returns the amount that the creditor actually took from what the recipient provided and applied to the debt.event OperatorSet(address indexed operator);: Emitted when the owner designates an operator to submit tasks on its behalf.function operator() external view returns (address);: Returns the operator address currently designated by the owner.function setOperator(address operator) external;: The owner designates an operator to submit tasks on its behalf.function setJobBudget(address commerce, uint256 jobId, uint256 amount, bytes calldata optParams) external;: The owner or operator sets the budget for an ERC-8183 task.function submitJob(address commerce, uint256 jobId, bytes32 deliverable, bytes calldata optParams) external;: The owner or operator submits the deliverable for an ERC-8183 task.event RevenueFromPayee(address indexed payee, address indexed asset, uint256 amount);: Announces the amount that arrived from the recipient into the token and was credited as a reward.function payee() external view returns (address);: Returns the recipient address of the agent for which this token is designated as beneficiary.function syncFromPayee(address asset) external returns (uint256 booked);: Credits a new asset arriving from the recipient into the token as a holder reward and returns that amount.
In depth
The relationship between the payee and the identity
identityRegistry() and agentId() do not change after deployment. The owner is, at the time of each call, the address that the registry's ownerOf(agentId()) points to. beneficiary() returns the address the current owner set via setBeneficiary if one has been set; if none has been set or the owner has changed, it returns the current owner. If the identity is burned and ownerOf reverts, it returns the last address that was set (regardless of who set it), or the zero address if none was ever set, and does not revert. The payee does not accept ether force-sent without a call, and pays out token balances only through sweep.
Adding and removing creditors
addCreditor can only be called by the owner, and rejects an already registered address, the zero address, or a maxShareBps that is 0 or exceeds 10000. A new creditor is always added after the existing creditors, at the lowest seniority. removeCreditor always succeeds when called by the creditor itself, but when called by the owner it fails if that creditor's hasClaim() is true or reverts. Once removed, any reserve that creditor had accumulated across all tokens disappears (it reverts to the distributable amount at the next settlement), and if re-added, it starts with no reserve. A creditor's share and seniority do not change while it remains registered.
The settlement algorithm of sweep
sweep(token) first reads each creditor's amountOwed and, if its reserve exceeds that, reduces the reserve. The distributable amount B is the payee's token balance minus the reduced reserves. Going in order of seniority, for each creditor the amount to pay first (give) is set to the minimum of 'the amount owed minus the reserve', 'B multiplied by its share (bps)', and 'the remaining B'; it then approves an offer equal to the reserve plus give, calls collect, resets the approval back to 0, and finally counts only what was actually pulled as paid, adding the remainder back to the reserve. After processing all creditors, the remaining B is sent to the beneficiary, but if the beneficiary is the zero address or the transfer fails, it stays in the payee.
How the creditor interface behaves
amountOwed is a value the creditor self-reports as the amount it can receive right now; for a loan that only accepts full repayment, it returns the amount that pays off the entire debt. hasClaim is true whenever a claim remains outstanding, whether or not the repayment deadline has passed. collect pulls at most amount from the payee, applies it to the debt, and returns only the amount actually applied; it must not pull funds in advance that cannot be applied right now, and that portion stays in the payee's reserve to be offered again at the next settlement.
Acting as an ERC-8183 job provider (optional)
ERC-8183 pays the escrow to the provider once a job is completed, and accepts result submission only from the provider. If the payee also acts as this provider, the owner or operator calls setJobBudget and submitJob, which in turn call the commerce contract's setBudget and submit respectively. The operator is designated by the owner via setOperator, and operator privileges disappear together when the owner changes. The payee must not make any other call on behalf of the owner or operator beyond these two, so job payment arriving is just an ordinary token transfer, and is afterward handled the same as any other revenue through sweep.
Distributing residual revenue to ERC-7254 token holders (optional)
If the owner designates a token implementing ERC-7254 and IHoldersAfterCreditors as the beneficiary, the money left over after all creditors have been paid is passed to that token. This token cannot become a creditor; anyone can call syncFromPayee, which accrues as rewards the amount of newly arrived assets in the token, emitting RevenueFromPayee on accrual. Attempting to sync an unregistered asset fails, and nothing accrues when total supply is 0. This token's recognition as beneficiary is also valid only while the owner who designated it still holds the identity.
Design rationale: why the reserve stays inside the payee
A loan that accepts only full repayment does not reduce the debt if it accepts a partial payment, so if sweep handed that portion to the owner, it could never be repaid. That is why the portion not taken stays as a reserve inside the payee contract rather than with the creditor, is offered again at every settlement, and is repaid in full the moment the accumulated amount covers the entire debt. The creditor's seniority is also fixed by registration order, so the owner cannot later reorder it to push out an existing lender, and because ERC-8004's agentWallet requires a signature from the new wallet, a payee that does not verify signatures cannot be used in that role.
Proposal status
This standard is in Draft status as of October 2026, and its details may still change or adoption may stall during community discussion and review.
Things to watch out for
- The revenue address can change at any time: An agent can change the address it discloses to payers to a new one at any time, diverting future revenue away from the payee. A creditor must check each time that the address the agent publishes on-chain actually points to the payee, and must treat any revenue that does not as unsecured.
- The creditor self-reports its own figures: If a creditor reports amountOwed higher than the actual value, it can take more than its share or accumulate it in reserve at every settlement, and the owner cannot stop this until that creditor lowers its own report or leaves. The owner should register only lending institutions that actually lent money as creditors.
- The reserve may fall short of the outstanding debt: A loan that only accepts full repayment can have its repayment delayed, staying in reserve until enough of the agent's revenue has come in to cover its share. The lending institution should set its share and maturity at a level where the agent's expected revenue can cover the debt before the deadline.
- Reentrancy risk from creditor calls: Since a creditor is an external contract, the payee must approve exactly the offer amount, reset the approval to 0 after each call, use limited gas on each creditor call, and prevent reentrancy into sweep, addCreditor, and removeCreditor.
- Caution on ownership transfer and burning: When the identity is traded, control over the payee, creditors, and reserve transfers along with it, and the beneficiary set by the previous owner loses effect, so a buyer should check creditors() and each creditor's hasClaim and reserved values beforehand. Once the identity is burned, no one can change the settings, so an owner who can burn it should clear the beneficiary to the zero address or similar beforehand.