The target for the next block is available in getblocktemplate but I can not figure out if there is a way to get the target without also getting all of the pending transactions, which can take a very long time and generate lots of data.

You could also use getbestblock to get the top block and then use getblockheader to get the previous 2016 blocks and then do the math based on the times, but again this is very slow and data heavy.

Is there a fast way to determine the target for the next block from bitcoin-core over RPC?

3 Answers 3


You can easly calculate that from the difficulty

So just with the RPC call getdifficulty calculate this:

target = targetmax / difficulty

Where targetmax = 26959535291011309493156476344723991336010898738574164086137773096960

target max is a fix number from the genesis block

If the hash value (Converted to decimal) is lower then this value, it's a valid Block

  • 4
    That reports the difficulty of the last block, not the next block. May 7, 2021 at 2:54

Is there a fast way to determine the target for the next block from bitcoin-core over RPC?

Not really, there's no special RPC command to have the future target.

The target is the number you need to get below to mine a block. The target adjusts every 2016 blocks. That's very important to take into account.

First, you have to get the last target block information by doing a getblockchaininfo RPC command. Then you will be able to access to 3 interesting JSON fields which are the best block height (blocks), the best block hash (bestblockhash) and the current difficulty (difficulty).

Secondly, you must calculate a modular operation which is :

enter image description here

There are 2 choices :

  • If the result is different from 0, you will be able to use the same target for the next block ! You'll notice there's no field called "target" in JSON-RPC, so in this step you have to do :

target = targetmax / difficulty

where targetmax = 0xffff0000000000000000000000000000000000000000000000000000 and represents a fix number from the genesis block

  • If the result is 0, you shall calculate the new target thanks to the difficulty field : work out the ratio of the actual time against the expected time. Note : blocks represent the number of blocks in the blockchain not the last block height. The lastBlockHeight = blocks - 1

There's a code for the second choice. This is available : https://learnmeabitcoin.com/technical/target#code.

I think the second step is a little bit complicated. Note that the first step is most often called (the easier) and that the second will be used sometimes.

Tell me if you see a mistake by posting a comment, Loopite.

  • Yes, trivial when there is not a difficulty adjustment but looking for a general solution that does not require reading the previous 2016 block headers. Obviously Bitcoin core knows this number (it needs it to verify the next block) but sadly does not seem to make it available efficiently. Thanks!
    – bigjosh
    Jun 1, 2022 at 20:28

You can now get the target for the next block without all the transactions using this command...

bitcoin-cli getblocktemplate "{\"rules\":[\"segwit\"]}"

...which returns this relatively short datastructure that contains the target...

  "capabilities": [
  "version": 536870912,
  "rules": [
  "vbavailable": {
  "vbrequired": 0,
  "previousblockhash": "0000000000000000000204567a1893c68560ac05decc823e264ee90ccc122e07",
  "transactions": [
  "coinbaseaux": {
  "coinbasevalue": 625000000,
  "longpollid": "0000000000000000000204567a1893c68560ac05decc823e264ee90ccc122e07434",
  "target": "0000000000000000000838300000000000000000000000000000000000000000",
  "mintime": 1670613493,
  "mutable": [
  "noncerange": "00000000ffffffff",
  "sigoplimit": 80000,
  "sizelimit": 4000000,
  "weightlimit": 4000000,
  "curtime": 1670616125,
  "bits": "17083830",
  "height": 766672,
  "default_witness_commitment": "6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.