# Lambda View

> Source: https://taquito.io/docs/25.1.1/lambda_view

Lambda View is a way to retrieve data from a smart contract's storage without incurring fees via a contract's view method.

## Recap: Views & Callbacks

As you develop applications on the blockchain, you'll soon realize you not only
want to interact with Smart Contracts by updating information but also by
reading pieces of data.

Many Smart Contracts have what's known as `view methods,` which allow you to
specify parameters around what data you'd like to retrieve. They also require
you to supply a callback contract whose storage will update as a result of
executing the view method.

## Limitations to Views & Callbacks

One issue with using views and callbacks is that, just like any operation
executed on Tezos, each read has a small fee attached to it. The amount is
trivial for occasional reads, but it becomes a burden at higher volumes.

Another drawback is speed: since we're invoking a contract method as a callback, we have to wait for confirmation to retrieve the requested data. You may not find this
acceptable if the application you're working on requires consistent, faster
response times.

### `run_view` endpoint
Fortunately with the `run_view` endpoint, users can run views without needing to inject operations into the blockchain. This means that no fees will be incurred when running views using this endpoint.

## Usage

We have integrated the lambda view feature into the `ContractAbstraction` class. This integration allows retrieving data from a very similar view to call other entry points of a smart contract with Taquito.

Here's an example of using the Lambda View on a FA1.2 contract.

Taquito dynamically creates a `getAllowance`, `getBalance` and `getTotalSupply` view method that the developer can call as follows:

- `myContract.views.getAllowance(parameters)`
- `myContract.views.getBalance(parameters)`
- `myContract.view.getTotalSupply(parameters)`

>[!NOTE]
> Parameters must not include the callback parameter

Then we call the `read()` method (note that we have no longer need a lambda contract).
```js
try {
  const contract = await Tezos.contract.at('KT1PiSe6aMhtURLEQHRLCreQzU6wFLWB8Ukq');
  const response = await contract.views.getTotalSupply(UnitValue).read();
  console.log(response);
} catch (error) {
  console.log(`Error: ${error} ${JSON.stringify(error, null, 2)}`);
}
```

```js
try {
  const contract = await Tezos.contract.at('KT1AzxaDzfSzaoTM23QGeZZUvhY5QJR539aV');
  const response = await contract.views
    .balance_of([{ owner: 'tz1c1X8vD4pKV9TgV1cyosR7qdnkc8FTEyM1', token_id: '0' }])
    .read();
  console.log(JSON.stringify(response, null, 2));
} catch (error) {
  console.log(`Error: ${error} ${JSON.stringify(error, null, 2)}`);
}
```
