hiero-ledger / hiero-ledger/hiero-sdk-cpp
[Intermediate]: Add HIP-632 Hedera Account Service (HAS) System Contract Example
- Dominant language
- C++
- Stars
- 42
- Forks
- 108
- Avg merge
- 11h 45m
- Merged PRs (30d)
- 2
Description
## 🧩 Intermediate Friendly
This issue is a good fit for contributors who are already familiar with the Hiero C++ SDK and feel comfortable navigating the codebase.
Intermediate Issues often involve:
- Exploring existing implementations
- Understanding how different components work together
- Making thoughtful changes that follow established patterns
The goal is to support deeper problem-solving while keeping the task clear, focused, and enjoyable to work on.
---
## 🐞 Problem Description
The Hiero C++ SDK is missing an example demonstrating the **Hedera Account Service (HAS)** system contract defined in [HIP-632](https://hips.hedera.com/hip/hip-632).
HAS is a live network feature (released in v0.56.7) that provides:
- `getEvmAddressAlias(address)` - translate account num to EVM address
- `getHederaAccountNumAlias(address)` - translate EVM address to account num
- `isValidAlias(address)` - check if an address is a valid alias
- `isAuthorized(address, message, signatureBlob)` - verify authorization with protobuf signatures
- `isAuthorizedRaw(address, messageHash, signatureBlob)` - verify authorization with raw signatures (like ECRECOVER)
The SDK has examples for other system contracts (HTS in `SolidityPrecompileExample.cpp`) but none for HAS.
Relevant files:
- `src/sdk/examples/SolidityPrecompileExample.cpp` - existing pattern to follow
- `src/sdk/examples/precompile-example/` - Solidity contracts and compiled artifacts
---
## 💡 Expected Outcome
Create a new example that demonstrates the HAS system contract methods, following the existing `SolidityPrecompileExample` pattern.
The change should:
- Include a Solidity interface for HAS (`IHederaAccountService.sol`)
- Include a Solidity contract that exercises HAS methods (`HASExample.sol`)
- Include the compiled contract artifacts (`HASExample.json`)
- Include a C++ example that deploys and calls the contract (`HASExample.cpp`)
- Match the style and patterns of existing precompile examples
- Build and run successfully against testnet
The HAS system contract lives at address `0x16a` (account `0.0.362`) on all Hiero networks.
---
## 🧠 Implementation Notes
This task requires knowledge beyond basic C++:
**Smart contract skills needed:**
- Understanding Solidity syntax and precompile call patterns
- Knowing how to compile Solidity to bytecode/ABI JSON format
- Familiarity with how system contracts work on Hiero
**Suggested approach:**
1. Study the existing precompile example:
- `src/sdk/examples/SolidityPrecompileExample.cpp`
- `src/sdk/examples/precompile-example/IHederaTokenService.sol`
- `src/sdk/examples/precompile-example/PrecompileExample.sol`
- `src/sdk/examples/precompile-example/PrecompileExample.json`
2. Create the Solidity interface (`IHederaAccountService.sol`):
- Define all HAS methods from HIP-632
- Use correct function selectors (see HIP-632 specification)
3. Create the example contract (`HASExample.sol`):
- Import the interface
- Call HAS precompile at `0x16a`
- Create step functions to test each HAS method
4. Compile the Solidity:
- Use `solc`, Foundry, or Hardhat
- Generate `HASExample.json` with bytecode and ABI
5. Create the C++ example (`HASExample.cpp`):
- Deploy the contract
- Call each step function
- Print results to demonstrate functionality
6. Update `CMakeLists.txt` to include the new example
**HIP-632 function selectors:**
| Function | Selector |
|----------|----------|
| `getEvmAddressAlias(address)` | `0xdea3d081` |
| `getHederaAccountNumAlias(address)` | `0xbbf12d2e` |
| `isValidAlias(address)` | `0x308ef301` |
| `isAuthorized(address,bytes,bytes)` | `0xb2526367` |
| `isAuthorizedRaw(address,bytes32,bytes)` | `0xb2a31da4` |
---
## ✅ Acceptance Criteria
To help get this change merged smoothly:
- [ ] `IHederaAccountService.sol` interface created with HIP-632 methods
- [ ] `HASExample.sol` contract exercises key HAS methods
- [ ] `HASExample.json` contains compiled bytecode and ABI
- [ ] `HASExample.cpp` demonstrates usage from C++
- [ ] Follow existing project conventions (see `SolidityPrecompileExample`)
- [ ] Example builds and runs successfully against testnet
- [ ] Example is added to CMakeLists.txt
- [ ] Pass all CI checks
---
## 📋 Contribution Guide
To help your contribution go as smoothly as possible, we recommend following these steps:
- [ ] Comment `/assign` to request the issue
- [ ] Wait for assignment
- [ ] Fork the repository and create a branch
- [ ] Set up the project using the instructions in `README.md`
- [ ] Make the requested changes
- [ ] Sign each commit using `-s -S`
- [ ] Push your branch and open a pull request
Read [Workflow Guide](docs/training/workflow.md) for step-by-step workflow guidance.
Read [README.md](README.md) for setup instructions.
❗ Pull requests **cannot be merged** without `S` and `s` signed commits.
See the [Signing Guide](docs/training/signing.md).
---
## 📚 Additional Context or Resources
**References:**
- [HIP-632 Specification](https://hips.hedera.com/hip/hip-632)
- [HIP-583 (Alias definitions)](https://hips.hedera.com/hip/hip-583)
- [Solidity Compiler (solc)](https://docs.soliditylang.org/en/latest/installing-solidity.html)
If you have questions, the community is happy to help:
https://discord.com/channels/905194001349627914/1337424839761465364
Contributor guide
Assessment
This issue has not been assessed yet.