Skip to content

Conversation

ariutokintumi
Copy link

@ariutokintumi ariutokintumi commented Aug 10, 2025

This ERC proposes an optional ERC-20 extension that allows token contracts to implement a preInitializeAddress(address) function. This function lets users or dApps pay the high SSTORE gas cost of first-time balance initialization in advance, when gas is low, by writing a sentinel (magic) value to the balance slot.

The balance mapping is stored as bytes32 internally, and the sentinel is treated as 0 for all ERC-20 reads/writes. When the user later receives tokens, the sentinel is overwritten at the cheaper 5k gas rate instead of the full 20k.

We use bytes32 because writing zero to a slot does not save gas for the first real (nonzero) balance write. EVM only discounts overwrites of already-allocated slots with nonzero value.

This approach mirrors ERC-721A "gas timing" concept but in reverse: high gas now, low gas later, giving users more control over when they incur expensive storage writes.

Discussion thread: https://ethereum-magicians.org/t/erc-tbd-erc-20-pre-initialization-extension-sentinel-storage-gas-savings-for-first-time-token-receivers/24993

Repository including contracs, testing and tooling: https://github.com/ariutokintumi/ERC-20-Pre-initialization

@eip-review-bot
Copy link
Collaborator

eip-review-bot commented Aug 10, 2025

File ERCS/erc-8003-erc20-preinit-sentinel-storage.md

Requires 1 more reviewers from @g11tech, @SamWilsn, @xinbenlv

@eip-review-bot eip-review-bot changed the title ERC: ERC-20 Pre-initialization Extension (Sentinel Storage) Add ERC: ERC-20 Pre-initialization Extension (Sentinel Storage) Aug 10, 2025
@github-actions github-actions bot added the w-ci label Aug 10, 2025
@github-actions github-actions bot added w-ci and removed w-ci labels Aug 10, 2025
@github-actions github-actions bot removed the w-ci label Aug 12, 2025
@eip-review-bot eip-review-bot changed the title Add ERC: ERC-20 Pre-initialization Extension (Sentinel Storage) Add ERC: ERC-8003 ERC-20 Pre-initialization Extension (Sentinel Storage) Aug 12, 2025
@github-actions github-actions bot added the w-ci label Aug 12, 2025
@eip-review-bot eip-review-bot changed the title Add ERC: ERC-8003 ERC-20 Pre-initialization Extension (Sentinel Storage) Add ERC: ERC-20 Pre-initialization Extension (Sentinel Storage) Aug 16, 2025
@github-actions github-actions bot removed the w-ci label Aug 16, 2025
Copy link

The commit ead73d5 (as a parent of e0b1d4a) contains errors.
Please inspect the Run Summary for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants