What is the Difference Between Clarity’s Block-Height and Burn-Block-Height?

Daniel Pericich
3 min readAug 16, 2022
Photo by Shubham Dhage on Unsplash

Clarity comes with a number of built in keywords that give us access to the Stacks blockchain and principal data in our smart contracts. Some of these items include being able to determine and access the smart contract or transaction calling address. Two very important keywords we have are block-height and burn-block-height.

What is Block-Height

The block-height keyword allows us to get the current block height of the Stacks blockchain. This keyword allows us access to the state of the blockchain. This state can drive our logic for timing, or other dependent events.

A classic example of use of block-height is to set events happening in the future. Stacks doesn’t use a time based primitive variable, so we have to approach time from another direction. Stacks’s target block time is 10 minutes. This metric measures the average amount of time between blocks being added to the blockchain.

It’s not millisecond precision, but having a unit of time measurement with block time will allow us to schedule events. Using the block-height, we can set events to trigger when the current block height plus the amount of time times block time has occurred. Thus if we want do something a week from the transaction being called we can calculate that it will happen in ~1008 blocks.

What is Burn-Block-Height

Similar to block-height, burn-block-height gives us a block height for a specific blockchain. However, this time the block height is the Bitcoin blockchain’s block height. One of the important parts of Stacks being built on Bitcoin is that we get unparalleled access to the state of the Bitcoin blockchain.

With this access we are able to read state and base events on the Stacks blockchain from events on the Bitcoin blockchain. If you wanted to time a Stacks’s smart contract event off the Bitcoin blockchain’s block height, all you’d need to do is use burn-block-height instead of Stacks’s block-height.

Why Do we Call it Burn-Block-Height

The Stacks blockchain uses a special consensus mechanism called Proof of Transfer, often abbreviated as PoX. This mechanism incentivizes miners to mine by promising newly minted STX and the block’s associated transaction fees as reward for spending BTC to win blocks and performing the block mining.

This consensus mechanism is seen as being more resource efficient as all miners transfer BTC to the blockchain in order to have the chance to win the block. Once a miner wins the block, only one miner will mine and then add the new block to the blockchain. This is different from Proof of Work as we do not have all the miners completing the work to create the new block.

Originally, Stacks used the PoB or Proof of Burn mechanism. Though this is more resource efficient than Proof of Work, as we don’t have multiple miners using resources on the same task, it is still inefficient as the miner must “burn” or destroy Bitcoin by sending it to a burn address.

It is because of this original consensus mechanism that we have the name burn-block-height. In this case we are referring to the Bitcoin blockchain as the burn blockchain because it is the chain whose resources we must destroy to secure our transactions.

Conclusion

I hope that you now understand the difference between the block-height and burn-block-height keywords. Both are useful for us to be able to access and utilize the different blockchain’s state. Because of the lack of time measurement in seconds, these block height keywords are incredibly helpful to our ability to time and execute smart contract operations.

Notes

https://docs.stacks.co/docs/write-smart-contracts/clarity-language/language-keywords#block-height

https://docs.stacks.co/docs/write-smart-contracts/clarity-language/language-keywords#burn-block-height

https://docs.stacks.co/docs/understand-stacks/technical-specs

--

--

Daniel Pericich

Former Big Beer Engineer turned Full Stack Software Engineer