> **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.

# WebAuthn.sign

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

Signs a challenge using a stored WebAuthn P256 Credential. If no Credential is provided, a prompt will be displayed for the user to select an existing Credential that was previously registered.

## Imports

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

## Examples

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

const credential = await WebAuthn.createCredential({
  name: 'Example'
})

const { metadata, signature } = await WebAuthn.sign({
  // [!code focus]
  credentialId: credential.id, // [!code focus]
  challenge: '0xdeadbeef' // [!code focus]
}) // [!code focus]
// @log: {
// @log:   metadata: {
// @log:     authenticatorData: '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000',
// @log:     clientDataJSON: '{"type":"webauthn.get","challenge":"9jEFijuhEWrM4SOW-tChJbUEHEP44VcjcJ-Bqo1fTM8","origin":"http://localhost:5173","crossOrigin":false}',
// @log:     challengeIndex: 23,
// @log:     typeIndex: 1,
// @log:     userVerificationRequired: true,
// @log:   },
// @log:   signature: { r: 51231...4215n, s: 12345...6789n },
// @log: }
```

## Definition

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

## Parameters

### options

* **Type:** `sign.Options`

Options.

## Return Type

The signature.

`Promise<sign.ReturnType>`
