# Time to the next Juno halving calculation ## Formula **Time left until halving in seconds = blockTime * ((targetSupply - totalSupply) / (annualProvisions / blocksPerYear))** ## Explanation - **blockTime** = the time in seconds between two blocks: - if you have access to Mintscan API you can get it directly from: `https://api.mintscan.io/v1/juno/block/blocktime?blocks=10000`, - otherwise, infer it by subtracting the timestamps of two blocks from the official RCP endpoints: - most recent block time = `/cosmos/base/tendermint/v1beta1/blocks/latest`.block.header.time - most recent block height = `/cosmos/base/tendermint/v1beta1/blocks/latest`.block.header.height - time of an old block (by height) = `/cosmos/base/tendermint/v1beta1/blocks/15872771`.block.time - convert the times to timestamps in seconds, subtract the old from the latest and divide by the number of blocks in between (the difference between the heights) - **targetSupply** = defined on genesis for the end of each inflation phase (see [x/mint](https://github.com/CosmosContracts/juno/blob/main/x/mint/types/minter.go#L50) and the [tokenomics article](https://medium.com/@JunoNetwork/jun%C3%B8-tokenomics-and-utility-powering-the-worlds-first-fully-interoperable-smart-contract-ce9f490c4d97)), eg: `130735901` for Phase 4, to be multiplied by 10^6 for the ujuno base denomination - **totalSupply** = get it from the official RPC endpoint & query for the native coin at `/cosmos/bank/v1beta1/supply/by_denom?denom=ujuno`.amount.amount - **annualProvisions** = get it from the official RPC endpoint at `/cosmos/mint/v1beta1/annual_provisions`.annual_provisions - **blocksPerYear** = get it from the official RPC endpoint at `/cosmos/mint/v1beta1/params`.params.blocks_per_year