Function Override
Force a contract function on your Stagenet to return a fixed value, without changing its code.
Use this to:
- Mock a price oracle, vault rate, or any external view function during testing.
- Force a contract into a specific branch (e.g.
paused() = true) without writing to storage. - Reproduce a production state that depends on a registry, ACL, or feed you can’t easily seed.
Targets your active stagenet — see Target a Stagenet. Backed by the function-override RPC methods.
function-override add
Install an override for a contract function.
contract.dev function-override add 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 \
--abi 'function totalSupply() view returns (uint256)' \
--returns '["1000000000000"]'| Argument | Description |
|---|---|
<address> | The contract whose function to override |
--abi <abi> | JSON ABI fragment or a human-readable signature (e.g. 'function getCount() view returns (uint256)') |
--returns <json> | JSON array of return values matching the fragment’s outputs |
--input-params <json> | Optional. JSON array of input params to scope this override to a specific call. Omit for a wildcard. |
The same selector can have several overrides — one per --input-params set, plus an optional wildcard. Exact-input overrides take precedence over wildcards on the same selector.
Examples:
# Wildcard: every call to balanceOf returns 1,000,000 (6dp USDC)
contract.dev function-override add 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 \
--abi 'function balanceOf(address) view returns (uint256)' \
--returns '["1000000000000"]'
# Scoped: only this holder reads as 500
contract.dev function-override add 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 \
--abi 'function balanceOf(address) view returns (uint256)' \
--input-params '["0x1111111111111111111111111111111111111111"]' \
--returns '["500000000"]'
# Pretend the protocol is paused
contract.dev function-override add 0xVault... \
--abi 'function paused() view returns (bool)' \
--returns '["true"]'Prints the created override id — keep it to update / disable / remove later.
function-override list
List active overrides.
contract.dev function-override list # every override
contract.dev function-override list --contract 0xVault... # one contractOutput is one override per line: <id> <contract> <enabled|disabled> returns=<json> [inputs=<json>].
function-override update
Replace the return values of an existing override. The contract address, selector, and inputParams are immutable — remove and re-add to change them.
contract.dev function-override update fov_abc123 --returns '["2000000000000"]'function-override enable / disable
Toggle an override on or off without removing it. A disabled override persists but is not applied — calls fall through to the real contract.
contract.dev function-override disable fov_abc123
contract.dev function-override enable fov_abc123function-override remove
Delete an override.
contract.dev function-override remove fov_abc123Notes
- Overrides intercept at the EVM layer, so a contract that
staticcalls the overridden function sees the override too — not justeth_callfrom outside. - When both a wildcard and an exact-input override exist for the same selector, the exact-input one wins.
- See RPC → Function Overrides for the full RPC schema.