Skip to content

with options ​

The four options a call can carry — abi, caller, block, value — where you may write each, and which wins when they overlap.

cql
let wstETH = ethereum:0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0;
let stETH  = ethereum:0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84 with { abi: erc20 };

from stETH with { caller: wstETH } as t
| project { balance: t.balanceOf(wstETH) with { block: 26_000_000, value: 0 } }

Open in workbench →

The options ​

OptionTakesDoes
abia let name, a built-in, 'a library name', an inline abi […], or nonethe ABI used to encode the call and decode its answer
calleran addressWho the call appears to come from — the from of the call. The contract may answer differently per caller.
blocka bigintthe block the call is answered at, instead of the row's own
valuea bigint, default 0The value sent with the call. Only a payable function may take a non-zero one.

A value may not be negative: CQL refuses a constant below zero before the run (CQL2060). A value computed per row that falls outside 0 to 2^256 − 1 gives null for that row, with revert_reason encode error: value … is outside uint256, and CQL sends no request.

CQL never sends anything to the chain. Every call is a read, value and all. A call on a function that is not view — stETH's transfer, say — is answered as a simulation and noted as CQL3908.

block must be a whole number: for a time, blockat($chain, datetime('2026-09-01')). CQL refuses a constant outside the chain's range before the run (CQL3003). A constant is a number, such as -1 or (5), or a let bound to a number. A value computed per row that falls below zero gives null for that row. A value computed per row that is beyond the pinned head stops the run (CQL4003).

A call on an address on another chain than the row's must carry a block (CQL3006). That block should be a block of the address's chain. blockat(chain(x), $timestamp) is that chain's last block at or before the row's time. $block is a block number on the row's own chain. On the other chain, that number is another moment altogether, and nothing refuses it. Compare a contract across chains does this after a join.

The four places ​

On the name. let x = ethereum:0x… with { abi: v }; attaches the options to the name, so every use of x — as a source, in a list, as a call target — carries them.

On the source. from x with { … } as s applies to every call made through s — through s.$address, too, and through a column that holds it. On a list, from [a, b] as s, a row of a takes a's options from its name, and a row of b takes b's. The source's own options apply to both.

The options on a name and on a source are fixed before the query has any row. So they may use let names and constants, but not $block or a call (CQL2006). No column is in scope there. For a block that follows the row, write it on the call: s.f() with { block: $block - 1 }.

On one call. s.f() with { … } applies to that call and not to calls on its result.

On an address that the query finds. A call can give back an address, and expand makes a row for each address in a list. Such an address has no ABI of its own, so attach one where the address starts. Then the options apply to every call made through that address:

  • expand pool.getDestinations() as d with { abi: v } gives each item v. The with can also follow index i.
  • extend x = d with { abi: v } gives the column x the options.
  • project { locator: (s.getLidoLocator()) with { abi: v } } gives the call's result the options. The parentheses are necessary. Without them, the with applies to the call itself.

The options stay with the column through later stages: a project that copies or renames it, a distinct, a summarize … by key, a where, an order and a join. A call through such an address with no abi anywhere stops the query before the run (CQL2063). Follow a contract that names others shows both ways.

Which wins ​

The innermost. A with on the call overrides the source's, which overrides the name's, key by key. In the same way, a with on the call overrides one on its operand, which overrides the options of the column. For example, a source with { abi: v, caller: wstETH } and a call with { caller: nobody } give the call v and nobody. Two clauses in a row merge, and the later key wins. A key written twice in one clause also takes the later value.

abi: none ​

Disables ABI lookup for that contract. Only .call() remains. Use it when the verified ABI at an address is not the one you want to decode against.

Errors ​

  • CQL2006 — $block or a call in the options of a name or a source.
  • CQL2043 — an option that is not one of the four.
  • CQL2042 — with after something that is not a call or an address.
  • CQL2041 — a block that is not a bigint.
  • CQL2060 — a caller that is not an address, a value that is not a bigint, or a constant value below zero.
  • CQL2053 — a non-zero value on a function that is not payable.
  • CQL2063 — a call through an address that the query found, with no abi attached.

See also ​