Skip to content

Advancing blocks ​

Some contract logic depends on time: PoX cycles, unlock heights, time-locked redemptions, bridge finalization, oracle freshness. The AdvanceBlocks step adds bitcoin (burn) blocks and Stacks blocks on top of a simulation's fork, so you can step past those boundaries inside one session.

The step ​

json
{ "AdvanceBlocks": { "bitcoin_blocks": 2, "stacks_blocks_per_bitcoin": 1 } }
FieldRequiredMeaning
bitcoin_blocksyesBurn blocks to add. May be 0 only with stacks_blocks_per_bitcoin > 0, which adds Stacks blocks to the current tenure.
stacks_blocks_per_bitcoinyesStacks blocks per burn block; at least 1 when bitcoin_blocks > 0.
bitcoin_interval_secsnoBurn block time step, default 600.
burn_header_hashesnoOverride the header hash of burn block i (0-based within this step), 32-byte hex.
pox_addrsnoOverride PoX payout addresses and amount per burn block.
vrf_seedsnoOverride the VRF seed per burn block, 32-byte hex.

The result lists each new block. From a real session forked at Stacks block 1044660:

json
{
  "AdvanceBlocks": {
    "Ok": [
      { "stacks_height": 1044661, "burn_height": 894279, "coinbase_height": 194338,
        "block_time": 1745816675, "burn_block_time": 1745816675, "tenure_change": true,
        "index_block_hash": "92dc00f6…", "burn_header_hash": "d46c59da…", "vrf_seed": "1dd053c2…" },
      { "stacks_height": 1044662, "burn_height": 894280, "coinbase_height": 194339,
        "block_time": 1745817275, "burn_block_time": 1745817275, "tenure_change": true, "…": "…" }
    ]
  }
}

Later steps run at the new tip, so height- and time-dependent Clarity (burn-block-height, get-burn-block-info? and so on) sees the advanced chain.

The session tip ​

GET /devtools/v2/simulations/{id}/tip returns where the session is now. After an AdvanceBlocks step it is the last synthetic block ("synthetic": true, with vrf_seed and tenure_change); before, it is the fork point ("synthetic": false).

json
{ "synthetic": true, "stacks_height": 1044662, "burn_height": 894280, "coinbase_height": 194339,
  "block_time": 1745817275, "burn_block_time": 1745817275, "epoch": "3.1", "tenure_change": true, "…": "…" }

With the SDK ​

ts
import { SimulationBuilder, getSimulationTip } from 'stxer'

const id = await SimulationBuilder.new()
  .withSender('SP…')
  .addContractCall({ /* request a redemption */ })
  .addAdvanceBlocks({ bitcoin_blocks: 144, stacks_blocks_per_bitcoin: 1 }) // about one day
  .addContractCall({ /* claim after the lock */ })
  .run()

const tip = await getSimulationTip(id)
console.log(tip.synthetic, tip.burn_height)

A tip: to learn the parent burn height before computing how many blocks you need, advance with bitcoin_blocks: 0, stacks_blocks_per_bitcoin: 1 first and read the tip.

Worked scenarios (locked STX unlock, sBTC deposit, BTC peg-in, vault cooldowns) are in the SDK's samples on GitHub.