> ## Documentation Index
> Fetch the complete documentation index at: https://cantonfoundation-generated-reference-full-stack-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# DA.ContractKeys

> Reference documentation for Daml module DA.ContractKeys.

<div class="x2mdx-ref-page x2mdx-ref-page--collection" />

<span id="module-da-contractkeys-19667" />

<div class="x2mdx-ref-hero">
  <p class="x2mdx-ref-eyebrow">Daml module</p>

  <h1 class="x2mdx-ref-title">DA.ContractKeys</h1>

  <p class="x2mdx-ref-summary">Note: Docs TODO ([https://github.com/digital-asset/daml/issues/22673](https://github.com/digital-asset/daml/issues/22673))</p>

  <div class="x2mdx-ref-badges">
    <span class="x2mdx-ref-badge x2mdx-ref-badge--protocol">Daml</span>

    <a class="x2mdx-ref-badge x2mdx-ref-badge--added" href="#history-added-3-5-1">Added 3.5.1</a>
  </div>

  <dl class="x2mdx-ref-meta-grid">
    <div class="x2mdx-ref-meta-item">
      <dt>Module</dt>
      <dd>DA.ContractKeys</dd>
    </div>

    <div class="x2mdx-ref-meta-item">
      <dt>Latest release</dt>
      <dd>3.5.7</dd>
    </div>
  </dl>
</div>

## Functions

<span id="function-da-internal-template-functions-lookupnbykey-93090" />

### `lookupNByKey`

`lookupNByKey` : [`HasLookupNByKey`](/appdev/reference/daml-standard-library/prelude#class-da-internal-template-functions-haslookupnbykey-35508) `t` `k` => [`Int`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> `k` -> [`Update`](/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-update-68072) \[([`ContractId`](/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-contractid-95282) `t`, `t`)]

Look up up to n contracts associated with the passed key. Contracts created
within a transaction are returned first (in recency order), then disclosed
contracts, then nonlocal contracts.

You must pass the `t` using an explicit type application. For instance, if
you want to query 3 contracts of template `Account` given by its key `k`, you
must call \`lookupNByKey @Account 3 k.

<span id="function-da-internal-template-functions-lookupallbykey-2641" />

### `lookupAllByKey`

`lookupAllByKey` : [`HasLookupNByKey`](/appdev/reference/daml-standard-library/prelude#class-da-internal-template-functions-haslookupnbykey-35508) `t` `k` => `k` -> [`Update`](/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-update-68072) \[([`ContractId`](/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-contractid-95282) `t`, `t`)]

Shorthand for `lookupNByKey` with n larger than the amount of contracts that
can exist for a key (1000000), therefore returning all contracts

## History

<div class="x2mdx-ref-history" aria-label="Reference history">
  <div class="x2mdx-ref-history-event x2mdx-ref-history-event--introduced" id="history-added-3-5-1">
    <div class="x2mdx-ref-history-event-head">
      <span class="x2mdx-ref-history-event-label">Added</span>
      <code class="x2mdx-ref-history-event-version">3.5.1</code>
    </div>
  </div>
</div>
