# Consensus Tutorial

`mind_sdk_fcn` is a **Native Rust SDK** by [Mind Network](https://www.mindnetwork.xyz/)

### Quick Start

**TFHE-rs-v1.0.0** marks the first official stable release, see more details [here](https://github.com/zama-ai/tfhe-rs/releases/tag/tfhe-rs-1.0.0). **Rustc-v1.84.0** is required to compile TFHE-rs v1.0.0. You can upgrade rustc like `rustup update stable`.

#### Install

```
[dependencies]
mind_sdk_fcn = "*
```

#### build

```
cargo build --debug
cargo build --release
```

#### run

```
cd msn
cargo build && ./target/debug/mind_sdk_fcn --log-level=info --node-config-file=./config/config_fcn.toml check-fcn-wallet-address
cargo run --log-level=debug --node-config-file=./config/config_fvn.toml register 0x06eF5C5ba427434bf36469B877e4ea9044D1b735
```

### CLI Help

```sh
# ./bin/fcn --help

FHE Decryption Node Cli

Usage: fcn [OPTIONS] <COMMAND>

Commands:
  check-fcn-wallet-address  check fcn wallet address, by default will use ./config/testnet_config_fcn.toml
  check-gas-balance         check fcn wallet gas balance, need gas fee to talk onchain
  run-once                  Run in loop mode
  run-loop                  Run in loop mode
  check-rewards             check received rewards onchain
  check-tx                  check voting tx history on the explore
  help                      Print this message or the help of the given subcommand(s)

Options:
      --node-config-file <NODE_CONFIG_FILE>
          fcn config file, contains all the config to run fcn [default: ./config/testnet_config_fcn.toml]
      --log-level <LOG_LEVEL>
          control level of print, useful for debug, default is info [default: info] [possible values: debug, info, warn, error]
      --fcn-wallet-private-key <FDN_WALLET_PRIVATE_KEY>
          fcn wallet private key is needed if to load a different wallet from testnet_config_fcn.toml to sign the message onchain, by default load from ./config/testnet_config_fcn.toml
      --from-block-number <FROM_BLOCK_NUMBER>
          starting block number, if not set, will use the value in node_config_file
  -h, --help
          Print help
  -V, --version
          Print version
```

### CLI Example

```sh
## command
./bin/randgen --log-level=info --node-config-file=./config/testnet_config_fcn.toml check-fcn-wallet-address
{
  "app": "fcn",
  "command": "check-fcn-wallet-address",
  "arg": "",
  "status": true,
  "result": "0x161FE9d92689D27653c63984f3195811491167A0",
  "note": ""
}

## command
./bin/randgen --log-level=info --node-config-file=./config/testnet_config_fcn.toml check-gas-balance
{
  "app": "fcn",
  "command": "check-gas-balance",
  "arg": "fcn_wallet: 0x161FE9d92689D27653c63984f3195811491167A0",
  "status": true,
  "result": "29307405505000000",
  "note": ""
}

## command
./bin/randgen --log-level=info --node-config-file=./config/testnet_config_fcn.toml check-rewards
{
  "app": "fcn",
  "command": "check-rewards",
  "arg": "fcn_wallet: 0x161FE9d92689D27653c63984f3195811491167A0",
  "status": true,
  "result": "0",
  "note": "fcn_wallet: 0x161FE9d92689D27653c63984f3195811491167A0, received_rewards: 0"
}

## command
./bin/randgen --log-level=debug --from-block-number=100000 --node-config-file=./config/testnet_config_fcn.toml run-once
{
  "app": "fcn",
  "command": "register",
  "arg": "hot_wallet: 0x6224F72f1439E76803e063262a7e1c03e86c6Dbd, voter_wallet: 0x06eF5C5ba427434bf36469B877e4ea9044D1b735",
  "status": true,
  "result": "registration successful !",
  "note": "is_registered: true, hot_wallet: 0x6224F72f1439E76803e063262a7e1c03e86c6Dbd, voter_wallet: 0x06eF5C5ba427434bf36469B877e4ea9044D1b735"
}

## command
./bin/randgen --log-level=info --from-block-number=100000 --node-config-file=./config/testnet_config_fcn.toml check-tx
{
  "app": "fcn",
  "command": "check-tx",
  "arg": "0x51B5de8555cc55f62c039c3aA3d9a5eBF8Fc30EE",
  "status": true,
  "result": "check on the explore: testnet: https://explorer-testnet.mindnetwork.xyz/address/0x51B5de8555cc55f62c039c3aA3d9a5eBF8Fc30EE, mainnet: https://explorer.mindnetwork.xyz/address/0x51B5de8555cc55f62c039c3aA3d9a5eBF8Fc30EE",
  "note": ""
}
```

### **License**

This project is licensed under the **MIT License**.
