Skip to content

Issue 4 — Per-user balances stored in instance() storage — TTL expiry wipes all balances at once Labels: bug, security, priority:critical #4

Description

@Junman140

Body:

Problem
Balance(Address) and Allowance(Address, Address) are stored via env.storage().instance(). Instance storage has a single shared TTL for the whole contract; if it's allowed to expire, every user's balance disappears simultaneously, and nothing in the code currently calls extend_ttl to prevent this.
Proposed fix

Move Balance and Allowance entries to env.storage().persistent(), each with its own TTL, bumped on every write via extend_ttl.
Keep Admin/Paused/TotalSupply in instance() storage, with a scheduled/automated TTL bump job (e.g., a cron-triggered bump_instance_ttl admin call, or a keeper bot).
Document the TTL/rent model explicitly in the README.

Acceptance criteria

Per-user data moved to persistent storage with individual TTL extension on write
Instance storage TTL bump path documented and tested
Test simulating TTL expiry confirms no silent balance loss

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions