You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This HIP extends HIP-756 by allowing smart contracts to utilize the Hedera
24
-
Schedule Service (HSS) for any possible smart contract call.
23
+
This HIP proposes a Hedera Smart Contract Service (HSCS) system contract function that allows a smart contract to determine whether a Hedera Token Service (HTS) token contains a `customFeeSchedule` and/or a non-empty `customFeeScheduleKey`. This information is critical for smart contracts to safely interact with tokens without risk of unintended token transfers caused by malicious fee schedules.
25
24
26
25
## Motivation
27
-
HIP-755 extended the ability to schedule transactions to the Hedera Smart
28
-
Contract Service. While this is very useful for smart contract calls by
29
-
externally owned accounts (EOAs), it requires off-chain coordination and
30
-
it does not extend to smart contracts calling other smart contracts as the
31
-
origin of the transaction. Furthermore, HIP-755 does not fully support
32
-
regularly scheduled transactions, as the off-chain signatures and message
33
-
submission must be repeated for each transaction.
34
-
35
-
Extending HIP-756 to call contracts in the future would enable recursive
36
-
execution and rescheduling of contract calls, resulting in a 'set it and forget
37
-
it' system by which contract calls can be made at regularly scheduled intervals
38
-
as long as the transaction payer has enough hbar to cover the gas and scheduled
39
-
contract call fee.
26
+
While custom fee schedules are a powerful feature of HTS, they may be exploited maliciously in decentralized applications. If a smart contract accepts an HTS token with a complex or malicious fee schedule, and subsequently performs a token transfer via HAPI or precompile, it may unknowingly incur additional fee payments — including the unauthorized transfer of **other unrelated tokens** held by the contract.
27
+
28
+
This poses a serious threat to dApps and DeFi protocols which hold multiple tokens in their balance map. For example, if a smart contract accepts a token with a fee schedule that references an unrelated token or imposes a high collector fee, any token transfer operation might inadvertently transfer the unrelated token to a third-party address.
29
+
30
+
This HIP enables developers to **proactively reject token associations** that present this threat by allowing contracts to detect `customFeeSchedules` and non-empty `customFeeScheduleKeys`.
40
31
41
32
## Rationale
42
-
This HIP provides the possiblility to have fully on-chain 'cron jobs' regularly
43
-
call smart contracts that to this point have been done manually or through a web
44
-
server.
33
+
This proposal adds support to a `IHederaTokenService.sol` that can be called from smart contracts to query the `customFeeSchedule` and `customFeeScheduleKey` of any HTS token. Any presence of a `customFeeSchedule` or non-empty `customFeeScheduleKey` should be detected and returned.
34
+
The precompile would return the following:
35
+
36
+
- Whether the token has a non-empty `customFeeSchedule`
37
+
- Whether the token has a non-zero `customFeeScheduleKey`
45
38
46
-
## User stories
47
-
1. As a smart contract developer, I want to reduce my technical overhead through
48
-
having a contract call itself or other contracts
39
+
By doing so, developers can build safer and more robust smart contracts that **refuse to interact with unsafe tokens** or alert administrators when unexpected configurations are found.
49
40
50
-
Useful examples for this upgrade could include: rebalancing DeFi positions,
51
-
claiming tokens from vesting contracts at regular intervals, and changing token
52
-
statuses at a predetermined epoch time in the future.
41
+
## User Stories
42
+
1. As a dApp developer, I want to prevent tokens with malicious fee schedules from being deposited into my contract.
43
+
2. As a protocol admin, I want to audit the fee characteristics of incoming tokens.
44
+
3. As a security engineer, I want on-chain detection of potentially exploitable token configurations.
53
45
54
46
## Specification
55
-
The ledger HSCS will utilize the existing HSS but with more generality via
56
-
`IHederaScheduleService.sol`.
57
47
58
-
### HSS System Contract
59
-
The `IHederaScheduleService.sol` interface must be updated to support everything
60
-
needed to run any smart contract call.
48
+
### System Contract Interface
49
+
This HIP introduces a new precompile interface:
50
+
51
+
```solidity
52
+
interface IHederaTokenService {
53
+
function detectCustomFees(address token) external view returns (
No existing features are modified as this only exposes HAPI functionality to smart
68
-
contracts.
69
+
This HIP introduces new functionality via precompile and does not change any existing behavior.
69
70
70
71
## Security Implications
71
-
No additional security concerns
72
+
This precompile is intended to mitigate security risks by enabling better detection of malicious or risky tokens. It does not introduce new risks when implemented correctly.
72
73
73
74
## How to Teach This
74
-
75
+
This HIP should be taught as a safety precompile for developers building DeFi and token-interactive smart contracts. Teaching materials should include:
76
+
• Examples of malicious token configurations
77
+
• Walkthrough of how to reject unsafe tokens using this precompile
78
+
• Integration with existing token gating or access control systems
75
79
76
80
## Reference Implementation
77
-
81
+
TBD. A sample contract using IHederaTokenService.detectCustomFees() can be provided to show how a contract rejects a token if either boolean is true.
78
82
79
83
## Rejected Ideas
80
-
84
+
• Using off-chain detection (not trustless)
85
+
• Whitelisting tokens (not scalable or dynamic)
81
86
82
87
## Open Issues
83
-
88
+
• Should this precompile expose full fee schedule data?
89
+
• Should fallback fee info be included for royalty fees?
84
90
85
91
## References
86
-
1.[HIP-755](https://hips.hedera.com/hip/hip-755)
87
-
2.[HIP-756](https://hips.hedera.com/hip/hip-756)
88
92
89
93
## Copyright/license
90
94
This document is licensed under the Apache License, Version 2.0 —
0 commit comments