# writeTarget

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

Defined in: [derive.ts:474](https://github.com/FilOzone/synapse-sdk/blob/68e30a2a5457180e60a5579eb5ecff90b65894b3/packages/keysmith/src/derive.ts#L474)

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

The grant decides what is allowed. A keyspace grant may write under any scope
or none; a scope grant only under its own scope or a scope beneath it, and
defaults to its own scope. 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) |
| `scope?` | `string` |

## Returns

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

## Throws

If the grant is a piece grant, the scope lies outside the grant's subtree, or the key is not 32 bytes.