Skip to content

KeyAuthorization.getSignPayload

Computes the sign payload for an KeyAuthorization.KeyAuthorization.

The root key must sign this payload to authorize the access key. The resulting signature is attached to the key authorization via KeyAuthorization.from with the signature option.

Access Keys Specification

Imports

Named
import { KeyAuthorization } from 'ox/tempo'

Examples

import { Address, Secp256k1, Value } from 'ox'
import { KeyAuthorization } from 'ox/tempo'
 
const privateKey = '0x...'
const address = Address.fromPublicKey(Secp256k1.getPublicKey({ privateKey }))
 
const authorization = KeyAuthorization.from({
  address,
  expiry: 1234567890,
  type: 'secp256k1',
  limits: [{
    token: '0x20c0000000000000000000000000000000000001',
    limit: Value.from('10', 6),
  }],
})
 
const payload = KeyAuthorization.getSignPayload(authorization)

Definition

function getSignPayload(
  authorization: KeyAuthorization.KeyAuthorization,
): Hex.Hex

Source: src/tempo/KeyAuthorization.ts

Parameters

authorization

  • Type: KeyAuthorization.KeyAuthorization

The KeyAuthorization.KeyAuthorization.

authorization.address

  • Type: abitype_Address

Address derived from the public key of the key type.

authorization.chainId

  • Type: bigintType
  • Optional

Chain ID for replay protection (0 = valid on any chain).

authorization.expiry

  • Type: numberType
  • Optional

Unix timestamp when key expires (0 = never expires).

authorization.limits

  • Type: readonly TokenLimit[]
  • Optional

TIP20 spending limits for this key.

authorization.signature

  • Type: SignatureEnvelope
  • Optional

authorization.type

  • Type: "secp256k1" | "p256" | "webAuthn"

Key type. (secp256k1, P256, WebAuthn).

Return Type

The sign payload.

Hex.Hex