View this page as Markdown

assume_storage

Declares the exact 32-byte value supplied for one contract storage slot in a PROGRAM's initial state.

Example

Local

WITH actors AS (
  SELECT
    '0x1000000000000000000000000000000000000001'::ADDRESS AS sender,
    '0x2000000000000000000000000000000000000002'::ADDRESS AS writer
),
authored AS (
  SELECT [
    -- Funds the one-Wei transfer in step zero.
    assume_native_balance(sender, 1000000::UINT256, 'funds step value transfer'::VARCHAR),
    -- Supplies the transaction context consumed by step zero.
    assume_nonce(sender, 0::UBIGINT, 'step sender nonce'::VARCHAR),
    assume_no_code(sender, 'step sender is an EOA'::VARCHAR),
    assume_native_balance(writer, 0::UINT256, 'receives step value'::VARCHAR),
    assume_nonce(writer, 0::UBIGINT, 'call target nonce'::VARCHAR),
    -- This runtime consumes calldata and stores its first word.
    assume_code(writer, '0x60003560005500'::BYTES, 'step code stores calldata word'::VARCHAR),
    assume_storage(
      writer,
      '0x0000000000000000000000000000000000000000000000000000000000000000'::BYTES32,
      '0x0000000000000000000000000000000000000000000000000000000000000000'::BYTES32,
      'step writes slot zero'::VARCHAR
    )
  ] AS assumptions,
  execute_call(
    sender,
    writer,
    '0x000000000000000000000000000000000000000000000000000000000000002a'::BYTES,
    1::UINT256,
    100000::UBIGINT
  ) AS step
  FROM actors
),
candidate AS (
  SELECT program(assumptions, [step]) AS program, assumptions
  FROM authored
)
SELECT
  len(assumptions)::INTEGER AS assumption_count,
  program IS NOT NULL AS runnable
FROM candidate;
-- => [{"assumption_count":7,"runnable":"true"}]

API reference

Exact signatures with descriptions, requirements, inputs, returns, and examples.

assume_storage(ADDRESS, BYTES32, BYTES32, VARCHAR) #

Declares the exact 32-byte value supplied for one contract storage slot in a PROGRAM's initial state.

Inputs

Name Type Use
address ADDRESS

Address that owns the storage slot.

required positional
slot BYTES32

Exact BYTES32 storage key.

required positional
value BYTES32

Exact BYTES32 word stored at the key.

required positional
reason VARCHAR

Non-NULL valid UTF-8 text recorded in the assumption manifest; it does not affect the semantic assumption root.

required positional

Returns

Name Type
assumption ASSUMPTION

Storage ASSUMPTION. Returns an ASSUMPTION for one address-and-slot coordinate. PROGRAM rejects another assumption for that coordinate.

Guidance

PROGRAM validation

Duplicate storage assumptions for the same address and slot fail when PROGRAM is constructed.

Related functions

Category and tags

Category
Simulation
Tag
Simulate