> ## Documentation Index
> Fetch the complete documentation index at: https://docs.li.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# call

> Run a contract call at execution time and use the token balance it produces as the input amount

The `call` materialiser sets a flow input's amount to what a contract call produces, for example "claim rewards from staking contract X, then deposit them into vault Y". At execution, the transaction calls `target` with your `calldata` from the execution proxy and measures the proxy's balance of the input token before and after. The difference is the input amount.

`msg.sender` is the proxy, so a `claimRewards()` call claims the proxy's rewards, not the signer's. The position must belong to the proxy.

> [!NOTE]
>
> Unlike the [`core.call`](https://docs.li.fi/composer/composer-api/ops/core-call) op, which ABI-encodes a function signature for you, the `call` materialiser takes pre-encoded `0x` `calldata`. Encode it yourself, for example with viem's `encodeFunctionData`.

## Plan with assumptions

Pass `assumptions` with an estimated amount for the input, in base units, so Composer can plan the downstream ops before the real amount exists. Guard the ops that consume it, for example with [`slippage`](https://docs.li.fi/composer/composer-api/guards/slippage).

## Example

Claim reward tokens from a staking contract and deposit the claimed amount into a vault:

```ts theme={"system"}
import { createComposeSdk, guards, materialisers, resources } from '@lifi/composer-sdk';
import { encodeFunctionData } from 'viem';

const STAKING_CONTRACT = '0xYourStakingContract';
const REWARD_TOKEN = '0xYourRewardToken';
const VAULT_SHARE = '0xYourVaultShareToken';

const sdk = createComposeSdk({
  baseUrl: 'https://composer.li.quest',
  apiKey: process.env.LIFI_API_KEY!,
});

const builder = sdk.flow(1, {
  name: 'claim-and-deposit',
  inputs: { rewards: resources.erc20(REWARD_TOKEN, 1) },
});

builder.lifi.zap('deposit', {
  bind: { amountIn: builder.inputs.rewards },
  config: { resourceOut: resources.erc20(VAULT_SHARE, 1) },
  guards: [guards.slippage({ port: 'amountOut', bps: 100 })],
});

// ABI-encode the claim call once; the materialiser takes raw calldata.
const claimRewardsCalldata = encodeFunctionData({
  abi: [{ type: 'function', name: 'claimRewards', inputs: [], outputs: [], stateMutability: 'nonpayable' }],
  functionName: 'claimRewards',
});

await builder.compile({
  signer: '0xYourSignerAddress',
  inputs: {
    rewards: materialisers.call({
      target: STAKING_CONTRACT,
      calldata: claimRewardsCalldata,
    }),
  },
  // The claimed amount is only known on chain; give the compiler an estimate to plan with.
  assumptions: { rewards: 50_000000000000000000n }, // about 50 reward tokens (18 decimals)
  sweepTo: builder.context.sender,
});
```

The vault must have a routing edge from the reward token for `lifi.zap` to deposit it; see [Protocols and chains](https://docs.li.fi/composer/protocols-and-chains.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.