hiero-ledger / hiero-ledger/hiero-consensus-node

Hedera Account Service (HAS) Precompile `hbarAllowance` Returns Original Instead of Live Remaining Allowance

Open
#26,010 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
406
Forks
226
Avg merge
3d 4h
Merged PRs (30d)
210

Description

# Issue: Hedera Account Service (HAS) Precompile `hbarAllowance` Returns Original Instead of Live Remaining Allowance

## Problem

Under [HIP-906](https://hips.hedera.com/hip/hip-906#hip-906), the Hedera Account Service (HAS) system contract precompile at `0x16a` exposes functions to query HBAR allowances. However, calls to these functions fail to return the live, decremented remaining allowance after HBAR has been spent by a spender. Instead, they return the originally granted allowance.

This is demonstrated and reproducible using the following MCVE repository:
**MCVE Repository:** [remainign-hbar-allowance-mcve](https://github.com/skurzyp-blockydevs/remainign-hbar-allowance-mcve)

---

## Technical Context & HIP-906 Specification

Based on the [HIP-906 Specification](https://hips.hedera.com/hip/hip-906#hip-906):
* **Solidity Signature:** `hbarAllowance(address spender) external returns (int64 responseCode, int256 amount)`
* *(Also applies to the 2-parameter variant: `hbarAllowance(address owner, address spender)`)*

### Expected Behavior:
The response code from the call and the amount of HBAR allowance currently available to the spender must return the **remaining assets (live remaining allowance)**, not the originally given/granted amount.

When a spender uses `cryptoTransfer` via the HTS precompile to spend HBAR on behalf of an owner, the available allowance must decrement accordingly on the consensus state. Any subsequent queries to `hbarAllowance` must reflect this deduction.

### Observed Behavior:
The HAS precompile queries do not correctly reflect the decremented remaining allowance after a spend transaction has occurred, continuing to return the original amount granted.

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior with the linked remainign-hbar-allowance-mcve repository, then trace the HAS precompile hbarAllowance entry points alongside HTS cryptoTransfer. Compare the queried amount before and after the spender uses the allowance; done means both hbarAllowance variants report the live remaining amount rather than the original grant.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, solidity
Domain
api, blockchain
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.