Home

CallStatic

CallStatic is a term used in Ethereum development, most commonly in the ethers.js library, describing a way to simulate a contract function call without changing blockchain state.

In Ethereum, interactions with contracts can be divided into state-changing transactions and read-only calls. The EVM

How it works: calling a function via CallStatic executes the function in a non-mutating context and returns

Differences from a normal transaction: a CallStatic call does not alter contract state and does not create

Limitations and caveats: results depend on the current on-chain state and the environment provided by the connected

Examples of use include checking the return value of a transfer function or verifying whether a function

also
provides
the
staticcall
opcode,
which
enforces
non-state-changing
execution.
CallStatic
builds
on
this
idea
by
offering
a
high-level
method
that
runs
the
same
function
as
a
transaction
but
as
a
local,
read-only
simulation.
It
uses
the
current
blockchain
state
from
a
provider
to
determine
what
a
real
transaction
would
return,
without
broadcasting
a
transaction
or
spending
gas.
the
function’s
return
value
as
if
the
transaction
had
succeeded.
If
the
underlying
function
would
revert,
the
CallStatic
call
rejects
with
an
error
that
includes
the
revert
reason.
Because
it
does
not
modify
state,
there
are
no
gas
costs
and
no
on-chain
changes.
a
transaction
on
the
network.
It
is
primarily
used
to
preflight
or
validate
outcomes,
test
logic
paths,
or
determine
return
values
before
issuing
a
real
transaction.
node.
Non-deterministic
elements,
recent
state
changes,
or
differences
between
nodes
can
affect
the
outcome.
CallStatic
cannot
capture
effects
that
would
only
occur
on-chain,
such
as
emitted
events
from
a
state-changing
transaction.
would
revert
before
sending
a
live
transaction.
See
also
staticcall
and
read-only
calls
in
contract
interaction
libraries.