Skip to content

Period

Utilities for constructing period durations (in seconds) for recurring spending limits.

Periods define the reset interval for access key spending limits. A spending limit with a period will reset every period seconds. For example, a daily spending limit uses Period.days(1) (86400 seconds).

Examples

import { Value } from 'ox'
import { KeyAuthorization, Period } from 'ox/tempo'
 
const authorization = KeyAuthorization.from({
  address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
  chainId: 4217n,
  type: 'secp256k1',
  limits: [{
    token: '0x20c0000000000000000000000000000000000001',
    limit: Value.from('100', 6),
    period: Period.days(1), // resets daily
  }],
})

Access Keys Specification

Functions

NameDescription
Period.daysReturns the number of seconds in n days.
Period.hoursReturns the number of seconds in n hours.
Period.minutesReturns the number of seconds in n minutes.
Period.monthsReturns the number of seconds in n months (30 days).
Period.secondsReturns the number of seconds in n seconds.
Period.weeksReturns the number of seconds in n weeks.
Period.yearsReturns the number of seconds in n years (365 days).