# AuthorizationTempo.getSignPayload

Computes the sign payload for an [`AuthorizationTempo.AuthorizationTempo`](/tempo/reference/AuthorizationTempo/types#authorizationtempo) in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702): `keccak256('0x05' || rlp([chain_id, address, nonce]))`.

## Imports

:::code-group
```ts [Named]
import { AuthorizationTempo } from 'ox/tempo'
```

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

## Examples

### Secp256k1

Standard Ethereum ECDSA signature using the secp256k1 curve.

```ts twoslash
import { Secp256k1 } from 'ox'
import { AuthorizationTempo } from 'ox/tempo'

const privateKey = Secp256k1.randomPrivateKey()

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

const payload =
  AuthorizationTempo.getSignPayload(authorization) // [!code focus]

const signature = Secp256k1.sign({ payload, privateKey })
const authorization_signed = AuthorizationTempo.from(
  authorization,
  { signature }
)
```

### P256

ECDSA signature using the P-256 (secp256r1) curve. Requires embedding the public key and a `prehash` flag indicating whether the payload was hashed before signing.

```ts twoslash
import { P256 } from 'ox'
import {
  AuthorizationTempo,
  SignatureEnvelope
} from 'ox/tempo'

const { privateKey, publicKey } = P256.createKeyPair()

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

const payload =
  AuthorizationTempo.getSignPayload(authorization) // [!code focus]

const signature = P256.sign({ payload, privateKey })
const signatureEnvelope = SignatureEnvelope.from({
  prehash: false,
  publicKey,
  signature
})
const authorization_signed = AuthorizationTempo.from(
  authorization,
  { signature: signatureEnvelope }
)
```

### P256 (WebCrypto)

When using WebCrypto keys, `prehash` must be `true` since WebCrypto always hashes the payload internally before signing.

```ts twoslash
// @noErrors
import { WebCryptoP256 } from 'ox'
import {
  AuthorizationTempo,
  SignatureEnvelope
} from 'ox/tempo'

const { privateKey, publicKey } =
  await WebCryptoP256.createKeyPair()

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

const payload =
  AuthorizationTempo.getSignPayload(authorization) // [!code focus]

const signature = await WebCryptoP256.sign({
  payload,
  privateKey
})
const signatureEnvelope = SignatureEnvelope.from({
  prehash: true,
  publicKey,
  signature
})
const authorization_signed = AuthorizationTempo.from(
  authorization,
  { signature: signatureEnvelope }
)
```

### WebAuthn

Passkey-based signature using WebAuthn. Includes authenticator metadata (authenticatorData and clientDataJSON) along with the P-256 signature and public key.

```ts twoslash
// @noErrors
import { WebAuthnP256 } from 'ox'
import {
  AuthorizationTempo,
  SignatureEnvelope
} from 'ox/tempo'

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

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

const challenge =
  AuthorizationTempo.getSignPayload(authorization) // [!code focus]

const { metadata, signature } = await WebAuthnP256.sign({
  challenge,
  credentialId: credential.id
})
const signatureEnvelope = SignatureEnvelope.from({
  signature,
  publicKey: credential.publicKey,
  metadata
})
const authorization_signed = AuthorizationTempo.from(
  authorization,
  { signature: signatureEnvelope }
)
```

## Definition

```ts
function getSignPayload(
  authorization: AuthorizationTempo.AuthorizationTempo,
): Hex.Hex
```

**Source:** [src/tempo/AuthorizationTempo.ts](https://github.com/wevm/ox/blob/main/src/tempo/AuthorizationTempo.ts#L954)

## Parameters

### authorization

* **Type:** `AuthorizationTempo.AuthorizationTempo`

The [`AuthorizationTempo.AuthorizationTempo`](/tempo/reference/AuthorizationTempo/types#authorizationtempo).

#### authorization.address

* **Type:** `abitype_Address`

Address of the contract to set as code for the Authority.

#### authorization.chainId

* **Type:** `numberType`

Chain ID to authorize.

#### authorization.nonce

* **Type:** `bigintType`

Nonce of the Authority to authorize.

#### authorization.signature

* **Type:** `SignatureEnvelope`
* **Optional**

## Return Type

The sign payload.

`Hex.Hex`
