Skip to main content
balanceOf sets a flow input’s amount to owner’s balance of the input token, read on chain when the transaction executes, and spends exactly that. It works for ERC-20 and native inputs. balanceOf moves no tokens, so the tokens it counts must already be on the execution proxy, for example tokens a bridge delivered there or leftovers from an earlier flow. In practice owner is the proxy, which the compile result returns as userProxy. To pull the signer’s whole wallet balance instead, use the sweep form of directDeposit.

Plan with assumptions and preconditions

The amount is unknown at compile time, so the simulation needs a stand-in. Two compile options provide it:
  • preconditions: an erc20Balance precondition on the proxy makes the simulation assume the proxy holds that balance. Nothing checks the real balance at compile time.
  • assumptions: an estimated amount per input, in base units, for example { amountIn: 1000000000n }. Composer plans the downstream ops with it.

Example

Deposit whatever USDC the execution proxy holds into Aave v3, simulating as if 1,000 USDC has arrived: