# Contract getters (https://docs-i0yym09dy-ton-core-docs.vercel.app/llms/tolk/features/contract-getters/content.md)



Contract getters or [get methods](/llms/tvm/get-method/content.md) are declared using `get fun xxx()`. They typically return data extracted from [storage](/llms/languages/tolk/features/contract-storage/content.md):

```tolk
get fun currentOwner() {
    val storage = lazy Storage.load();
    return storage.ownerAddress;
}
```

## Return type [#return-type]

The return type is inferred when omitted. Get methods follow the same behavior as [functions and methods](/llms/languages/tolk/syntax/functions-methods/content.md). Specifying the return type explicitly is recommended:

```tolk
get fun currentOwner(): address {
    // ...
}
```

## Custom name [#custom-name]

Use camelCase for naming.

* Recommended: `get fun currentOwner()`
* Not recommended: `get fun get_current_owner()`

This convention may be overridden when matching standard TEPs. For example, a jetton wallet should expose a method `get_wallet_data`, as it was named in implementations.
In such cases, using `get fun get_wallet_data` is appropriate, even if it does not follow the camelCase convention.

## Documentation comments [#documentation-comments]

Place `///` doc comments above a get method to enrich the [exported ABI](/llms/languages/tolk/features/contract-abi/content.md) with descriptions.
They are surfaced in TypeScript wrappers, IDE hover, explorers, and other client-side tooling.

```tolk
/// Reads current counter.
/// @param verbose whether to include debug info
get fun currentCounter(verbose: bool): SomeReply {
    // ...
}
```

## Structures [#structures]

When a getter returns multiple values, define a [structure](/llms/languages/tolk/types/structures/content.md) and return it.
Using a structure is acceptable even for a single return. Field names provide explicit metadata for client wrappers, making the structure self-descriptive.

```tolk
struct JettonWalletDataReply {
    jettonBalance: coins
    ownerAddress: address
    minterAddress: address
    jettonWalletCode: cell
}

get fun get_wallet_data(): JettonWalletDataReply {
    val storage = lazy WalletStorage.load();

    return {
        jettonBalance: storage.jettonBalance,
        ownerAddress: storage.ownerAddress,
        minterAddress: storage.minterAddress,
        jettonWalletCode: contract.getCode(),
    }
}
```

## `lazy` loading [#lazy-loading]

Use [`lazy` loading](/llms/languages/tolk/features/lazy-loading/content.md) for [contract storage](/llms/languages/tolk/features/contract-storage/content.md). Prefer `lazy loadStorage()` instead of `loadStorage()`. Unreferenced fields are skipped automatically.

## Parameters [#parameters]

Get methods can accept parameters. Parameters use the same syntax as regular functions:

```tolk
get fun get_wallet_address(ownerAddress: address): address {
    // ...
}
```

## Stack-based execution [#stack-based-execution]

Any function in TVM takes its arguments from the stack and pushes return values onto it; get methods differ only in that they can be invoked [off-chain](/llms/from-ethereum/content.md). When called off-chain, a get method does not persist state changes.

A getter can return `int`, which is not serializable unlike `intN`. Returning a structure pushes each field onto the stack as a separate value. Client libraries such as [Blueprint](/llms/contract-dev/blueprint/overview/content.md) parse get method responses using a tuple reader.

Get methods do not store their names. They are identified by a `method_id = crc16(name) | 0x10000`, avoiding the need to store additional strings on-chain.
