AIBTC Working Group
  • AIBTC
  • Prompt2DAO
  • AIBTC Contracts
    • DAO Base Layer
    • DAO Extensions
      • Action Proposal Voting
      • DAO Charter
      • DAO Epoch
      • DAO Users
      • Onchain Messaging
      • Rewards Account
      • Token Owner
      • Treasury
    • DAO Proposals
      • Action Proposals
    • Agent Account
  • Agent Tools
    • Overview
    • Available Tools
      • Agent Account Tools
      • Agent Wallet Tools
      • DAO Tools
      • Database Tools
      • Faktory Tools
  • AIBTC Cache
    • Overview
    • Contract Calls
      • API Design
      • Endpoints
        • Decode Clarity Value
        • Read-Only Function Calls
        • Contract ABI
        • Known ABI Contracts
      • Clarity Value Types
      • Integration Examples
    • Cache Services
    • Error Handling
    • Utilities
  • Prompting
    • Action Proposal Prompts
    • Agent Account Prompts
  • Links
    • Common Terms
    • Our App
    • Discord
    • GitHub
    • Prompt2DAO on X
    • AIBTC on X
  • Templates
    • Template Style Guide
  • Documentation Templates
    • Smart Contract Documentation
    • Cache Service Documentation
    • Cache Endpoint Documentation
    • Agent Tool Documentation
    • Prompting Documentation
  • Example Implementations
    • Agent Account Example
    • Cache Service Example
    • Cache Endpoint Example
    • Agent Tool Example
Powered by GitBook
On this page
  • Key Features
  • Quick Reference
  • How It Works
  • Public Functions
  • callback
  • Read-Only Functions
  • get-current-dao-epoch
  • get-dao-epoch-length
  • Print Events
  • Error Handling
  • Security Considerations
  • Related Contracts
  1. AIBTC Contracts
  2. DAO Extensions

DAO Epoch

Tracks the current epoch of the DAO based on Bitcoin block progression.

PreviousDAO CharterNextDAO Users

Last updated 3 days ago

The DAO Epoch extension (aibtc-dao-epoch) provides a mechanism to track time in discrete periods called "epochs." These epochs are defined by a fixed number of Bitcoin blocks, allowing DAO operations and governance to be synchronized with the progression of the Bitcoin blockchain.

Key Features

  • Bitcoin Block-Based Epochs: Epochs are measured in Bitcoin blocks, providing a consistent and decentralized time reference.

  • Configurable Epoch Length: The duration of an epoch (in Bitcoin blocks) is a defined constant.

  • Read-Only Access: Provides functions to query the current epoch and the defined epoch length.

Quick Reference

Property
Value

Contract Name

aibtc-dao-epoch

Implements

.aibtc-dao-traits.extension, .aibtc-dao-traits.dao-epoch

Key Parameters

EPOCH_LENGTH (default: u4320 Bitcoin blocks, approx. 30 days)

How It Works

The extension calculates the current DAO epoch based on the number of Bitcoin blocks that have elapsed since the contract's deployment. It uses the burn-block-height (current Bitcoin block height), DEPLOYED_BURN_BLOCK (Bitcoin block height at contract deployment), and EPOCH_LENGTH (constant defining blocks per epoch). The formula is essentially (burn-block-height - DEPLOYED_BURN_BLOCK) / EPOCH_LENGTH.

Public Functions

callback

Purpose: Standard extension callback function required by the extension trait.

Parameters:

  • sender: principal - The principal that triggered the callback.

  • memo: (buff 34) - Optional memo data.

Returns: (response bool) - Returns (ok true) if the callback is processed.

Read-Only Functions

get-current-dao-epoch

Purpose: Gets the current DAO epoch number.

Parameters: None.

Returns: (ok uint) - The current epoch number.

get-dao-epoch-length

Purpose: Gets the defined length of a DAO epoch in Bitcoin blocks.

Parameters: None.

Returns: (ok uint) - The epoch length in Bitcoin blocks (e.g., u4320).

Print Events

This contract does not emit any print events.

Error Handling

This contract does not define custom error codes. Read-only functions return (ok ...) responses.

Security Considerations

  • Read-Only Nature: The primary functions are read-only and do not alter state, minimizing direct attack vectors.

  • Reliance on Stacks Chain Data: The accuracy of epoch calculation depends on the burn-block-height provided by the Stacks blockchain.

  • Immutability of Epoch Length: EPOCH_LENGTH is a constant; changing it would require deploying a new version of the contract.

Related Contracts

  • .aibtc-dao-traits.extension: Trait implemented by this extension.

  • .aibtc-dao-traits.dao-epoch: Trait implemented by this extension.

  • Any DAO contract or extension that needs to perform actions based on defined time periods (epochs).