> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Submit a Genesis Transaction

> Submit a Genesis Transaction to the StateSet Commerce Network

# Submit a `gentx` for the **Stateset Commerce Network** Testnet

**Network:** `stateset-1-testnet`
**Denom:** `ustst` (micro‑STST)
**Plan:** This testnet simulates **stateset `v0.0.8`**.

***

## Quick Start (Copy/Paste)

> Replace `<moniker-name>` and `<key-name>` with your own values.
> Default home in this doc is `~/.stateset`. If your build uses `~/.statesetd`, adjust paths or pass `--home ~/.statesetd`.

```bash theme={null}
# 0) If you've run Stateset before: stop & clean
sudo systemctl stop statesetd 2>/dev/null || true
statesetd unsafe-reset-all --home ~/.stateset 2>/dev/null || true
rm -f ~/.stateset/config/genesis.json
rm -rf ~/.stateset/config/gentx/

# 1) Build statesetd (source, v0.0.8)
# Requires Go >= 1.17 and a working GOPATH/GOBIN
git clone https://github.com/stateset/core
cd core
git checkout v0.0.8
make build && make install

# Sanity check
statesetd version    # expected format example: latest-8e35a4d3

# 2) Initialize node home
statesetd init <moniker-name> --chain-id=stateset-1-testnet --home ~/.stateset

# 3) Fetch the testnet genesis (one of these will be current in the repo)
# Preferred (genesis.json for testnet)
curl -s https://raw.githubusercontent.com/stateset/networks/testnets/main/stateset-1-testnet/genesis.json \
  > ~/.stateset/config/genesis.json

# (Alternate fallback used in earlier instructions)
# curl -s https://raw.githubusercontent.com/stateset/networks/main/stateset-1-testnet/pregenesis.json \
#   > ~/.stateset/config/genesis.json

# 4) Create a key (choose a secure backend)
statesetd keys add <key-name> --keyring-backend os --home ~/.stateset

# 5) Add a genesis account with funds (10,000 STATE = 10,000,000,000 ustate)
statesetd add-genesis-account $(statesetd keys show <key-name> -a --keyring-backend os --home ~/.stateset) \
  10000000000ustate --home ~/.stateset

# 6) Create your gentx (self-delegate 9,000 STATE = 9,000,000,000 ustate)
# Minimal:
statesetd gentx <key-name> 9000000000ustate \
  --chain-id=stateset-1-testnet \
  --keyring-backend os \
  --home ~/.stateset

# (Advanced: include validator metadata & commission params)
# statesetd gentx <key-name> 9000000000ustate \
#   --commission-max-change-rate "0.05" \
#   --commission-max-rate "0.20" \
#   --commission-rate "0.01" \
#   --moniker "<moniker-name>" \
#   --identity "" \
#   --website "" \
#   --details "" \
#   --security-contact "" \
#   --chain-id=stateset-1-testnet \
#   --keyring-backend os \
#   --home ~/.stateset

# 7) Validate your genesis
statesetd validate-genesis --home ~/.stateset

# 8) Submit the gentx via PR to the networks repo (see "Submit" section below)
# Your gentx file will be at:
#   ~/.stateset/config/gentx/gentx-*.json
```

***

## “First!” — If you’re resetting from a previous run

1. **Stop your node**

   ```bash theme={null}
   sudo systemctl stop statesetd 2>/dev/null || true
   pkill -f statesetd 2>/dev/null || true
   ```

2. **Unsafe reset**

   ```bash theme={null}
   statesetd unsafe-reset-all --home ~/.stateset
   ```

3. **Remove old genesis & gentxs**

   ```bash theme={null}
   rm -f ~/.stateset/config/genesis.json
   rm -rf ~/.stateset/config/gentx/
   ```

4. **Proceed with the gentx flow** below.

> **Heads‑up:** Some older builds default to `~/.statesetd` instead of `~/.stateset`. If your setup uses `~/.statesetd`, swap the home path (or pass `--home ~/.statesetd` on each command).

***

## Prerequisites

* **Golang ≥ 1.17** installed and on your `PATH`
* `git`, `curl`, and basic build tools
* (Recommended) A configured **GOPATH/GOBIN**

**Example environment setup** (Linux/macOS):

```bash theme={null}
# Add to ~/.profile or ~/.zshrc then `source` it
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GO111MODULE=on
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
```

If in doubt:

```bash theme={null}
mkdir -p ~/go
export GOPATH=~/go
```

***

## Build the `statesetd` Binary

### Option A — Build from Source (recommended for v0.0.8)

```bash theme={null}
git clone https://github.com/stateset/core
cd core
git checkout v0.0.8
make build && make install
```

This installs `statesetd` into `$GOBIN` (commonly `~/go/bin`). Ensure it’s on your `PATH`.

Verify:

```bash theme={null}
statesetd version
# example output: latest-8e35a4d3
```

### Option B — Starport/Ignite (alternative)

If you prefer Starport:

