# writeTarget

> **writeTarget**(`grant`, `nodeKey`, `group?`): [`WriteTarget`](/reference/filoz/keysmith/interfaces/writetarget/)

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

Everything a delegate needs to write a piece, taken from the grant that
delegated it: the group key to record, the group to label it with,
and the key to derive its piece key from.

The grant decides what is allowed. A group key grant may write under any group
or none; a group grant only under its own group or a group beneath it, and
defaults to its own group. A piece grant cannot write at all: its key belongs
to one existing piece, and FEE needs a fresh key for every object. Anything
else is refused here, before a piece is encrypted under a key its intended
readers could never derive.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `grant` | [`GrantDescriptor`](/reference/filoz/keysmith/interfaces/grantdescriptor/) |
| `nodeKey` | [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) |
| `group?` | `string` |

## Returns

[`WriteTarget`](/reference/filoz/keysmith/interfaces/writetarget/)

## Throws

If the grant's `v` is present and not 2 (as [holdingOf](/reference/filoz/keysmith/functions/holdingof/)), the grant is a piece grant, the group lies outside the grant's subtree, or the key is not 32 bytes.