ECPIP-2: Standard Hook Fee Estimation Interface #3
Replies: 9 comments 19 replies
-
|
This is a great start! A couple of things we should perhaps consider
|
Beta Was this translation helpful? Give feedback.
-
|
I forgot to add in the spec that if the the hook requires transfer anything else other than ERC20. it is not covered in the spec but instead the info should be provided by the simulation of the wallet app. |
Beta Was this translation helpful? Give feedback.
-
|
the x402 standard has a similar problem; https://github.com/coinbase/x402/tree/main/examples/typescript/servers/advanced For example the description seems sensible, as does the asset additional data (potentially in a different format, as onchain JSON is awkward), so that apps can communicate to the user what is going on
I'm not sure there's enough of a use case for this. How would this be used? You need to pay a specific NFT? By definition they're not interchangeable
A bit unclear atm - is this a cache for all arguments or just the provided ones? what should happen when this expiry has passed? What if there's no price guarantee?
I think |
Beta Was this translation helpful? Give feedback.
-
this is used for edit and comment in the code, perhaps
can rename this to
Would change this to
is missing it's type in this doc
grammar issue
this is wrong - this comment is relevant for the assetAddress not the fee
the msg.sender that
perhaps we should rename to
Is there a reason we're adding this argument here? It's unlikely to be used by the estimation, requires an additional read from contract/implementation by frontends, and if it's actually needed, the function can be defined to get it We should probably also note somewhere that these functions are not reliable to check that a tx will succeed/fail and are meant to solely estimate fees, not necessarily confirm that a transaction will succeed. For example for invalid comment data, these functions may return an estimate but the tx won't succeed.
the description still has remnants of old versions that should be excluded |
Beta Was this translation helpful? Give feedback.
-
|
this is all unused
you're still including this - please remove this and similar |
Beta Was this translation helpful? Give feedback.
-
|
underscore versions of contract calls should match non underscore, for example can you remove the unused stuff like and can you update the PR please? |
Beta Was this translation helpful? Give feedback.
-
|
hi @davidfurlong i think it was a bad move to have so i will remove i will do it that way for now to unblock but let me know if any objection. |
Beta Was this translation helpful? Give feedback.
-
|
Also wondering if there is a mature solution that we can maybe do a symbolic execution of the add comment code then analysis the condition automatically to find out the minimal fee... |
Beta Was this translation helpful? Give feedback.
-
|
typescript example added |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Abstract
This proposal introduces a standard interface for hook contracts to provide fee estimation capabilities, addressing the current challenge of estimating fees required by hooks in the Ethereum Comments Protocol (ECP). The interface allows hook developers to implement predictable fee estimation methods, improving developer experience and reducing complexity for integrators.
Motivation
Current Challenges
Estimating fees required by hooks in ECP is challenging because there is no standard interface for hooks to provide fee estimates. Developers must implement hook-specific fee calculation logic, leading to:
Existing Workaround
The current approach, as documented in the ECP Protocol Fees documentation, requires developers to:
This approach is not scalable and creates significant overhead for developers integrating with multiple hooks.
Terms
IHookinterface and provides custom logic for comment processingIFeeEstimatableHookinterface that returns the fee estimationSpecification
A full proposed implementation can be found here
Interface Definition
Typescript Example (using
viem)The snippet below demonstrates how to call a hook contract directly to estimate the minimum fee required for posting a comment.
Design Rationale
1. Method Signature Alignment
The estimator methods replicate the function signatures of corresponding hook callbacks. This design choice provides:
Advantages:
Trade-offs:
Comments.Commentstruct instead ofComments.CreateComment/Comments.EditCommentauthMethod,createdAt, andupdatedAtfields2. Parameter Considerations
authMethod: Integrators are responsible for providing the correct authentication method enum value. This ensures accurate fee estimation based on the intended authentication mechanism.createdAt/updatedAt: These timestamps are determined on-chain during execution. While integrators cannot provide exact values, they should provide reasonable estimates. For hooks that use these values:3. Delete Comment Exclusion
The interface does not include a
getDeleteCommentFeemethod because ECP is designed to allow users to calldeleteComment()without fees.4. Estimator returns the minimum amount that gates success
We considered returning a range (min/max) to express optional tipping or upper bounds. We could not find compelling, concrete use cases that require a top limit for gating. Therefore, the estimator returns only the lower bound—the minimum fee (or unit amount) that ensures the action succeeds. If a hook wishes to accept more (e.g., tipping), clients may still pass higher values; the hook’s business logic remains unchanged.
Implications for integrators:
commentAddFee/commentEditFeeas the minimum required5. Identify the fee asset via
assetfieldHooks may charge in native currency or in tokens. We add an
assetfield in the estimator return struct to specify the asset:asset == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE: the fee is the native token to the current chain (on Ethereum mainnet this is ETH).This keeps the interface concise and avoids separate enum types. It also matches common EVM patterns.
6. Returning a Struct Instead of a Tuple
We chose to return a struct instead of a tuple for the estimator functions. Since these functions are
view(read-only), gas consumption is not a concern. Using a struct improves clarity and extensibility, making it easier to add or document new fields in the future without breaking readability or forcing developers to rely on positional return values.7. No explicit ERC type enum — rely on ERC-165 detection
We do not return a separate “ERC spec” discriminator. Instead:
asset == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE, the asset is the native token to the current chain.assetaddress for supported interfaces.Implementation Guidelines
Estimator Guidelines
assetto0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeEfor the native token; otherwise use the token contract address.For Hook Developers
BaseHookabstract contract, and provide the estimator functions according toIFeeEstimatableFeeinterface.For Integrators
IFeeEstimatableHookComments.Commentstruct with appropriate valuesBackward Compatibility
This proposal is backward compatible. Existing hooks that do not implement
IFeeEstimatableHookwill continue to function normally.The ECP team will also implement an SDK helper function that provides a best-effort estimation for cases not covered by
IFeeEstimatableHook.Integrators can:
supportsInterface()to detect fee estimation capabilitySecurity Considerations
References
Beta Was this translation helpful? Give feedback.
All reactions