# WebCryptoP256.sign

Signs a payload with the provided `CryptoKey` private key and returns a P256 signature.

## Imports

:::code-group
```ts [Named]
import { WebCryptoP256 } from 'ox'
```

```ts [Entrypoint]
import * as WebCryptoP256 from 'ox/WebCryptoP256'
```
:::

## Examples

```ts twoslash
import { WebCryptoP256 } from 'ox'

const { privateKey } = await WebCryptoP256.createKeyPair()

const signature = await WebCryptoP256.sign({
  // [!code focus]
  payload: '0xdeadbeef', // [!code focus]
  privateKey // [!code focus]
}) // [!code focus]
// @log: {
// @log:   r: 151231...4423n,
// @log:   s: 516123...5512n,
// @log: }
```

## Definition

```ts
function sign<as>(
  options: sign.Options<as>,
): Promise<sign.ReturnType<as>>
```

**Source:** [src/core/WebCryptoP256.ts](https://github.com/wevm/ox/blob/main/src/core/WebCryptoP256.ts#L389)

## Parameters

### options

* **Type:** `sign.Options<as>`

Options for signing the payload.

#### options.as

* **Type:** `"Object" | "Bytes" | "Hex" | as`
* **Optional**

Format of the returned signature.

#### options.payload

* **Type:** `0x${string} | Uint8Array`

Payload to sign.

#### options.privateKey

* **Type:** `CryptoKey`

ECDSA private key.

## Return Type

The P256 ECDSA [`Signature.Signature`](/api/Signature/types#signature) (always low-S normalized).

`Promise<sign.ReturnType<as>>`
