> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Secp256k1.sign

:::info
`Secp256k1.sign` is a re-export of ox's [`Secp256k1.sign`](https://oxlib.sh/api/Secp256k1/sign). Refer to the ox documentation for the full reference.
:::

Signs the payload with the provided private key.

## Imports

```ts
import { Secp256k1 } from 'viem/utils'
```

## Examples

```ts twoslash
// @noErrors
import { Secp256k1 } from 'viem/utils'

const signature = Secp256k1.sign({
  // [!code focus]
  payload: '0xdeadbeef', // [!code focus]
  privateKey: '0x...' // [!code focus]
}) // [!code focus]
```

## Definition

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

## Parameters

### options

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

The signing options.

#### options.as

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

Format of the returned signature.

#### options.extraEntropy

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

Extra entropy to add to the signing process. Setting to `true` enables hedged
(RFC 6979 + extra randomness) signing.

#### options.hash

* **Type:** `boolean`
* **Optional**

If set to `true`, the payload will be hashed (sha256) before being signed.

#### options.payload

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

Payload to sign.

#### options.privateKey

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

ECDSA private key.

## Return Type

The ECDSA [`Signature.Signature`](/docs/utilities/signature/types#signature).

`sign.ReturnType<as>`
