# Second subnet creation and deployment

{% hint style="success" %}
For simplicity, the new subnet we are creating is run by the same validators as the first subnet. This is not mandatory.
{% endhint %}

### Step 1: Subnet creation

In the same way as we created our first subnet, connect to the `bitcoin-ipc-local` container running:

```bash
docker exec -it bitcoin-ipc bash
```

Then run:

```bash
# from inside the container
/usr/local/bin/bootstrap_subnet_b_from_container.sh
```

### Step 2: Validator deployment

{% hint style="warning" %}
Make sure you use the Subnet ID of the subnet we just created and not the one from the previous pages.
{% endhint %}

Run:

```bash
# from inside the container
/usr/local/bin/spin_up_subnet_b_from_container.sh $SUBNET_ID
```

where `SUBNET_ID` indicates the subnet for which you deploy validators (the script of the previous step outputs it).

Similar to the script we used for subnet A, it does the following:

1. It starts twelve Docker containers (three for each validator: `fendermint-X-subnet-b`, `cometbft-X-subnet-b` , and `ethapi-X-subnet-b`) on your host.
2. It starts a Relayer for each validator, with log files stored in  `/root/logs/` in the container. See [optional-helper-scripts](https://bitcoin-scaling-labs-docs.gitbook.io/ipc-btc-scaling-docs/user-guide-for-using-subnets/optional-helper-scripts "mention") for more information on the log files.

***

## Alternative: Install on the host machine

If in page [installation](https://bitcoin-scaling-labs-docs.gitbook.io/ipc-btc-scaling-docs/user-guide-for-using-subnets/installation "mention") you chose the alternative deployment — hence `bitcoin-core` , the monitors and providers, and `ipc-cli` are running on your host machine — then you **must** also use this alternative approach here to create a second subnet and deploy the validators.

Even if you used the default Docker-based deployment, you still have the option to use this alternative approach here. In that case, you need to run all following commands from inside the `bitcoin-ipc` container — the `ipc` and `bitcoin-ipc` repos can be found in the `/root/workspace` directory.

### Step 1: Create a child subnet

Exactly the same as in [subnet-creation](https://bitcoin-scaling-labs-docs.gitbook.io/ipc-btc-scaling-docs/user-guide-for-using-subnets/subnet-creation "mention"):

```bash
ipc-cli --config-path ~/.ipc/validator1/config.toml subnet create \
	--parent /b4 --min-validators 4 --bottomup-check-period 120 \
	btc --min-validator-stake 100000000 --min-cross-msg-fee 10 \
	--validator-whitelist $WHITELIST
```

Make sure you write down the subnet id or export it to a env variable `$SUBNET_ID`.

### Step 2: Update the config.toml files

We now need to add the new subnet configuration to **all** of the following configuration files:

* `~/.ipc/validator1/config.toml`
* `~/.ipc/validator2/config.toml`
* `~/.ipc/validator3/config.toml`
* `~/.ipc/validator4/config.toml`&#x20;
* `~/.ipc/validator5/config.toml`&#x20;
* `~/.ipc/user1/config.toml`&#x20;
* `~/.ipc/user2/config.toml`&#x20;
* `~/.ipc/config.toml`&#x20;

**Notice that this time we are changing the entry for Subnet B.** The config files already contain the corresponding entry, you only have to replace `/b4/t410ftkmrmongfxyrefwgpyz524taorvrijfwfzrfwgy` with the new subnet id.

```toml
# Subnet B
[[subnets]]
id = "/b4/t410ftkmrmongfxyrefwgpyz524taorvrijfwfzrfwgy"

[subnets.config]
network_type = "fevm"
provider_http = "http://localhost:9545/"
gateway_addr = "0x77aa40b105843728088c0132e43fc44348881da8"
registry_addr = "0x74539671a1d2f1c8f200826baba665179f53a1b7"
```

### Step 3: Join the subnet

Exactly the same as in [subnet-creation](https://bitcoin-scaling-labs-docs.gitbook.io/ipc-btc-scaling-docs/user-guide-for-using-subnets/subnet-creation "mention"):

{% code overflow="wrap" %}

```sh
ipc-cli --config-path ~/.ipc/validator1/config.toml subnet join --from $IPC_ADDRESS_OF_VALIDATOR_1 --subnet $SUBNET_ID btc --collateral=200000000 --ip 66.222.44.55:8080 --backup-address "$(bitcoin-cli --rpcwallet=validator1 getnewaddress)"

ipc-cli --config-path ~/.ipc/validator2/config.toml subnet join --from $IPC_ADDRESS_OF_VALIDATOR_2 --subnet $SUBNET_ID btc --collateral=110000000 --ip 66.222.44.55:8081 --backup-address "$(bitcoin-cli --rpcwallet=validator2 getnewaddress)"

ipc-cli --config-path ~/.ipc/validator3/config.toml subnet join --from $IPC_ADDRESS_OF_VALIDATOR_3 --subnet $SUBNET_ID btc --collateral=150000000 --ip 66.222.44.55:8082 --backup-address "$(bitcoin-cli --rpcwallet=validator3 getnewaddress)"

ipc-cli --config-path ~/.ipc/validator4/config.toml subnet join --from $IPC_ADDRESS_OF_VALIDATOR_4 --subnet $SUBNET_ID btc --collateral=180000000 --ip 66.222.44.55:8083 --backup-address "$(bitcoin-cli --rpcwallet=validator4 getnewaddress)"
```

{% endcode %}

### Step 4: Fund the validators

Exactly the same as in [subnet-creation](https://bitcoin-scaling-labs-docs.gitbook.io/ipc-btc-scaling-docs/user-guide-for-using-subnets/subnet-creation "mention"):

{% code overflow="wrap" %}

```sh
ipc-cli --config-path ~/.ipc/validator1/config.toml cross-msg fund --subnet=$SUBNET_ID btc --to $IPC_ADDRESS_OF_VALIDATOR_1 210000000

ipc-cli --config-path ~/.ipc/validator2/config.toml cross-msg fund --subnet=$SUBNET_ID btc --to $IPC_ADDRESS_OF_VALIDATOR_2 220000000

ipc-cli --config-path ~/.ipc/validator3/config.toml cross-msg fund --subnet=$SUBNET_ID btc --to $IPC_ADDRESS_OF_VALIDATOR_3 230000000

ipc-cli --config-path ~/.ipc/validator4/config.toml cross-msg fund --subnet=$SUBNET_ID btc --to $IPC_ADDRESS_OF_VALIDATOR_4 240000000
```

{% endcode %}

### Step 5: Deploy the validators

Similar to  [deploy-the-validators](https://bitcoin-scaling-labs-docs.gitbook.io/ipc-btc-scaling-docs/user-guide-for-using-subnets/deploy-the-validators "mention"), we recommend that you use the helper script to deploy the validator containers for the second subnet. This is because all the ports change, and this can be tricky to do manually.

```bash
./scripts/spin_up_subnet_b.sh $SUBNET_ID
```

### Step 6: Check the status of the subnet

Exactly the same as in [deploy-the-validators](https://bitcoin-scaling-labs-docs.gitbook.io/ipc-btc-scaling-docs/user-guide-for-using-subnets/deploy-the-validators "mention"):

Run the *block\_checker* helper script:

```bash
./scripts/l2_block_checker.sh $SUBNET_ID
```

Run the *balancer* helper script:

```bash
./scripts/balancer.sh $SUBNET_ID
```
