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

# useContractCall

> Simulate contract 'reads' with zero boilerplate and built-in caching.

`useContractCall` is your window into the state of the blockchain. It simulates a read-only method call against a deployed Soroban contract and returns the decoded result as a native JavaScript value. No connected wallet required.

## The Experience

You pass plain JavaScript objects as arguments. Sorokit fetches the contract's WASM spec at runtime and handles all XDR conversion for you, so you never touch `scValToNative` or manual encoding.

```tsx theme={null}
import { useContractCall } from "@sorokit/contract";

function TokenInfo({ contractId }: { contractId: string }) {
  const { data, isLoading } = useContractCall<string>({
    contractId,
    method: "symbol",
  });

  if (isLoading) return <span>Loading...</span>;
  return <h1>Token: {data}</h1>;
}
```

## Performance by Default

Under the hood, `useContractCall` is a wrapper around **TanStack Query**.

* **Automatic Caching:** If two components call the same method with the same arguments, only one network request is made.
* **Smart Revalidation:** The cache is automatically invalidated when a wallet transaction might have changed the value (via [`useContractSend`](/hooks/use-contract-send)).
* **Loading & Error States:** You get `isLoading`, `isError`, and `error` directly, ready for JSX.

## Parameters

| Field        | Type      | Description                                                              |
| ------------ | --------- | ------------------------------------------------------------------------ |
| `contractId` | `string`  | The address of the deployed contract (`C...`).                           |
| `method`     | `string`  | The name of the read-only function (e.g. `"balance"`, `"name"`).         |
| `args`       | `object`  | An object whose keys match the contract's parameter names.               |
| `enabled`    | `boolean` | Controls when the query fires (e.g. wait until a user address is known). |

## Type Inference

The contract spec is fetched at runtime, but you can pass a generic type for type safety in your component.

```tsx theme={null}
const { data } = useContractCall<bigint>({
  contractId: TOKEN_CONTRACT_ID,
  method: "balance",
  args: { id: userAddress },
});

// `data` is correctly inferred as `bigint | undefined`
```
