# Become a Solana Transmitter

This guide will walk you through how to become a Solana transmitter. From wallet details to transmitter setup, we'll cover it all here.

## Dependencies

Before beginning make sure to install all of the necessary dependencies and tools. In this guide we'll be using several, including:

* [libusd](https://libusb.sourceforge.io/api-1.0/index.html), an open source library that allows communication with USB devices fom user space.
* [foundry](https://github.com/foundry-rs/foundry), a modular toolkit for Ethereum application development.
* [docker](https://www.docker.com/), a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers.

{% tabs %}
{% tab title="Mac" %}

```bash
brew install python
brew install pipx       
pipx install base58
brew install libusb
curl -L https://foundry.paradigm.xyz | bash
foundryup
```

{% endtab %}

{% tab title="Linux" %}
{% hint style="warning" %}
For the Zsh shell, use source "\~/.zshenv" instead of source "\~/.bashrc".
{% endhint %}

{% hint style="warning" %}
If pipx install base58 doesn’t work, try using: python3 -m pip install base58
{% endhint %}

```bash
sudo apt update
sudo apt install pipx
pipx install base58
sudo apt install curl build-essential libssl-dev pkg-config
sudo apt install libusb-1.0-0-dev
curl -L https://foundry.paradigm.xyz | bash
~./bashrc  
foundryup
```

{% endtab %}
{% endtabs %}

To verify the successful installation of dependencies, you can run the following command.

```bash
cast --version
```

If everything was successfully installed, the output should be the version of the cast command, as shown below.

```
cast 0.2.0 (31c24b0 2024-11-14T00:20:56.080456000Z)
```

## Wallet Setup

{% hint style="warning" %}
Your Solana wallet should only hold SOL tokens. The security of other tokens is not guaranteed.
{% endhint %}

To become an transmitter on Solana you need two wallets. An EVM standard wallet and a Solana standard wallet. To proceed you need to convert your wallets into a format suitable for transmitter registration, below we describe the process.

{% tabs %}
{% tab title="Convert a Solana Wallet to Hex" %}
For your Solana wallet (\<solana\_wallet>) in Base58 format, run the following command.

{% code overflow="wrap" %}

```
python3 -c "import base58; import sys; print('0x' + base58.b58decode(sys.argv[1]).hex())" <solana_wallet>
```

{% endcode %}

* Example for a Solana Wallet:
  * Hj12XrWQmcfRZk4nEejLRvF3tE5QXk5EpxmMm3zZzQbC (Base58)
* Hexadecimal Representation (Output):  &#x20;
  * 0xf87d6a27b105812cdaf3ade4ba67fe501092df51a716671db13f05387dc04603
    {% endtab %}

{% tab title="Convert an EVM Wallet to Hex" %}
For your EVM wallet (\<evm\_address>), run the following command.

{% code overflow="wrap" %}

```
cast to-uint256 <evm_address>
```

{% endcode %}

* Example for a EVM Wallet:
  * 0xff22Fb238CfA1013A793FC917F242F9f82a61417
* Hexadecimal Representation (Output):  &#x20;
  * 0x000000000000000000000000ff22fb238cfa1013a793fc917f242f9f82a61417
    {% endtab %}
    {% endtabs %}

## 1. Registration

Make sure that you have the native network token on Entangle and that you have added the Entangle network address to your wallet.

* Node:  [https://json-rpc.entangle.fi](https://json-rpc.entangle.fi/)
* Chain Id:  33033

Now run the following command to register your transmitter in the desired network.

```bash
cast send 0xB83E7753CAB418775f0dc91ACfcfECba24FE62C1 \
    "registerAgent(uint,address,bytes[])" \
    <chain_id> \
    <evm_address> \
    "[<hex_address_evm>, <hex_address_solana>, <hex_address_evm>, <hex_address_evm>]" \
    -r "https://json-rpc.entangle.fi" \
    --private-key <private_key>
```

<details>

<summary>Command Parameter Explanation</summary>

The cast command includes several parameters, here we've described them.

* The HEX address at the begining is the address of our AgentRegistrator contract
* \<chain\_id> is the Blockchain Id (for Solana, use 11100000000000000501).
* \<evm\_address> is your EVM wallet address (master key).
* \<hex\_address\_evm> is the hex representation of your EVM wallet.
* \<hex\_address\_solana> is the hex representation of your Solana wallet.
* \<private\_key> is the private key of your EVM wallet (in EVM format).
  * Expl. \[\<hex\_evm\_1>, \<hex\_solana\_1>, \<hex\_evm2>, \<hex\_evm\_3>]
    * \<hex\_address\_evm\_1> is used to execute transactions in EIB.
      * \<hex\_address\_solana\_1> is used to execute transactions in Solana .
      * \<hex\_address\_evm\_2> rewards will be distributed to this address.
      * \<hex\_address\_evm\_3> reserved.

</details>

If you encounter the error tx already in mempool, try adding the following optional parameter:

```
--gas-price <actual gas in chain> * 2
```

To get the actual gas price in the network, run:

```
cast gas-price -r "https://json-rpc.entangle.fi"
```

## 2. Security Deposit

To ensure your transmitter works as expected you are required to stake a security deposit. A minimum of 100 NTGL is required.

Run the cast command again but this time with the follow parameters.

{% code overflow="wrap" %}

```
cast send 0x2897F9093bE0B5d5F9067c6f7842B949017eE830 "deposit(uint256,address,uint256)" <chainID> <agent-address> <wntgl-value> -r https://json-rpc.entangle.fi --private-key <your_key> --value <ntgl-value>
```

{% endcode %}

<details>

<summary>Command Parameter Explanation</summary>

{% hint style="warning" %}
Set WNTGL amount to 0 if you want to use NTGL for staking and vice versa, set NTGL amount to 0 if you want to use WNTGL for staking.
{% endhint %}

The cast command includes several parameters, here we've described them.

1. The HEX address at the begining is the address of the RewardVaults contract which is responsible for distributing rewards among UIP participants
2. \<chainID> is the blockchain ID where the agent will be deployed (e.g., 146 for Sonic).
3. \<agent-address> is the EVM wallet address (master key).
4. \<wntgl-value> is the amount of security deposit (in wei) min 100WNTGL&#x20;
5. \<your key> is the wallet’s private key.

</details>

## 3. Docker Environment Setup

To simplify this process, we've created a docker image. In this part we will describe how to install and setup docker.

{% tabs %}
{% tab title="Ubuntu" %}
{% stepper %}
{% step %}
Update the system.

```bash
sudo apt update && sudo apt upgrade -y
```

{% endstep %}

{% step %}
Install dependencies.

```bash
sudo apt install -y ca-certificates curl gnupg
```

{% endstep %}

{% step %}
Add the official Docker GPG key.

{% code overflow="wrap" %}

```bash
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo tee /etc/apt/keyrings/docker.asc > /dev/null
sudo chmod a+r /etc/apt/keyrings/docker.asc
```

{% endcode %}
{% endstep %}

{% step %}
Add the Docker repository.

{% code overflow="wrap" %}

```bash
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
```

{% endcode %}
{% endstep %}

{% step %}
Install Docker and Docker Compose.

{% code overflow="wrap" %}

```bash
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```

{% endcode %}
{% endstep %}

{% step %}
Verify the installation.

```bash
docker --version
docker compose version
```

{% endstep %}

{% step %}
Add the current user to the Docker group (to run commands without using sudo).

```bash
sudo usermod -aG docker $USER
```

{% endstep %}

{% step %}
Then log out and log back in, or run.

```bash
newgrp docker
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Mac" %}
{% stepper %}
{% step %}
Install Docker via Homebrew

```
brew install --cask docker
```

{% endstep %}

{% step %}
Launch Docker Desktop

Simply find it in your applications and open it.
{% endstep %}

{% step %}
Verify the installation

```
docker --version
docker compose version
```

{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}

## 4. Starting the Transmitter

{% stepper %}
{% step %}
Update the docker image.

```
docker pull msentangle/agent:3.0
docker pull msentangle/agent-setup:3.0
docker pull msentangle/solana:3.0
```

{% endstep %}

{% step %}
Create a directory for the transmitter and move to it.

```
mkdir transmitter
cd transmitter
```

{% endstep %}

{% step %}
Start the transmitter.

{% hint style="warning" %}
If you want this transmitter to be a super transmitter you need to specify "-e IS\_SUPER\_AGENT=true".
{% endhint %}

```
docker run --rm \
  -v $(pwd)/.:/app/agent/ \
  -e PRIVATE_KEY="yourprivatekey" \
  -e PASSWORD="yourpassword" \
  -e NON_EVM_CHAINS="11100000000000000501" \
  -e SOLANA_PRIVATE_KEY="solanaprivate" \
  msentangle/agent-setup:3.0
```

<details>

<summary>Command Parameter Explanation</summary>

1. **yourprivatekey** is your wallet's private key.
2. **yourpassword** is your desired password to encrypt the private key.
3. **solanaprivate** is the private key of your Solana wallet.

</details>

{% hint style="info" %}
The program will generate a default configurations for the selected networks.
{% endhint %}

After the successful execution of the program, you will see the message:

```
Your Address: 0x96564904617F27722C522D4Ed9D0e7b9911Aa5cC please check correct

2:57PM WRN > contract has no events Contract Name=Slasher
...
```

{% endstep %}
{% endstepper %}

## Choosing a Transmitter Name

You can also set a unique name for your transmitter to more easily distinguish it. Run the below command to do so.

```
docker-compose -p <agent-name> up -d
```

<details>

<summary>Command Parameter Explanation</summary>

1. \<agent-name> is where you provide the unique name for the agent (e.g. agent-sonic-1).

</details>

## Change Round

You can either wait for another participant to make changes to the round or update the round yourself. Run the following command to change the round.

{% hint style="info" %}
You can check the fees for changing the round in the logs of the evm\_agent program.
{% endhint %}

{% code overflow="wrap" %}

```
docker exec -it <agent-name>-evm_agent-1 sh -c "apk add curl && curl 'http://localhost:9131/turnround?chainId=<chain_id>'"
```

{% endcode %}

<details>

<summary>Command Parameter Explanation</summary>

1. \<agent-name> the name of the agent (e.g. agent-sonic-1).
2. \<chain\_id> is the blockchain Id (for Sonic, use 146).

</details>

## Change Node

You can change blockchain providers (RPC nodes) by modifying the *configs/solana/transmitter-config.yml* file. You can add multiple nodes to ensure high availability

{% code title="transmitter-config.yml" %}

```yaml
solana:
    read_rpcs:
        - url: https://api.mainnet-beta.solana.com
          ratelimit: 4
    write_rpcs:
        - url: https://api.mainnet-beta.solana.com
          ratelimit: 1
```

{% endcode %}

### Additional Configuration Parameters

Below are additional configuration parameters you can use for the blockchain provider source configuration file.

<table><thead><tr><th width="246.00006103515625">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>parse_new_headers_interval</td><td>How often to update blockchain information (e.g.,  5s,  1m).</td></tr><tr><td>max_query_in_batch</td><td>The number of requests in a single batch request.</td></tr><tr><td>filter_logs_max_blocks</td><td>The maximum difference between fromBlock  and toBlock.</td></tr><tr><td>blocks_delay</td><td>The maximum difference between block shifts.</td></tr><tr><td>blocks_batch_to_filter</td><td>The minimum number of blocks to process.</td></tr><tr><td>min_balance_to_alert</td><td>The minimum wallet balance for notifications (in wei).</td></tr></tbody></table>

## Withdraw Security Deposit & Stopping Transmitter

To withdraw your security deposit and stop being a transmitter, run the following command.

{% code overflow="wrap" %}

```
cast send 0x2897F9093bE0B5d5F9067c6f7842B949017eE830 "withdraw(uint256,address,uint256,bool)" <chain_id> <agent-address> <nglt-amount> <flag> -r "https://json-rpc.entangle.fi" --private-key <private-key>
```

{% endcode %}

<details>

<summary>Command Parameter Explanation</summary>

1. The HEX address at the begining is the address of the RewardVaults contract which is responsible for distributing rewards among UIP participants
2. \<chainID> is the Blockchain Id.
3. \<agent-address> is the EVM wallet address  (master key).
4. \<nglt-amount> is the amount in wei.
5. \<flag> if set to true, WNGL will be unwrapped and sent to the wallet (you will receive NGL), otherwise WNGL will be sent wrapped (you will receive WNGL)
6. \<your key> is the wallet’s private key.

</details>

## Troubleshooting

<details>

<summary>Insufficient Funds</summary>

Make sure there are enough native tokens in the wallet to cover the transaction fees.

</details>

<details>

<summary>Git Command Not Found</summary>

Install git using the command below.

```bash
sudo apt install git -y
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.entangle.fi/universal-interoperability-protocol/developer-guides/solana/become-a-solana-transmitter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
