> For the complete documentation index, see [llms.txt](https://dicdoc.gitbook.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dicdoc.gitbook.io/doc/smart-chain-api/generating.md).

# Generating

### generate

**generate numblocks**

::: tip This function can only be used in the **regtest** mode (for testing purposes). :::

The `generate` method instructs the coin daemon to immediately mine the indicated number of blocks.

#### Arguments

| Name      | Type      | Description                              |
| --------- | --------- | ---------------------------------------- |
| numblocks | (numeric) | the desired number of blocks to generate |

#### Response

| Name        | Type    | Description                |
| ----------- | ------- | -------------------------- |
| blockhashes | (array) | hashes of blocks generated |

**📌 Examples**

Command:

```
./komodo-cli generate 2
```

\<collapse-text hidden title="Response">

```
[
  "0475316d63fe48bb9d58373595cb334fc2553f65496edfb2fb17b9ed06f4c480",
  "00d29a2b7dec52baa9ab8e4264363f32b4989eef7dbb0a9932fbc11274195b5a"
]
```

\</collapse-text>

### getgenerate

**getgenerate**

The `getgenerate` method returns a boolean value indicating the server's mining status.

The default value is false.

::: tip See also **gen**. :::

#### Arguments

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| (none) | (none) |             |

#### Response

| Name       | Type      | Description                                           |
| ---------- | --------- | ----------------------------------------------------- |
| true/false | (boolean) | indicates whether the server is set to generate coins |

**📌 Examples**

Command:

```
./komodo-cli getgenerate
```

\<collapse-text hidden title="Response">

```
false
```

\</collapse-text>

You can find your `rpcuser`, `rpcpassword`, and `rpcport` in the coin's `.conf` file.

Command:

```
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getgenerate", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/
```

\<collapse-text hidden title="Response">

```
{
  "result": false,
  "error": null,
  "id": "curltest"
}
```

\</collapse-text>

### setgenerate

**setgenerate generate ( genproclimit )**

The `setgenerate` method allows the user to set the `generate` property in the coin daemon to `true` or `false`, thus turning generation (mining/staking) on or off.

Generation is limited to [genproclimit](https://app.gitbook.com/basic-docs/smart-chains/smart-chain-setup/common-runtime-parameters.html#genproclimit) processors. Set `genproclimit` to `-1` to use maximum available processors.

::: tip See also the [getgenerate](https://app.gitbook.com/basic-docs/smart-chains/smart-chain-api/generate.html#getgenerate) method to query the current setting, and [genproclimit](https://app.gitbook.com/basic-docs/smart-chains/smart-chain-setup/common-runtime-parameters.html#genproclimit) for setting the default number of processors the daemon uses through the `.conf` file. :::

#### Arguments

| Name         | Type                | Description                                                                     |
| ------------ | ------------------- | ------------------------------------------------------------------------------- |
| generate     | (boolean, required) | set to true to turn on generation; set to off to turn off generation            |
| genproclimit | (numeric, optional) | set the processor limit for when generation is on; use value "-1" for unlimited |

#### Response

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| (none) | (none) |             |

**📌 Examples**

**Activate mining with maximum available processors**

Command:

```
./komodo-cli setgenerate true -1
```

\<collapse-text hidden title="Response">

```
(none)
```

\</collapse-text>

**Activate staking**

Command:

```
./komodo-cli setgenerate true 0
```

\<collapse-text hidden title="Response">

```
(none)
```

\</collapse-text>

**Activate mining with 4 threads**

Command:

```
./komodo-cli setgenerate true 4
```

\<collapse-text hidden title="Response">

```
(none)
```

\</collapse-text>

**Check the setting**

Command:

```
./komodo-cli getgenerate
```

\<collapse-text hidden title="Response">

```
true
```

\</collapse-text>

**Turn off generation**

Command:

```
./komodo-cli setgenerate false
```

\<collapse-text hidden title="Response">

```
(none)
```

\</collapse-text>

**Turning the setting on via json RPC**

Command:

```
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "setgenerate", "params": [true, 1] }' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/
```

\<collapse-text hidden title="Response">

```
{
  "result": null,
  "error": null,
  "id": "curltest"
}
```

\</collapse-text>
