# BRISE Chain Relayer

## BRISE Relayer Guides <a href="#brise-relayer-guides" id="brise-relayer-guides"></a>

### Prepare Fund <a href="#prepare-fund" id="prepare-fund"></a>

1. Make sure that you have enough BRISE in your account. You can get from [faucet](https://faucet.brisescan.com/)

If you haven't created your account yet, please follow these guides to create one first.

* **100 BRISE** for relayer register
* More than 50 BRISE for transaction fee

Tip

Currently the brise-chain-relayer code is not fully prepared. Some features like `db persistence`, `alert`, `prometheus monitor` are still under development. So please don’t modify the configuration about db\_config, alert\_config, instrumentation\_config, admin\_config

&#x20;

### Steps to Install BRISE Relayer <a href="#steps-to-install-brise-relayer" id="steps-to-install-brise-relayer"></a>

1.Build from source code

Make sure that you have installed [Go 1.13+](https://golang.org/doc/install) and have added `GOPATH` to `PATH` environment variable

```
git clonehttps://github.com/Bitgert/brise-chain-relayer
# Enter the folder bsc was cloned into
cd nc-relayer
# Comile and install bsc
make build
```

or you can download the pre-build binaries from [release page](https://github.com/Bitgert/brise-chain-relayer/releases/tag/v1.1.0)

### Get Example Config File <a href="#get-example-config-file" id="get-example-config-file"></a>

Get example config from this url: <https://github.com/Bitgert/brise-chain-relayer/blob/master/config/config.json>

Edit`config.json` and fill your BRISE private key to bsc\_config.private\_key, example private key: `AFD8C5D83F148065176268A9D1EE375A10CEE1E74D15985D4CC63E467EC34DA5`

* Brise Chain Configuration:
  * `mnemonic`: Paste the recovery phrase here. Since nc-relayer will automaticly submit `double-sign` evidence, if it's committed, the reward will be sent to this address
* Brise Chain Configuration: \*

### Start Relayer <a href="#start-relayer" id="start-relayer"></a>

You can start Locally

```
./brise-chain-relayer --config-type local --config-path config.json
```

Output:

```
(base) huangsuyudeMacBook-Pro:mac huangsuyu$ nc-relayer --config-type local --config-path config.json
2020-05-27 17:01:16 INFO main Start relayer
2020-05-27 17:01:16 INFO SyncProtocol Sync cross chain protocol fromhttps://github.com/Bitgert/brise-chain-relayer-config.git
2020-05-27 17:01:18 INFO RegisterRelayerHub This relayer has already been registered
2020-05-27 17:01:18 INFO CleanPreviousPackages channelID: 1, next deliver sequence 55 on TC, next sequence 55 on BC
2020-05-27 17:01:18 INFO CleanPreviousPackages channelID: 2, next deliver sequence 1273 on TC, next sequence 1273 on BC
2020-05-27 17:01:18 INFO CleanPreviousPackages channelID: 3, next deliver sequence 6 on TC, next sequence 6 on BC
2020-05-27 17:01:19 INFO CleanPreviousPackages channelID: 8, next deliver sequence 5 on TC, next sequence 5 on BC
2020-05-27 17:01:19 INFO RelayerDaemon Start relayer daemon
2020-05-27 17:01:19 INFO Serve start admin server at 0.0.0.0:8080
```

Or, dynamic Sync Cross Chain Protocol Configuration from <https://github.com/Bitgert/brise-chain-relayer-config>

* Edit config.json and change "cross\_chain\_config.protocol\_config\_type" to "remote". Then relayer will dynamically sync cross chain protocol configuration from this repository: <https://github.com/Bitgert/brise-chain-relayer-config>
* Start relayer service

```
./nc-relayer --config-type local --config-path config.json
```

#### Verify Status <a href="#verify-status" id="verify-status"></a>

You could call [RelayerHub Contract](https://brisescan.com/address/0x0000000000000000000000000000000000001006) to verify that your relayer is registered. Go to [read contract](https://brisescan.com/address/0x0000000000000000000000000000000000001006#readContract) and call **isRelayer** function. If it returns **true**, then your relayer is working properly.

### Relayer Rewards <a href="#relayer-rewards" id="relayer-rewards"></a>

1. You can witness the distribution of relayer rewards in the log of system contract: <https://brisescan.com/address/0x0000000000000000000000000000000000001005#events>. According to the design of [Relayer Incentive](https://docs.brisescan.com/smart-chain/guides/concepts/incentives.html), the rewards will be distributed every 1000 data packages. The total accumulated rewards can be read from [contract](https://brisescan.com/address/0x0000000000000000000000000000000000001005#readContract) the value of `_collectedRewardForHeaderRelayer` and `_collectedRewardForTransferRelayer`.
2. Query your relayer's status

The total accumulated relayed count can be read from [contract](https://brisescan.com/address/0x0000000000000000000000000000000000001005#readContract) the value of `_transferRelayersSubmitCount`

### Stop Relayer <a href="#stop-relayer" id="stop-relayer"></a>

To get your locked **100 BRISE** back, you need to call [RelayerHub Contract](https://brisescan.com/address/0x0000000000000000000000000000000000001006) to unregister your relayer. The fee is **0.1 BRISE**

* Go to MyEtherWallet and [interact with contract](https://www.myetherwallet.com/interface/interact-with-contract)
* Fill in the contract address: **0x0000000000000000000000000000000000001006** with [abi](https://docs.brisescan.com/smart-chain/system-smart-contract/relayerhub.abi) interface
* Call **unregister** function and leave value in ETH as 0
* Sign your transaction in **MetaMask**

<br>
