# pickGrant

> **pickGrant**\<`T`\>(`grants`, `target`, `options`): `T` \| `undefined`

Defined in: [claims.ts:412](https://github.com/FilOzone/synapse-sdk/blob/840d7b2c6263846ac51b7558000e62dd68d33a44/packages/keysmith/src/claims.ts#L412)

The narrowest held grant that reaches `target`: a piece grant before a group grant, a deeper group before a
shallower one, the group key last; on a tie, the one that expires last. Grants for another network or group key,
or expired ones, or whose node does not parse, are skipped. Undefined when none reaches it: ask for a grant to that group or piece.

Takes anything carrying a verified `claim`, such as what `openDelivery` returns.

Grants are matched to one owner, never to any owner: a grant's owner and group key id are public, so
anyone can root a grant under another wallet's group key id. A group target names its owner. A piece
target takes it from the piece's `foc/own`; a piece without one (not gated) needs `options.owner`. When
both are present they must match.

## Type Parameters

| Type Parameter |
| ------ |
| <a id="type-parameter-t"></a> `T` *extends* `object` |

## Parameters

| Parameter | Type |
| ------ | ------ |
| `grants` | readonly `T`[] |
| `target` | [`GrantTarget`](/reference/filoz/keysmith/type-aliases/granttarget/) |
| `options` | \{ `chainId`: `bigint`; `now?`: `number`; `owner?`: `` `0x${string}` ``; \} |
| `options.chainId` | `bigint` |
| `options.now?` | `number` |
| `options.owner?` | `` `0x${string}` `` |

## Returns

`T` \| `undefined`

## Throws

If no owner can be fixed, `options.owner` contradicts the piece's `foc/own`, or a label is malformed.