execute_call

Builds one raw EVM call step for ordered, non-atomic PROGRAM execution.

Scalar function Program CompilerSimulate

Example

Runs locally

-- A PROGRAM from a raw call step and an ABI-encoded contract step
WITH actors AS (
  SELECT
    '0x1000000000000000000000000000000000000001'::ADDRESS AS sender,
    '0x2000000000000000000000000000000000000002'::ADDRESS AS writer,
    '0x3000000000000000000000000000000000000003'::ADDRESS AS second_target
),
step_values AS (
  SELECT [
    execute_call(
      sender,
      writer,
      '0x000000000000000000000000000000000000000000000000000000000000002a'::BYTES,
      1::UINT256,
      100000::UBIGINT
    ),
    execute_contract(
      sender,
      second_target,
      0::UINT256,
      100000::UBIGINT,
      '[{"type":"function","name":"set","inputs":[{"name":"value","type":"uint256"}],"outputs":[]}]'::JSON,
      'set'::VARCHAR,
      7::UINT256
    )
  ] AS steps
  FROM actors
),
authored AS (
  SELECT steps, program(steps) AS program
  FROM step_values
)
SELECT
  len(steps)::INTEGER AS step_count,
  'raw,abi'::VARCHAR AS step_order,
  program IS NOT NULL AS runnable
FROM authored;
-- => [{"step_count":2,"step_order":"raw,abi","runnable":"true"}]

API reference

execute_call(ADDRESS, ADDRESS, BYTES, UINT256, UBIGINT) #

Builds one raw EVM call step for ordered, non-atomic PROGRAM execution.

Inputs

Name Type Use
sender ADDRESS

Account exposed as the call sender.

required positional
target ADDRESS

Account or contract called by the step.

required positional
calldata BYTES

Exact non-NULL bytes passed to the target.

required positional
value UINT256

Exact UINT256 native-token value, in Wei, sent by the call.

required positional
gas_limit UBIGINT

UBIGINT gas limit; values greater than INT64_MAX are rejected.

required positional

Returns

Name Type
step STEP

Raw call STEP. Returns a STEP with zero gas price and empty access-list and blob-hash context.

execute_call(ADDRESS, ADDRESS, BYTES, UINT256, UBIGINT, CALL_CONTEXT) #

Builds one raw EVM call step with explicit CALL_CONTEXT for ordered, non-atomic PROGRAM execution.

Inputs

Name Type Use
sender ADDRESS

Account exposed as the call sender.

required positional
target ADDRESS

Account or contract called by the step.

required positional
calldata BYTES

Exact non-NULL bytes passed to the target.

required positional
value UINT256

Exact UINT256 native-token value, in Wei, sent by the call.

required positional
gas_limit UBIGINT

UBIGINT gas limit; values greater than INT64_MAX are rejected.

required positional
context CALL_CONTEXT

Non-NULL CALL_CONTEXT supplying gas price, access list, and blob versioned hashes.

required positional

Returns

Name Type
step STEP

Contextual raw call STEP. Returns a STEP carrying the supplied CALL_CONTEXT.

Guidance

PROGRAM execution

PROGRAM executes steps in list order without atomic rollback and stops after the first unsuccessful step.

Examples

Runs locally

-- Raw and ABI-encoded steps with explicit CALL_CONTEXTs
WITH actors AS (
  SELECT
    '0x1000000000000000000000000000000000000001'::ADDRESS AS sender,
    '0x2000000000000000000000000000000000000002'::ADDRESS AS writer,
    '0x3000000000000000000000000000000000000003'::ADDRESS AS second_target
),
inputs AS (
  SELECT
    *,
    call_context(
      1::UINT256,
      [{
        address: writer,
        storage_keys: [
          '0x0000000000000000000000000000000000000000000000000000000000000000'::BYTES32
        ]
      }],
      []::BYTES32[]
    ) AS context
  FROM actors
),
step_values AS (
  SELECT [
    execute_call(
      sender,
      writer,
      '0x000000000000000000000000000000000000000000000000000000000000002a'::BYTES,
      1::UINT256,
      100000::UBIGINT,
      context
    ),
    execute_contract(
      sender,
      second_target,
      0::UINT256,
      100000::UBIGINT,
      context,
      '[{"type":"function","name":"set","inputs":[{"name":"value","type":"uint256"}],"outputs":[]}]'::JSON,
      'set'::VARCHAR,
      7::UINT256
    )
  ] AS steps
  FROM inputs
),
authored AS (
  SELECT steps, program(steps) AS program
  FROM step_values
)
SELECT
  len(steps)::INTEGER AS step_count,
  'raw,abi'::VARCHAR AS step_order,
  program IS NOT NULL AS runnable
FROM authored;
-- => [{"step_count":2,"step_order":"raw,abi","runnable":"true"}]