import { Callout } from 'nextra/components';
import { Tabs } from 'nextra/components';
import { VarInfo } from 'components/variable-info.tsx';
import { Steps } from 'nextra/components'

# Bonding Nym Node

<Callout type="warning" emoji="⚠️">
To you unbond your Nym Node means you are leaving Nym network and you will lose all your delegations (permanently). You can join again with the same identity key, however, you will start with **no delegations**.
</Callout>

Nym Mixnet operators are rewarded for their work every epoch (60 minutes). To prevent centralisation, [Nym API](../validator-setup/nym-api.mdx) is ran by distributed validators on Nyx blockchain.

You are asked to `sign` a transaction and bond your node to Nyx blockchain so that the Mixnet smart contract is able to map your nym address to your node. This allows us to create a nonce for each account and defend against replay attacks.

**Before you bond your `nym-node` make sure you went through all the previous steps**

1. [Build](../../binaries/building-nym.mdx) or [download](../../binaries/pre-built-binaries.mdx) `nym-node` binary
2. [Configure VPS]( ../preliminary-steps/vps-setup.mdx) correctly
3. [Prepare Nym wallet](../preliminary-steps/wallet-preparation.mdx)
4. [Setup & Run](setup.mdx) the node
5. [Configure your node](configuration.mdx)

<Callout type="warning" emoji="⚠️">
Do not bond your node to the API if the previous steps weren't finished. Bad connectivity, closed ports, or other poor setup will result in your node getting blacklisted.
</Callout>


Any new bonded node will provide only the bare minimum information: host, identity key and optionally custom port of its HTTP API - we highly recommend to set that one up to `8080`. Everything else will be discovered via the self-described API for maximum flexibility. This also includes the sphinx key, meaning if the API is not exposed, the node will be unable to route any traffic.

**Every operator has to make sure that their nodes [self-described endpoint works](nodes/performance-and-testing/node-api-check#basic-api-usage), otherwise the node will be un-routable and thus won't get any rewards!**

## Bond via the Desktop wallet (recommended)

You can bond your `nym-node` via the Desktop wallet.

<Steps>

###### 1. Insert bonding information

- Open your wallet, and head to the `Bonding` page and click on `Bond` Button, and input your node details. Press `Next`.
- To find out your `nym-node` details, run this command in your VPS:
```sh
./nym-node bonding-information --id <ID>
```
- To get a correct host address, run this command in your VPS
```sh
echo "$(curl -4 https://ifconfig.me)"
```

###### 2. Bond to correct HTTP port

- In your wallet: Open the box called `Show advanced options` and make sure that your `Custom HTTP port` is set correctly like in your `config.toml`. **We strongly recommend to keep it on default `8080`.** For reference these are the ports used by `nym-node`:

| Node type              | Port name                           | Correct port value |
| :--                    | :--                                 | :--                |
| Mixnode                | Mix port                            | `1789`             |
| Mixnode                | Verloc port                         | `1790`             |
| Mixnode                | HTTP api port (picture below)       | `8080`             |
| Gateway (entry & exit) | Mix port                            | `1789`             |
| Gateway (entry & exit) | Client WS API port                  | `9000`             |

- Use own `ID_KEY`, and `Host`, which can be either your IPv4 address or hostname:

![](/images/operators/wallet-screenshots/bonding_nym-node.png)

###### 3. Enter your values and sign with your node

- Enter the `Amount`, `Operating cost` and `Profit margin` and press `Next`

<Callout type="warning" emoji="⚠️">
If you are part of [Nym Delegation Program](https://delegations.explorenym.net) or Service Grants Program, make sure your values are within the [rules](https://forum.nymtech.net/t/nym-delegations-program-update/466) of the programs. Operators setting up larger OP or PM than defined in the rules will be excluded from the program without prior warning!
</Callout>

- You will be asked to run a `sign` command with your `nym-node` - copy and paste the long signature as the value of `--contract-msg` and sing it on your VPS:

```sh
./nym-node sign --contract-msg <PAYLOAD_GENERATED_BY_THE_WALLET>
```

- Copy the resulting signature string and paste it into the wallet nodal, press `Next` and confirm the transaction:

```sh
# This is just an example, copy the one from your process
>>> The base58-encoded signature is:
2bbDJSmSo9r9qdamTNygY297nQTVRyQaxXURuomVcRd7EvG9oEC8uW8fvZZYnDeeC9iWyG9mAbX2K8rWEAxZBro1
```

![Paste Signature](/images/operators/wallet-screenshots/wallet-sign.png)

*This image is just an example, copy-paste your own base58-encoded signature*

</Steps>

Your node will now be bonded and ready to receive traffic, latest at the beginning of the next epoch (at most 1 hour).


If everything worked, you'll see your node running on the either the [Sandbox testnet network explorer](https://sandbox-explorer.nymtech.net) or the [mainnet network explorer](https://explorer.nymtech.net), depending on which environment you're running.

<Callout type="warning" emoji="">
**After migration to `nym-node` in Mixnet smart contract, many explorers, includyng Nym explorers will not pick up value correctly. While we are working on Nym Explorer v2, we would like to invite operators to use [Nym Harbourmaster](https://harbourmaster.nymtech.net) to track their nodes.**
</Callout>

## Change Settings via Desktop Wallet

In case you decide to change any settings like `custom HTTP port` or your `host` from an IP address to a hostname, don't forget to announce it to the API via changing these values in the desktop wallet.

- Go back to `Bonding` page, click on `Nym Node Settings` and change the values like in this example:

![](/images/operators/wallet-screenshots/settings_nym-node.png)


## Migrate to `nym-node` in Mixnet Smart Contract

From `nym-wallet` version `1.2.15` onward the application allows and prompts operators to migrate their gateway or mixnode to a `nym-node` in the Mixnet smart contract - an important step in [project smoosh](../../archive/faq/smoosh-faq.mdx). To do so follow these steps:

<Steps>

###### 1. Download the latest wallet from [the release page](https://github.com/nymtech/nym/releases)

###### 2. Verify the binary and extract it if needed

- Download [`hashes.json`](https://github.com/nymtech/nym/releases/download/nym-wallet-v1.2.15/hashes.json)
- Open it with your text editor or print it's content with `cat hashes.json`
- Run `sha256sum <WALLET_BINARY>` for example `sha256sum ./nym-wallet_1.2.15_amd64.AppImage`
- If your have to extract it (like `.tar.gz`) do it

###### 3. Open the wallet and sign in

###### 4. Migrate!

- Go to Bonding and you will be prompted with such message:

![](/images/operators/wallet-screenshots/migrate_nym-node.png)

- In case you for some reason didn't see the prompt or you closed it - you can click in the upper right corner of the same window on this button:

![](/images/operators/wallet-screenshots/migrate_nym-node2.png)

- Confirm the transaction

###### 5. Welcome to new episode of `nym-node`!

</ Steps>

<Callout type="warning" emoji="⚠️">
Versions older than `nym-wallet v 1.2.15` will not allow bonding new nodes.
</Callout>

## Bond via the CLI (power users)

If you want to bond your Mix Node via the CLI, then check out the [relevant section in the Nym CLI](https://nymtech.net/docs/tools/nym-cli.html#bond-a-mix-node) docs.
