# SignatureErc8010

Utility functions for working with [ERC-8010 wrapped signatures](https://eips.ethereum.org/EIPS/eip-8010#specification).

## Examples

```ts twoslash
import {
  Authorization,
  PersonalMessage,
  Secp256k1,
  Signature
} from 'ox'
import { SignatureErc8010 } from 'ox/erc8010' // [!code focus]

const authorization = Authorization.from({
  address: '0x1234567890abcdef1234567890abcdef12345678',
  chainId: 1,
  nonce: 69n
})

const authorizationSignature = Secp256k1.sign({
  payload: Authorization.getSignPayload(authorization),
  privateKey: '0x...'
})

const authorizationSigned = Authorization.from(
  authorization,
  {
    signature: authorizationSignature
  }
)

const signature = Secp256k1.sign({
  payload: PersonalMessage.getSignPayload('0xdeadbeef'),
  privateKey: '0x...'
})

const wrapped = SignatureErc8010.wrap({
  // [!code focus]
  authorization: authorizationSigned, // [!code focus]
  data: '0xcafebabe', // [!code focus]
  signature: Signature.toHex(signature) // [!code focus]
}) // [!code focus]
// @log: '0x000000000000000000000000cafebabecafebabecafebabecafebabecafebabe000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004deadbeef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041fa78c5905fb0b9d6066ef531f962a62bc6ef0d5eb59ecb134056d206f75aaed7780926ff2601a935c2c79707d9e1799948c9f19dcdde1e090e903b19a07923d01c000000000000000000000000000000000000000000000000000000000000008010801080108010801080108010801080108010801080108010801080108010'
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`SignatureErc8010.assert`](/ercs/erc8010/SignatureErc8010/assert) | Asserts that the wrapped signature is valid. |
| [`SignatureErc8010.from`](/ercs/erc8010/SignatureErc8010/from) | Parses an [ERC-8010 wrapped signature](https://github.com/jxom/ERCs/blob/16f7e3891fff2e1e9c25dea0485497739db8a816/ERCS/erc-8010.md) into its constituent parts. |
| [`SignatureErc8010.unwrap`](/ercs/erc8010/SignatureErc8010/unwrap) | Unwraps an [ERC-8010 wrapped signature](https://github.com/jxom/ERCs/blob/16f7e3891fff2e1e9c25dea0485497739db8a816/ERCS/erc-8010.md) into its constituent parts. |
| [`SignatureErc8010.validate`](/ercs/erc8010/SignatureErc8010/validate) | Validates a wrapped signature. Returns `true` if the wrapped signature is valid, `false` otherwise. |
| [`SignatureErc8010.wrap`](/ercs/erc8010/SignatureErc8010/wrap) | Wraps a signature into [ERC-8010 format](https://github.com/jxom/ERCs/blob/16f7e3891fff2e1e9c25dea0485497739db8a816/ERCS/erc-8010.md). |

## Errors

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`SignatureErc8010.InvalidUnwrappedSignatureError`](/ercs/erc8010/SignatureErc8010/errors#signatureerc8010invalidunwrappedsignatureerror) | Thrown when an ERC-8010 unwrapped signature object is malformed. |
| [`SignatureErc8010.InvalidWrappedSignatureError`](/ercs/erc8010/SignatureErc8010/errors#signatureerc8010invalidwrappedsignatureerror) | Thrown when the ERC-8010 wrapped signature is invalid. |

## Types

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`SignatureErc8010.Unwrapped`](/ercs/erc8010/SignatureErc8010/types#signatureerc8010unwrapped) | Unwrapped ERC-8010 signature. |
| [`SignatureErc8010.Wrapped`](/ercs/erc8010/SignatureErc8010/types#signatureerc8010wrapped) | Wrapped ERC-8010 signature. |
