Skip to main content
@tevm/voltaire
@tevm/voltaire / Proxy

Proxy

ERC-1967 Proxy Storage Slots and ERC-1167 Minimal Proxy utilities

See

Type Aliases

ProxySlotType

ProxySlotType = Uint8Array & object
Defined in: src/primitives/Proxy/ProxyType.ts:8 ERC-1967 Proxy storage slot type Represents a 32-byte storage slot used in proxy contracts

Type Declaration

[brand]
readonly [brand]: "ProxySlot"

See

https://eips.ethereum.org/EIPS/eip-1967

Variables

ADMIN_SLOT

const ADMIN_SLOT: string = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103"
Defined in: src/primitives/Proxy/constants.js:28 ERC-1967 Admin Slot Storage slot for the admin address in proxy contracts Calculated as: bytes32(uint256(keccak256(‘eip1967.proxy.admin’)) - 1)

See

https://eips.ethereum.org/EIPS/eip-1967

BEACON_SLOT

const BEACON_SLOT: string = "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50"
Defined in: src/primitives/Proxy/constants.js:18 ERC-1967 Beacon Slot Storage slot for the beacon address in beacon proxy contracts Calculated as: bytes32(uint256(keccak256(‘eip1967.proxy.beacon’)) - 1)

See

https://eips.ethereum.org/EIPS/eip-1967

IMPLEMENTATION_SLOT

const IMPLEMENTATION_SLOT: string = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"
Defined in: src/primitives/Proxy/constants.js:8 ERC-1967 Implementation Slot Storage slot for the implementation address in proxy contracts Calculated as: bytes32(uint256(keccak256(‘eip1967.proxy.implementation’)) - 1)

See

https://eips.ethereum.org/EIPS/eip-1967

ROLLBACK_SLOT

const ROLLBACK_SLOT: string = "0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143"
Defined in: src/primitives/Proxy/constants.js:38 ERC-1967 Rollback Test Slot Storage slot used for rollback tests in upgradeable proxies Calculated as: bytes32(uint256(keccak256(‘eip1967.proxy.rollback’)) - 1)

See

https://eips.ethereum.org/EIPS/eip-1967

Functions

generateErc1167()

generateErc1167(implementationAddress): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Proxy/generateErc1167.js:8 Generate ERC-1167 minimal proxy bytecode Creates the 55-byte creation code and 45-byte runtime code for a minimal proxy

Parameters

implementationAddress
Uint8Array<ArrayBufferLike> 20-byte implementation address

Returns

Uint8Array<ArrayBufferLike> 55-byte creation code

See

https://eips.ethereum.org/EIPS/eip-1167

generateErc3448()

generateErc3448(implementation, metadata): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Proxy/generateErc3448.js:18 Generate ERC-3448 MetaProxy bytecode with metadata ERC-3448 extends ERC-1167 minimal proxy by appending metadata to the bytecode. Structure:
  • 10 bytes: creation code (3d602d80600a3d3981f3)
  • 45 bytes: runtime code (363d3d373d3d3d363d73[address]5af43d82803e903d91602b57fd5bf3)
  • N bytes: metadata (arbitrary data)
  • 32 bytes: metadata length as uint256 (big-endian)
Total: 87 + N bytes

Parameters

implementation
Uint8Array<ArrayBufferLike> 20-byte implementation address
metadata
Uint8Array<ArrayBufferLike> Metadata to append (arbitrary length)

Returns

Uint8Array<ArrayBufferLike> Complete MetaProxy bytecode

See

https://eips.ethereum.org/EIPS/eip-3448

isErc1167()

isErc1167(bytecode): boolean
Defined in: src/primitives/Proxy/isErc1167.js:7 Check if bytecode is a valid ERC-1167 minimal proxy

Parameters

bytecode
Uint8Array<ArrayBufferLike> Bytecode to check

Returns

boolean True if valid ERC-1167 proxy

See

https://eips.ethereum.org/EIPS/eip-1167

isErc3448()

isErc3448(bytecode): boolean
Defined in: src/primitives/Proxy/isErc3448.js:15 Check if bytecode is valid ERC-3448 MetaProxy Validates:
  • Minimum length (87 bytes: 55 proxy + 32 length)
  • Creation code matches (10 bytes)
  • Runtime code prefix matches (first 20 bytes)
  • Runtime code suffix matches (last 15 bytes before metadata)
  • Metadata length encoding is consistent

Parameters

bytecode
Uint8Array<ArrayBufferLike> Bytecode to validate

Returns

boolean True if valid ERC-3448 MetaProxy

See

https://eips.ethereum.org/EIPS/eip-3448

parseErc1167()

parseErc1167(bytecode): Uint8Array<ArrayBufferLike> | null
Defined in: src/primitives/Proxy/parseErc1167.js:8 Parse implementation address from ERC-1167 minimal proxy bytecode Extracts the 20-byte implementation address from the proxy bytecode

Parameters

bytecode
Uint8Array<ArrayBufferLike> Proxy bytecode (45 or 55 bytes)

Returns

Uint8Array<ArrayBufferLike> | null 20-byte implementation address or null if invalid

See

https://eips.ethereum.org/EIPS/eip-1167

parseErc3448()

parseErc3448(bytecode): { implementation: Uint8Array; metadata: Uint8Array; } | null
Defined in: src/primitives/Proxy/parseErc3448.js:13 Parse ERC-3448 MetaProxy bytecode Extracts implementation address and metadata from ERC-3448 MetaProxy bytecode. Reads last 32 bytes as metadata length, then extracts:
  • Implementation address from bytes 20-39 (within creation code)
  • Metadata from bytes 55 to (length - 32)

Parameters

bytecode
Uint8Array<ArrayBufferLike> MetaProxy bytecode

Returns

{ implementation: Uint8Array; metadata: Uint8Array; } | null Parsed components or null if invalid

See

https://eips.ethereum.org/EIPS/eip-3448