Generate to Address

Requires wallet support.

The generatetoaddress RPC mines blocks immediately to a specified address.

Parameter #1—the number of blocks to generate

Name Type Presence Description
Blocks number (int) Required
(exactly 1)
The number of blocks to generate. The RPC call will not return until all blocks have been generated or the maxium number of iterations has been reached

Parameter #2—an address (P2PKH or P2SH)

Name Type Presence Description
Address string (base58) Required
(exactly 1)
The address to send the newly generated pai to

Parameter #3—the maximum number of iterations to try

Name Type Presence Description
Maxtries number (int) Optional
(0 or 1)
The maximum number of iterations that are tried to create the requested number of blocks. Default is 1000000

Result—the generated block header hashes

Name Type Presence Description
result array Required
(exactly 1)
An array containing the block header hashes of the generated blocks (may be empty if used with generate 0)

Header Hashes
string (hex) Required
(1 or more)
The hashes of the headers of the blocks generated, as hex in RPC byte order


Using regtest mode, generate 2 blocks with maximal 500000 iterations:

pai-cli -regtest generatetoaddress 2 "PaXVxzkruFZPidQjsDft9CW174Tr99xngu\
eBdYAyTMXW75" 500000



See also

  • Generate: nearly instantly generates blocks.
  • GetMiningInfo: returns various mining-related information.
  • GetBlockTemplate: gets a block template or proposal for use with mining software.