Skip to content

jaydenwindle/safe-external-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solidity Safe External Storage

SafeExternalStorage is a solidity contract which stores arbitrary account-scoped data. It allows storage for an account to be locked within a transaction, enabling contracts which permit arbitrary delegatecall operations to protect against storage collision attacks.

Installation

$ forge install jaydenwindle/safe-external-storage

Usage

address caller = 0x...;
bytes32 slot = bytes32(0);
bytes32 value = bytes32(uint256(1));

SafeExternalStorage extStorage = new SafeExternalStorage();

// Store data scoped by sender address
extStorage.extsstore(slot, value);

// Query data by address scope
bytes32 value = extStorage.extsload(caller, slot)

// Lock storage (future calls to extsstore within the same transaction will revert)
extStorage.lock();
extStorage.extsstore(slot, value); // Revert: StorageLocked()

Inspired by Uniswap v4's extsload pattern.

About

Collision-safe storage for solidity contracts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published