```bash theme={null}
curl https://get.starport.network/starport! | bash
git clone https://github.com/stateset/core
cd core
starport chain build
# Move the built binary into your PATH if needed:
sudo mv ./build/statesetd /usr/local/bin/
```

> **Note:** Version parity matters for the testnet. If you use Starport, confirm `statesetd version` aligns with the testnet commit/tag.

***

## Minimum Hardware

* **RAM:** 8–16 GB
* **Disk:** 100 GB (SSD recommended)
* **CPU:** 2 cores

***

## Generate Your `gentx`

1. **Init your node**

   ```bash theme={null}
   statesetd init <moniker-name> --chain-id=stateset-1-testnet --home ~/.stateset
   ```

2. **Pull the testnet genesis**

   ```bash theme={null}
   curl -s https://raw.githubusercontent.com/stateset/networks/testnets/main/stateset-1-testnet/genesis.json \
     > ~/.stateset/config/genesis.json
   ```

   *(Alternate earlier path used in some guides: `.../main/stateset-1-testnet/pregenesis.json`)*

3. **Create a key**

   ```bash theme={null}
   statesetd keys add <key-name> --keyring-backend os --home ~/.stateset
   ```

4. **Add a funded genesis account**

   ```bash theme={null}
   statesetd add-genesis-account $(statesetd keys show <key-name> -a --keyring-backend os --home ~/.stateset) \
     10000000000ustate --home ~/.stateset
   ```

5. **Create the gentx**
   **Minimal form:**

   ```bash theme={null}
   statesetd gentx <key-name> 9000000000ustate \
     --chain-id=stateset-1-testnet \
     --keyring-backend os \
     --home ~/.stateset
   ```

   **Advanced (with metadata & commission):**

   ```bash theme={null}
   statesetd gentx <key-name> 9000000000ustate \
     --commission-max-change-rate "0.05" \
     --commission-max-rate "0.20" \
     --commission-rate "0.01" \
     --moniker "<moniker-name>" \
     --identity "" \
     --website "" \
     --details "" \
     --security-contact "" \
     --chain-id=stateset-1-testnet \
     --keyring-backend os \
     --home ~/.stateset
   ```

   Success looks like:

   ```
   Genesis transaction written to "/home/<you>/.stateset/config/gentx/gentx-******.json"
   ```

6. **Validate**

   ```bash theme={null}
   statesetd validate-genesis --home ~/.stateset
   ```

***

## Submit Your `gentx`

1. **Fork** the networks repo: [https://github.com/stateset/networks](https://github.com/stateset/networks)
2. **Clone your fork:**

   ```bash theme={null}
   git clone https://github.com/<your-github-username>/networks
   cd networks
   ```
3. **Copy your gentx** into the testnet folder:

   ```bash theme={null}
   mkdir -p testnets/stateset-1-testnet/gentx
   cp ~/.stateset/config/gentx/gentx*.json ./testnets/stateset-1-testnet/gentx/
   ```
4. **Commit & push, then open a PR** back to `stateset/networks`.

> **Acceptance note:** Only PRs from individuals/groups with a history of successfully running nodes may be accepted to ensure the network launches on time.

***

## Tips & Troubleshooting

* **Home directory differences**
  Some environments use `~/.statesetd` as the default. Either:

  * pass `--home ~/.statesetd` to every command, **or**
  * symlink: `ln -s ~/.statesetd ~/.stateset` (pick one path and stay consistent).

* **Keyring backend**
  Use `--keyring-backend os` for persistence with your OS keystore. Alternatives:

  * `file` (plaintext on disk), `test` (ephemeral/in‑memory).

* **Denom & amounts**

  * Denom is `ustate` (micro‑units).
  * 1 **STATE** = **1,000,000 ustate**
  * Examples:

    * 10,000 **STATE** = `10000000000ustate`
    * 9,000 **STATE**  = `9000000000ustate`

* **Commission fields**
  If you include commission params in your `gentx`, typical values for testnets:

  * `--commission-rate "0.01"` (1%)
  * `--commission-max-rate "0.20"` (20%)
  * `--commission-max-change-rate "0.05"` (5% per day)

* **Build issues (Go/GOPATH)**
  Ensure:

  ```bash theme={null}
  go version            # >= 1.17
  echo $GOPATH          # set (e.g. $HOME/go)
  echo $PATH | grep go  # includes $GOPATH/bin and $GOROOT/bin
  ```

* **Sanity checks**

  ```bash theme={null}
  statesetd version
  statesetd validate-genesis --home ~/.stateset
  jq .chain_id ~/.stateset/config/genesis.json 2>/dev/null  # should show "stateset-1-testnet"
  ```

***

## Security Notes

* **Back up** your mnemonic offline. Anyone with it controls your validator funds.
* Never commit `~/.stateset*` contents to any repository.
* Double‑check addresses before submitting on‑chain transactions.

***

## What Happens After PR Merge?

* The Stateset team publishes the **final** testnet genesis (with accepted gentxs) and launch time.
* You’ll be instructed to download the final genesis and start your node/validator for network launch.

***
