ERGO
Time Locks & Access Control
Beginner
30 minutes

Block-Height Time Lock (Timelocked Payments)

Lock funds until a specific block height for scheduled payments

Problema

You need to lock funds until a future date for vesting, escrow, or scheduled payments.

Solución

ErgoScript can check the current block HEIGHT against a target. Funds remain locked until the blockchain reaches the specified height (~2 min/block on Ergo).

Cómo funciona

  1. 1Calculate target block height: current + (days * 720) for approximate timing
  2. 2Ergo averages ~2 minutes per block (720 blocks/day)
  3. 3Contract checks HEIGHT >= targetHeight before allowing spend
  4. 4Before target: funds are locked, no spending possible
  5. 5After target: only the designated beneficiary can claim

Ejemplos de código

{
  // Lock until block height 1,500,000
  val unlockHeight = 1500000
  val beneficiary = PK("9f...")  // Beneficiary public key
  
  // Can only spend after unlock height
  HEIGHT >= unlockHeight && proveDlog(beneficiary)
}

Simplest time lock. Funds are locked until the specified block height, then only the beneficiary can claim.

Casos de uso

  • Team token vesting schedules
  • Scheduled salary payments
  • Escrow with timeout refunds
  • Inheritance and succession planning
  • Delayed governance execution
  • Bond maturity contracts

Consideraciones de seguridad

  • !Block times can vary slightly - don't rely on exact timing
  • !Consider adding emergency unlock with multi-sig
  • !Test unlock conditions thoroughly on testnet
  • !Keep fee reserves for future unlock transactions

Recursos

Consideraciones de comisiones

Standard transaction fees. Reserve ~0.01 ERG for future unlock transaction.

Mejora tus habilidades en ErgoScript

Recibe notificaciones sobre nuevos patrones, tutoriales y recursos para desarrolladores.

Follow for daily updates