Skip to main content

generatetoaddress

Overview

The 'generatetoaddress' method allows you to generate a specified number of blocks to a particular address. This can be useful for mining applications or for generating new blocks in a test environment.

Request

wget --no-check-certificate --quiet \
--method POST \
--timeout=0 \
--header 'Content-Type: application/json' \
--header 'accept: application/json' \
--header 'X-CoinAPI-Key: 4303fb63-adec-42dc-b571-74bc2f2a5167' \
--body-data '{"jsonrpc":"2.0","id":1,"method":"generatetoaddress","params": [ ]}
' \
'https://bitcoin-mainnet.node.coinapi.io'

Request Parameters

  • number_of_blocks (integer): The number of blocks to generate.
  • address (string): The address to which the newly generated blocks should be sent.

Response

{
"result": null,
"error": {
"code": -1,
"message": "generatetoaddress nblocks \"address\" ( maxtries )\n\nMine to a specified address and return the block hashes.\n\nArguments:\n1. nblocks (numeric, required) How many blocks are generated.\n2. address (string, required) The address to send the newly generated bitcoin to.\n3. maxtries (numeric, optional, default=1000000) How many iterations to try.\n\nResult:\n[ (json array) hashes of blocks generated\n \"hex\", (string) blockhash\n ...\n]\n\nExamples:\n\nGenerate 11 blocks to myaddress\n> bitcoin-cli generatetoaddress 11 \"myaddress\"\nIf you are using the Bitcoin Core wallet, you can get a new address to send the newly generated bitcoin to with:\n> bitcoin-cli getnewaddress \n"
},
"id": 1
}