Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
ERC-6823 proposes a way for external tools to determine exactly which storage slots hold token ownership information, so that off-chain transaction simulations can reproduce state changes more reliably.
This article translates, summarizes, and expands on the following proposal.
I also cover other EIPs, BIPs, SLIPs, CAIPs, ENSIPs, RFCs, and ACPs.
Overview
The proposal aims to make off-chain simulations of transactions involving ERC-20, ERC-721, and ERC-1155 tokens more accurate.
Its central idea is to expose the storage location of the mapping used to track ownership or balances in each token standard.
For more on ERC-20, see the following article.
[ERC20] ERC-20 from the ground up
For more on ERC-721, see the following article.
[ERC721] ERC-721 from the ground up
Ethereum contracts keep their internal state in EVM storage. Storage is organized into 32-byte slots, and variables are allocated in declaration order. A mapping, however, has no fixed size and uses a different storage scheme. The location of each value in a mapping is determined by combining the key with the position of the mapping and computing a keccak256 hash.
Even among contracts implementing the same ERC standard, the storage slot serving as the root of a mapping varies from one contract to another. Because that position is implementation-specific, external tools cannot determine it generically. Off-chain simulations may therefore fail to reproduce storage changes accurately and diverge from the actual state of a contract.
A standard way to retrieve the storage slot used by the mapping that tracks ownership or balances would allow external tools to reproduce state changes without knowing the implementation. They could verify state more accurately instead of relying on events alone.
Motivation
Storage layout fundamentals
Ethereum smart contracts persist their internal state in storage. Storage is a key-value data structure in which the slot address is 32 bytes and the value is 32 bytes. Each variable declared in a contract is assigned a location in that storage.
Variables are laid out in declaration order. If a variable occupies less than 32 bytes, it is packed into the same slot where possible. The original article describes this layout as following the same rules in Solidity and other languages such as Vyper.
Why mapping is treated differently
A mapping is a variable-size data type whose number of entries is not known in advance. Unlike other variables, its entries are not laid out consecutively in storage. The mapping itself is assigned a fixed 32-byte slot, but its values are stored elsewhere at locations derived by hashing.
The location of a value is determined as follows.
- Encode the key
kas32bytes. - Encode the position of the
mapping,p, as32bytes. - Concatenate
[k | p]and compute itskeccak256hash. - The resulting hash is the storage slot containing the value.
The problem is that the base position of the mapping, p, differs between contracts and cannot be inferred from the token standard.
Why simulation is difficult
To simulate transactions off-chain, the simulation must use the same layout as the actual storage. However, without examining the implementation, a tool cannot know the order in which variables are declared or where a mapping is located in storage.
This leads to several problems.
- Even for ERC-20, ERC-721, and ERC-1155, the actual storage position of the
mappingused for balances or ownership is unknown. - External tools and services cannot reliably track state because they cannot accurately reproduce storage changes off-chain.
- As a result, they are left relying on events.
Events are intended to provide notifications, however, and should not be relied on to determine the actual state. Storage is the authoritative record of that state.
Why a standard way to retrieve the mapping storage slot is needed
Analyzing the storage layout of each implementation is impractical. Even contracts that conform to an ERC standard may use different storage locations. External tools consequently cannot simulate them reliably, reducing the accuracy of state verification.
If token standards provided a common entry point for retrieving the base slot of a mapping, tools could achieve the following regardless of implementation.
- Reproduce
stateaccurately off-chain. - Verify state securely without relying exclusively on events.
- Determine the correct storage location without inspecting the implementation.
- Improve the reliability of wallets, block explorers, and auditing tools through more accurate simulations.
Specification
Overview of the token standard extension
The proposal adds a common interface to ERC-20, ERC-721, and ERC-1155 for retrieving the storage slot reserved for the mapping used to track token ownership or balances.
The storage locations of mapping values depend on the contract implementation. A common function would provide a deterministic way to discover the relevant location from any conforming contract. External tools could then read storage directly to determine the actual state rather than relying on events alone, making more accurate off-chain simulations possible.
The proposal aims to avoid additional costs for external reads and keep the impact on contract deployment very small.
New function
ERC-20, ERC-721, and ERC-1155 contracts implement the same function, getTokenLocationRoot(). It returns the base storage slot of the relevant mapping.
abstract contract ERC20Extension is ERC20 {
function getTokenLocationRoot() external pure virtual returns (bytes32 slot) {
assembly {
slot := <mapping_name>.slot
}
}
}
abstract contract ERC721Extension is ERC721 {
function getTokenLocationRoot() external pure virtual returns (bytes32 slot) {
assembly {
slot := <mapping_name>.slot
}
}
}
abstract contract ERC1155Extension is ERC1155 {
function getTokenLocationRoot() external pure virtual returns (bytes32 slot) {
assembly {
slot := <mapping_name>.slot
}
}
}Replace <mapping_name> with the name of the mapping that actually holds token ownership information.
Off-chain tools can use this function to determine the root location of the mapping. Because the storage location of each key in a mapping is derived from that root slot using keccak256, knowing the root lets tools calculate the exact storage location for each key.
Practical applications
External tools can use getTokenLocationRoot() to verify storage contents in cases such as the following.
- ERC-721
mint(token issuance) Calculate the storage location for the token ID and verify that it contains the new owner's address. - ERC-20
transfer(balance movement) Calculate the relevant storage locations and verify directly that the sender's and recipient's balances were updated correctly. - ERC-1155
burnDetermine the location that should change and check whether its value is the zero address, as described in the original article.
This allows events to serve as supplementary information while storage remains the authoritative source for state verification. In the future, the same approach could also be used to prove specific storage slots rather than proving the entire storage state.
Why the function name is shared
The generic function name getTokenLocationRoot() was chosen deliberately so that all token standards can use it. The selector derived from the function signature is therefore identical, allowing tools to retrieve storage information in the same way from different token contracts.
With a shared entry point, external tools can retrieve the storage position using a common procedure without needing to distinguish between token standards.
Implementation requirements
| Requirement | Description |
|---|---|
| MUST | The contract must implement getTokenLocationRoot(). |
| MUST | The function must return the base storage slot of the relevant mapping. |
| SHOULD | The function should be declared external pure. |
Declaring the function pure prevents side effects, keeps gas costs low, and makes the function easy for external tools to use.
Rationale
Maintaining compatibility
ERC-20, ERC-721, and ERC-1155 are already widely adopted, so preserving compatibility with existing implementations is important. The proposal makes a small addition rather than a major change to the token specifications.
Only one function is added. Existing functions and events remain unchanged. This avoids incompatibilities with older implementations and existing tools. The goal is to improve access to storage information without disrupting the established ecosystem.
Keeping gas costs low
Gas costs matter to users of smart contracts. Tokens are used frequently, so even small increases in gas consumption can add up.
For ERC-20, ERC-721, and ERC-1155, the proposal takes the following approach.
- The added function is
pureand can be called off-chain without paying transaction gas. - Deployment costs increase only slightly, while existing user transactions are unaffected.
- External tools can retrieve storage information through an off-chain call without paying additional transaction fees.
Users can continue using tokens as before, while developers and external tools benefit from the new interface.
Minimal, flexible implementation
The extension is straightforward: it adds a single function to the contract. The function uses assembly to return the mapping's base slot, so the implementation need not be complex.
The minimal design has several intended benefits.
- Compatibility with a range of EVM languages, including Solidity and Vyper.
- Applicability across token implementations without requiring external tools to know their internal structures.
- Extensibility for future tools and proof systems.
Its simplicity makes it flexible and compatible, which helps the wider EVM ecosystem adopt the interface.
Reference implementation
abstract contract ERC20Extension is ERC20 {
function getTokenLocationRoot() external pure virtual returns (bytes32 slot) {
assembly {
slot := <mapping_name>.slot
}
}
}
abstract contract ERC721Extension is ERC721 {
function getTokenLocationRoot() external pure virtual returns (bytes32 slot) {
assembly {
slot := <mapping_name>.slot
}
}
}
abstract contract ERC1155Extension is ERC1155 {
function getTokenLocationRoot() external pure virtual returns (bytes32 slot) {
assembly {
slot := <mapping_name>.slot
}
}Citation
qdqd (@qd-qd) qdqdqdqdqd@protonmail.com, "ERC-6823: Token Mapping Slot Retrieval Extension [DRAFT]," Ethereum Improvement Proposals, no. 6823, March 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6823.
Conclusion
ERC-6823 proposes a standard way for external tools to identify the storage slots holding token ownership information and reproduce off-chain transaction simulations more reliably. I hope this overview was helpful.
If you have questions, feel free to send me a direct message on Twitter.
I also publish on the following platforms.



