Create a random burn address

Generate burn addresses for permanently removing tokens from circulation


(define-read-only (generate-burn-address (entropy (string-ascii 40)))
(let (
;; Hash the entropy to create address bytes
(hash-bytes (hash160 (unwrap-panic (to-consensus-buff? entropy))))
;; Use version byte for current network
(version-byte (if is-in-mainnet 0x16 0x1a))
)
;; Construct a valid principal that no one controls
(principal-construct? version-byte hash-bytes)
)
)
;; Example: Generate unique burn address
(generate-burn-address "BURN-2024-01-15-PROJECT-XYZ")
;; Returns: (ok SP1FJPSG7V4QMA7D4XVPZ3B2HQ8GY3EK8GC0NGNT3)

Use cases

  • Token burning mechanisms
  • Proof-of-burn implementations
  • Creating unspendable addresses for protocol fees
  • Deflationary token economics

Key concepts

Burn addresses are valid principals that:

  • No private key: Generated from arbitrary data, not a key pair
  • Verifiable: Anyone can verify tokens sent to these addresses
  • Unique: Different entropy creates different addresses
  • Permanent: Funds sent are irretrievably lost

Generate multiple burn addresses

;; Create categorized burn addresses
(define-constant BURN_FEES (unwrap-panic (generate-burn-address "PROTOCOL-FEES-BURN")))
(define-constant BURN_PENALTY (unwrap-panic (generate-burn-address "PENALTY-BURN")))
(define-constant BURN_BUYBACK (unwrap-panic (generate-burn-address "BUYBACK-BURN")))
;; Burn tokens to specific category
(define-public (burn-as-fee (amount uint))
(stx-transfer? amount tx-sender BURN_FEES)
)
(define-public (burn-as-penalty (amount uint))
(stx-transfer? amount tx-sender BURN_PENALTY)
)

Time-based burn addresses

;; Generate daily burn addresses
(define-read-only (get-daily-burn-address (day uint))
(generate-burn-address (concat "DAILY-BURN-" (int-to-ascii day)))
)
;; Track burns by period
(define-map daily-burns uint uint)
(define-public (burn-to-daily-address (amount uint))
(let (
(today (/ block-height u144)) ;; ~144 blocks per day
(burn-address (unwrap-panic (get-daily-burn-address today)))
(current-burned (default-to u0 (map-get? daily-burns today)))
)
(try! (stx-transfer? amount tx-sender burn-address))
(map-set daily-burns today (+ current-burned amount))
(ok burn-address)
)
)

Verifiable burn registry

(define-map burn-records
{ burner: principal, burn-id: uint }
{ amount: uint, address: principal, reason: (string-ascii 50) }
)
(define-data-var burn-nonce uint u0)
(define-public (record-burn (amount uint) (reason (string-ascii 50)))
(let (
(nonce (var-get burn-nonce))
(burn-address (unwrap-panic (generate-burn-address
(concat reason (int-to-ascii nonce))))
)
)
;; Transfer to burn address
(try! (stx-transfer? amount tx-sender burn-address))
;; Record the burn
(map-set burn-records
{ burner: tx-sender, burn-id: nonce }
{ amount: amount, address: burn-address, reason: reason }
)
;; Increment nonce
(var-set burn-nonce (+ nonce u1))
(ok { burn-id: nonce, address: burn-address })
)
)

SIP-10 token burning

;; Burn fungible tokens to a generated address
(define-public (burn-ft-tokens
(token <ft-trait>)
(amount uint)
(burn-reason (string-ascii 50)))
(let (
(burn-address (unwrap-panic (generate-burn-address
(concat "FT-BURN-" burn-reason))))
)
(contract-call? token transfer
amount
tx-sender
burn-address
none)
)
)
Important

Tokens sent to burn addresses are permanently lost. Always double-check addresses and amounts before burning. Consider implementing confirmation mechanisms for large burns.