---
title: Epoch Management
description: API reference for Trust Bonding epoch management functions
url: https://docs.intuition.systems/docs/v1/protocol/api-reference/trust-bonding/epochs
markdown_url: https://docs.intuition.systems/docs/v1/protocol/api-reference/trust-bonding/epochs.md
version: V1
llms_index: https://docs.intuition.systems/docs/v1/llms.txt
---

Functions for managing and querying epoch information in the Trust Bonding contract.

## trustBondingCurrentEpoch

Get the current epoch number.

### trustBondingCurrentEpoch - Returns

```typescript
Promise<bigint> // Current epoch number
```

### trustBondingCurrentEpoch - Example

```typescript
import { trustBondingCurrentEpoch, getContractAddressFromChainId } from '@0xintuition/protocol'

const bondingAddress = getContractAddressFromChainId('TrustBonding', chainId)
const epoch = await trustBondingCurrentEpoch({ address: bondingAddress, publicClient })
console.log('Current epoch:', epoch)
```

## trustBondingPreviousEpoch

Get the previous epoch number.

### trustBondingPreviousEpoch - Returns

```typescript
Promise<bigint>
```

### trustBondingPreviousEpoch - Example

```typescript
import { trustBondingPreviousEpoch } from '@0xintuition/protocol'

const prevEpoch = await trustBondingPreviousEpoch({ address: bondingAddress, publicClient })
console.log('Previous epoch:', prevEpoch)
```

## trustBondingEpochAtTimestamp

Get the epoch number for a specific timestamp.

### trustBondingEpochAtTimestamp - Parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| config | `ReadConfig` | Contract address and publicClient | Yes |
| args | `[bigint]` | Unix timestamp | Yes |

### trustBondingEpochAtTimestamp - Returns

```typescript
Promise<bigint> // Epoch number at timestamp
```

### trustBondingEpochAtTimestamp - Example

```typescript
import { trustBondingEpochAtTimestamp } from '@0xintuition/protocol'

const timestamp = BigInt(Math.floor(Date.now() / 1000))
const epoch = await trustBondingEpochAtTimestamp(
  { address: bondingAddress, publicClient },
  { args: [timestamp] }
)
console.log('Epoch at timestamp:', epoch)
```

## trustBondingEpochTimestampEnd

Get the end timestamp for an epoch.

### trustBondingEpochTimestampEnd - Parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| config | `ReadConfig` | Contract address and publicClient | Yes |
| args | `[bigint]` | Epoch number | Yes |

### trustBondingEpochTimestampEnd - Returns

```typescript
Promise<bigint> // Epoch end timestamp
```

### trustBondingEpochTimestampEnd - Example

```typescript
import { trustBondingEpochTimestampEnd } from '@0xintuition/protocol'

const endTime = await trustBondingEpochTimestampEnd(
  { address: bondingAddress, publicClient },
  { args: [epochNumber] }
)

const endDate = new Date(Number(endTime) * 1000)
console.log('Epoch ends:', endDate.toISOString())
```

## trustBondingEpochLength

Get the length of an epoch in seconds.

### trustBondingEpochLength - Returns

```typescript
Promise<bigint> // Epoch duration in seconds
```

### trustBondingEpochLength - Example

```typescript
import { trustBondingEpochLength } from '@0xintuition/protocol'

const length = await trustBondingEpochLength({ address: bondingAddress, publicClient })
console.log('Epoch length:', length, 'seconds')
console.log('In days:', Number(length) / 86400)
```

## trustBondingEpochsPerYear

Get the number of epochs per year.

### trustBondingEpochsPerYear - Returns

```typescript
Promise<bigint>
```

### trustBondingEpochsPerYear - Example

```typescript
import { trustBondingEpochsPerYear } from '@0xintuition/protocol'

const epochsPerYear = await trustBondingEpochsPerYear({ address: bondingAddress, publicClient })
console.log('Epochs per year:', epochsPerYear)
```

## See Also

- [Core Concepts: Epochs](https://docs.intuition.systems/docs/v1/protocol/core-concepts/epochs)
- [Trust Bonding Rewards](https://docs.intuition.systems/docs/v1/protocol/api-reference/trust-bonding/rewards)
