Getblocktemplate

getblocktemplate ( "template_request" )

If the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.
It returns data needed to construct a block to work on.
For full specification, see BIPs 22, 23, 9, and 145:
    https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki
    https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki
    https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes
    
Arguments:
1. template_request         (json object, optional, default={}) Format of the template
     {
       "mode": "str",       (string, optional) This must be set to "template", "proposal" (see BIP 23), or omitted
       "capabilities": [    (json array, optional) A list of strings
         "support",         (string) client side supported feature, 'longpoll', 'coinbasetxn', 'coinbasevalue', 'proposal', 'serverlist', 'workid'
         ...
       ],
     }

Result (If the proposal was accepted with mode=='proposal'):
null    (json null)

Result (If the proposal was not accepted with mode=='proposal'):
"str"    (string) According to BIP22

Result (Otherwise):
{                                 (json object)
  "version" : n,                  (numeric) The preferred block version
  "previousblockhash" : "str",    (string) The hash of current highest block
  "transactions" : [              (json array) contents of non-coinbase transactions that should be included in the next block
    {                             (json object)
      "data" : "hex",             (string) transaction data encoded in hexadecimal (byte-for-byte)
      "txid" : "hex",             (string) transaction id encoded in little-endian hexadecimal
      "hash" : "hex",             (string) hash encoded in little-endian hexadecimal
      "depends" : [               (json array) array of numbers
        n,                        (numeric) transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is
        ...
      ],
      "fee" : n,                  (numeric) difference in value between transaction inputs and outputs (in satoshis); for coinbase transactions, this is a negative Number of the total collected block fees (ie, not including the block subsidy); if key is not present, fee is unknown and clients MUST NOT assume there isn't one
      "sigchecks" : n             (numeric) total sigChecks, as counted for purposes of block limits; if key is not present, sigChecks are unknown and clients MUST NOT assume it is zero
    },
    ...
  ],
  "coinbaseaux" : {               (json object) data that should be included in the coinbase's scriptSig content
    ...
  },
  "coinbasevalue" : n,            (numeric) maximum allowable input to coinbase transaction, including the generation award and transaction fees (in satoshis)
  "coinbasetxn" : {               (json object) information for coinbase transaction
    "minerfund" : {               (json object) information related to the coinbase miner fund
      "addresses" : [             (json array) List of valid addresses for the miner fund output
        ...
      ],
      "minimumvalue" : n          (numeric) The minimum value the miner fund output must pay
    },
    "stakingrewards" : {          (json object) information related to the coinbase staking reward output, only set after the Nov. 15, 2023 upgrade activated and the -avalanchestakingrewards option is enabled
      "payoutscript" : {          (json object) The proof payout script
        "asm" : "str",            (string) Decoded payout script
        "hex" : "hex",            (string) Raw payout script in hex format
        "type" : "str",           (string) The output type (e.g. nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata)
        "reqSigs" : n,            (numeric) The required signatures
        "addresses" : [           (json array)
          "str",                  (string) eCash address
          ...
        ]
      },
      "minimumvalue" : n          (numeric) The minimum value the staking reward output must pay
    },
    ...
  },
  "target" : "str",               (string) The hash target
  "mintime" : xxx,                (numeric) The minimum timestamp appropriate for the next block time, expressed in UNIX epoch time
  "mutable" : [                   (json array) list of ways the block template may be changed
    "str",                        (string) A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'
    ...
  ],
  "noncerange" : "hex",           (string) A range of valid nonces
  "sigchecklimit" : n,            (numeric) limit of sigChecks in blocks
  "sizelimit" : n,                (numeric) limit of block size
  "curtime" : xxx,                (numeric) current timestamp in UNIX epoch time
  "bits" : "str",                 (string) compressed target of next block
  "height" : n                    (numeric) The height of the next block
}

Examples:
> bitcoin-cli getblocktemplate 
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblocktemplate", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/