# Run a Collator

{% tabs %}
{% tab title="Polkadot Mainnet" %}

Bifrost Mainnet:

<https://polkadot.js.org/apps/?rpc=wss://hk.p.bifrost-rpc.liebi.com/ws#/explorer>

### Download Chain Spec

* Bifrost chain spec: [bifrost-polkadot.json](https://raw.githubusercontent.com/bifrost-io/bifrost/refs/heads/develop/node/service/res/bifrost-polkadot.json)
* [Bifrost Binary](https://github.com/bifrost-io/bifrost/releases/download/bifrost-v0.15.0/bifrost)
* [Bifrost Source Code](https://github.com/bifrost-io/bifrost)

### Run a Collator Node

#### before start node

need to generate node-key (corresponding peer-id) ,command is

```
bifrost key generate-node-key
# this is just example, you must generate your only-one node-key
12D3KooWHhmkowJ4hNT1BUXDV1vuvLj49JdjMUfwJyFSniM3qu1k    # peer-node-key
902bbfd87bf7cc7b639095e8a7dc73462fb6a04f10a8c38b0f49b10abd8f5a71 # node-key for command args
```

#### strart node

```bash
/path/to/bifrost \
--collator \
--chain </path/to/bifrost-polkadot.json> \
--base-path <DATA_PATH> \
--node-key <YOUR_NODE_KEY> \
--ws-port=9944 \
--port=30333 \
--prometheus-external \
--state-cache-size 0 \
-- \
--chain polkadot 
```

### Set SessionKey

#### Generate SessionKey

```
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params":[]}' http://COLLATOR_IP:9933
```

**Set SessionKey**

![](https://hackmd.io/_uploads/rJYHbu4ec.png)

#### Get the Size of the Candidate Pool <a href="#get-the-size-of-the-candidate-pool" id="get-the-size-of-the-candidate-pool"></a>

First, you need to get the `candidatePool` size (this can change through governance) as you'll need to submit this parameter in a later transaction. To do so, you'll have to run the following JavaScript code snippet from within [Polkadot.js](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fwss.api.moonbase.moonbeam.network#/js):

```
// Simple script to get candidate pool size
const candidatePool = await api.query.parachainStaking.candidatePool();
console.log(`Candidate pool size is: ${candidatePool.length}`);
```

Head to the **Developer** tab, select **JavaScript** from the dropdown, and take the following steps:

1. Copy the code from the previous snippet and paste it inside the code editor box. (Optional) Click the save icon and set a name for the code snippet, for example, "Get candidatePool size". This will save the code snippet locally
2. To execute the code, click on the run button
3. Copy the result, as you'll need it when joining the candidate pool

<figure><img src="https://757947912-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJFtVsA5N3spWTWKvFvv0%2Fuploads%2FV7S1TgOQEXj2zuDe9jnx%2Fimage.png?alt=media&#x26;token=c1a328ec-1563-430c-b207-2ea70a279dee" alt=""><figcaption></figcaption></figure>

### Apply for Candidate

* **extrinsic**

parameters:

bond: candidate bonding amount 5,000,000,000,000,000 (5,000 BNCs)

candidateCount: existing candidate amount

![](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVzXa22j6fsQEjpS4Ht-887967055%2Fuploads%2FtfssX4wF5hBA7vXFzcu6%2Fimage.png?alt=media\&token=77de5ff5-af90-41c0-8798-e64c3ce47a4c)

* **event**

![](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVzXa22j6fsQEjpS4Ht-887967055%2Fuploads%2FD7Xvho6Gvlah9O9czqa8%2Fimage.png?alt=media\&token=50647990-4fab-4361-85b3-62ab64628eff)

If the total amount of Total Bonded is in the top 16, after 2 rounds, the new Collator can start to generate blocks and receive rewards.

<figure><img src="https://757947912-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJFtVsA5N3spWTWKvFvv0%2Fuploads%2FIK0qe41YJvpLvdNAMfxD%2Fimage.png?alt=media&#x26;token=7fc00e91-0c5a-47a6-8e84-b33808c1811f" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Kusama Mainnet" %}
Bifrost Mainnet:

[https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fus.bifrost-rpc.liebi.com%2Fws#](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fus.bifrost-rpc.liebi.com%2Fws)

### Download Chain Spec

* Bifrost chain spec: [bifrost-kusama.json](https://github.com/bifrost-io/bifrost/blob/develop/node/service/res/bifrost-kusama.json)
* [Bifrost Binary](https://github.com/bifrost-io/bifrost/releases/download/bifrost-v0.15.0/bifrost)
* [Bifrost Source Code](https://github.com/bifrost-io/bifrost)

### Run a Collator Node

#### before start node

need to generate node-key (corresponding peer-id) ,command is

```
bifrost key generate-node-key
# this is just example, you must generate your only-one node-key
12D3KooWHhmkowJ4hNT1BUXDV1vuvLj49JdjMUfwJyFSniM3qu1k    # peer-node-key
902bbfd87bf7cc7b639095e8a7dc73462fb6a04f10a8c38b0f49b10abd8f5a71 # node-key for command args
```

#### strart node

```bash
/path/to/bifrost \
--collator \
--chain </path/to/bifrost-kusama.json> \
--base-path <DATA_PATH> \
--node-key <YOUR_NODE_KEY> \
--ws-port=9944 \
--port=30333 \
--prometheus-external \
--state-cache-size 0 \
-- \
--chain kusama \
--execution wasm
```

### Set SessionKey

#### Generate SessionKey

```
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params":[]}' http://COLLATOR_IP:9933
```

**Set SessionKey**

![](https://hackmd.io/_uploads/rJYHbu4ec.png)

#### Get the Size of the Candidate Pool <a href="#get-the-size-of-the-candidate-pool" id="get-the-size-of-the-candidate-pool"></a>

First, you need to get the `candidatePool` size (this can change through governance) as you'll need to submit this parameter in a later transaction. To do so, you'll have to run the following JavaScript code snippet from within [Polkadot.js](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fwss.api.moonbase.moonbeam.network#/js):

```
// Simple script to get candidate pool size
const candidatePool = await api.query.parachainStaking.candidatePool();
console.log(`Candidate pool size is: ${candidatePool.length}`);
```

Head to the **Developer** tab, select **JavaScript** from the dropdown, and take the following steps:

1. Copy the code from the previous snippet and paste it inside the code editor box. (Optional) Click the save icon and set a name for the code snippet, for example, "Get candidatePool size". This will save the code snippet locally
2. To execute the code, click on the run button
3. Copy the result, as you'll need it when joining the candidate pool

<figure><img src="https://757947912-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJFtVsA5N3spWTWKvFvv0%2Fuploads%2FV7S1TgOQEXj2zuDe9jnx%2Fimage.png?alt=media&#x26;token=c1a328ec-1563-430c-b207-2ea70a279dee" alt=""><figcaption></figcaption></figure>

### Apply for Candidate

* **extrinsic**

parameters:

bond: candidate bonding amount 5,000,000,000,000,000 (5,000 BNCs)

candidateCount: existing candidate amount

![](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVzXa22j6fsQEjpS4Ht-887967055%2Fuploads%2FtfssX4wF5hBA7vXFzcu6%2Fimage.png?alt=media\&token=77de5ff5-af90-41c0-8798-e64c3ce47a4c)

* **event**

![](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVzXa22j6fsQEjpS4Ht-887967055%2Fuploads%2FD7Xvho6Gvlah9O9czqa8%2Fimage.png?alt=media\&token=50647990-4fab-4361-85b3-62ab64628eff)

If the total amount of Total Bonded is in the top 16, after 2 rounds, the new Collator can start to generate blocks and receive rewards.

<figure><img src="https://757947912-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJFtVsA5N3spWTWKvFvv0%2Fuploads%2FIK0qe41YJvpLvdNAMfxD%2Fimage.png?alt=media&#x26;token=7fc00e91-0c5a-47a6-8e84-b33808c1811f" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}
