hashgraph / hashgraph/hedera-forking
Feature Request: Add emulation support for Hedera Schedule Service (HSS) at 0x16b
- Dominant language
- Solidity
- Stars
- 3
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
### Problem
## Summary
Currently, `hedera-forking` provides an emulation layer for the **Hedera Token Service (HTS)** at `0x167`, which is extremely useful for fork testing. However, there is no emulation support for the **Hedera Schedule Service (HSS)** at `0x16b`, which means any smart contract that interacts with HSS will hit `EvmError: InvalidFEOpcode` during fork testing — the same problem HTS emulation was introduced to solve.
## Motivation
The HSS system contract (`IHederaScheduleService`), introduced in [HIP-755](https://hips.hedera.com/hip/hip-755) and extended by [HIP-756](https://hips.hedera.com/hip/hip-756), is increasingly used in production smart contracts for:
- **Multi-sig coordination** — scheduling transactions that require async authorization from multiple parties (EOAs and contracts)
- **Scheduled token operations** — e.g., `scheduleNative()` to schedule HTS token creates/updates
- **DAO automation & DeFi workflows** — contracts that rely on `authorizeSchedule()` / `signSchedule()` as part of their logic
Without HSS emulation, developers building contracts that use `0x16b` cannot fork-test against Hedera Testnet or Mainnet state, breaking the development workflow that `hedera-forking` is designed to support.
### Solution
The HSS is callable at `0x16b` and exposes the following functions (sourced from the official Hedera docs):
```solidity
interface IHederaScheduleService {
// HIP-755 (Consensus Node v0.57)
// Authorizes the calling contract as a signer using its ContractKey
function authorizeSchedule(address schedule)
external returns (int64 responseCode); // 0xf0637961
// HIP-755 (Consensus Node v0.59)
// Signs a schedule transaction using a protobuf-encoded signature map
function signSchedule(address schedule, bytes memory signatureMap)
external returns (int64 responseCode); // 0x358eeb03
// HIP-756 (Consensus Node v0.59)
// Schedules a native HTS transaction (e.g., token create/update)
function scheduleNative(address systemContractAddress, bytes memory callData, address payer)
external returns (int64 responseCode, address scheduleAddress); // 0xca829811
// HIP-756 (Consensus Node v0.59)
// Returns info about a scheduled fungible token creation
function getScheduledCreateFungibleTokenInfo(address scheduleAddress)
external returns (int64 responseCode, FungibleTokenInfo memory fungibleTokenInfo); // 0xda2d5f8f
// HIP-756 (Consensus Node v0.59)
// Returns info about a scheduled non-fungible token creation
function getScheduledCreateNonFungibleTokenInfo(address scheduleAddress)
external returns (int64 responseCode, NonFungibleTokenInfo memory nonFungibleTokenInfo); // 0xd68c902c
// HIP-1215 (Consensus Node v0.68)
// Schedules a contract call
function scheduleCall(
address contractAddress,
uint256 value,
uint256 gas,
uint64 expirationTime,
bytes memory callData
) external returns (int64 responseCode, address scheduleAddress); // 0x6f5bfde8
// HIP-1215 (Consensus Node v0.68)
// Schedules a contract call with an explicit payer
function scheduleCallWithPayer(
address contractAddress,
address payer,
uint256 value,
uint256 gas,
uint64 expirationTime,
bytes memory callData
) external returns (int64 responseCode, address scheduleAddress); // 0xe6599c18
// HIP-1215 (Consensus Node v0.68)
// Executes a scheduled call once the payer has signed
function executeCallOnPayerSignature(
address contractAddress,
address payer,
uint256 gas,
uint64 expirationTime,
bytes memory callData
) external returns (int64 responseCode, address scheduleAddress); // 0x105772b2
// HIP-1215 (Consensus Node v0.68)
// Deletes a schedule by address
function deleteSchedule(address scheduleAddress)
external returns (int64 responseCode); // 0x72d42394
// HIP-1215 (Consensus Node v0.68)
// Deletes the calling schedule (self-delete)
function deleteSchedule()
external returns (int64 responseCode); // 0xc61dea85
// HIP-1215 (Consensus Node v0.68)
// Checks whether the network has capacity for new scheduled calls
function hasScheduleCapacity(uint256 numSchedules, uint256 expirationTime)
external view returns (bool); // 0xdfb4a999
}
```
Defined in:
- [HIP-755](https://hips.hedera.com/hip/hip-755) — core `signSchedule` / `authorizeSchedule`
- [HIP-756](https://hips.hedera.com/hip/hip-756) — `scheduleNative` extension
- [HIP-1215]( https://hips.hedera.com/hip/hip-1215?_gl=1*1vbudw7*_gcl_aw*R0NMLjE3NjgzOTI5MjIuQ2p3S0NBaUFtcDNMQmhBa0Vpd0FKTTJKVUlYNkJCbGszRkpmTl90VkNZd3lONjFsbktpaS0xWmI0SnI3WXVXeDBDMFFIRXJ0Y1FNbE9Sb0NELWNRQXZEX0J3RQ..*_gcl_au*OTE4NzE2MTExLjE3Njc4NjEwNDUuMzIyNTk4MDMyLjE3NzQzNTYyOTQuMTc3NDM1NjI5Mw..*_ga*MjA1NzU4NjQzOS4xNzQyOTkyMzY2*_ga_T9403E54WN*czE3NzQ1OTcyOTIkbzI2MCRnMCR0MTc3NDU5NzI5MiRqNjAkbDEkaDEwMDA5NzAwNDQ.#hip-1215) — generalized schedule contracts
- [Hedera Docs — HSS System Contract](https://docs.hedera.com/hedera/core-concepts/smart-contracts/system-smart-contracts/hedera-schedule-service)
## Expected Behavior
Similar to how the HTS emulation works:
- The Foundry library should deploy an `HssSystemContract` implementation at `0x16b` via `hssSetup()` (analogous to `htsSetup()`).
- Emulate the behaviour of the functions presented in the Hedera Schedule Service.
## Scope / Notes
- A full behavioral replica is not required (consistent with the HTS emulation philosophy). The goal is to unblock fork testing for contracts that call HSS functions.
- State fetching for schedule transactions (e.g., checking signature status) may require Mirror Node integration similar to how token state is fetched for HTS.
- [HIP-1215](https://hips.hedera.com/HIP/hip-1215.html) (Generalized Scheduled Contract Calls) proposes further HSS extensions — it may be worth considering forward-compatibility with `hasScheduleCapacity()` as well.
### Alternatives
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.