Create wallets and config files
Two options -- automated and manual -- to create all required configuration.
Option A: Using the quickstart script
We provide a script that automates the setup for wallets and configuration files for five validators and two users.
Before running it:
Make sure you have followed all previous setup steps.
Make sure that
~/.ipcdoes not exist. The script will not override it.
From within the bitcoin-ipc repo run:
./target/release/quickstartIf you changed the "rpcuser" and/or "rpcpassword" fields in Bitcoin Regtest, then you need to update these values in the following files:
~/.ipc/validator1/.env~/.ipc/validator2/.env~/.ipc/validator3/.env~/.ipc/validator4/.env~/.ipc/validator5/.env~/.ipc/user1/.env~/.ipc/user2/.env
The script prints the the IPC address (aka ETH address) and the X-Only public key of each validator and user, as well as a whitelist consisting of the first four validators (to be used when creating a subnet).
In the following demo we will use the IPC address to identify users and validators in the L2 subnet, and the X-Only public key to identify validators on the bitcoin chain.
For ease of use, you can extract the IPC address and the whitelist into env variables:
The ~/.ipc directory should have the following structure:

~/.ipc directory after the quickstart script Option B: Manual setup
The script performs the following steps, which you can also do manually.
Step 1: Set up Bitcoin wallets for validators and clients
Throughout the demo we will use six validators (four in the initial subnet and two to demonstrate the dynamic participation) and two clients. In this step we create the necessary bitcoin wallets for them.
In order for each validator to stake, they need to have a bitcoin wallet with enough funds in it. We'll create and fund a bitcoin wallet for each validator.
All wallets should have at least 100 BTC.
After restarting
If in the future you restart bitcoind, you only have to load each wallet:
Step 2: Create IPC wallets for each validator
Now each validator has personal funds on Bitcoin. We will set up an IPC wallet for each validator and each user, that is, eight IPC wallets. This wallet will be used to interact with the child subnet and, for validators, to sign multisig transactions.
The btc wallet type is similar to the pre-existing evm wallet type, except with a technical difference (the y coordinate of the underlying secp256k1 key has even parity), which allows the validator to use the same key to sign multisig transactions on bitcoin.
The wallet for the users can also be of wallet-type evm . For simplicity we make it btc so it is easier to list all balances with one command.
List and record the newly created wallets addresses and corresponding x-only public keys:
Pick four validators that you want to use in the initial subnet and
Write down their IPC addresses, or set the env variables
${IPC_ADDRESS_OF_VALIDATOR_1}, ...,${IPC_ADDRESS_OF_VALIDATOR_4}. The IPC address is printed asAddress:by ipc-cli and starts with0x.Construct and write down the
validator-whitelist(to be used in the next step) as a comma-separated list using the the x-only public keys of these four validators return by ipc-cli (printed asXonlyPubKey:). This should look like the following. Observe that there are no empty spaces between the keys.
Let's export the secret keys of all validators:
Implementation detail: The secret keys we export here will be used in two places:
By the Fendermint docker image of each validator
By the bitcoin provider of each validator, in order to sign bitcoin transactions
Step 3: Create .env file for each validator and user
The .env file of each validator is used by the bitcoin monitor and bitcoin provider.
Create .env for validators
Navigate to bitcoin-ipc directory and run the following commands:
In each .env file modify the values
RPC_USERandRPC_PASS: Update them if you changed the default values in the bitcoin.conf file (in Bitcoin Regtest)WALLET_NAME: Use the bitcoin wallet names created on the previous step ("validator1", ... "validator5")DATABASE_URL: You can use<HOME_DIR>/.ipc/validator1/regtest_db, ... ,<HOME_DIR>/.ipc/validator5/regtest_dbPROVIDER_PORT: Use ports 3030, 3031, 3032, 3033, 3034, respectively.PROVIDER_AUTH_TOKEN: You can usevalidator1_auth_token, ... ,validator5_auth_tokenVALIDATOR_SK_PATH: Use<HOME_DIR>/.ipc/validator1/validator.sk, ...,<HOME_DIR>/.ipc/validator5/validator.skreplace
<HOME_DIR>with your absolute home directory path.
Let's see the ~/.ipc/validator1/.env file as an example:
Create .env for users
Let's do the same for the users.
Edit the two new .env files as follows:
RPC_USERandRPC_PASS: Update them if you changed the default values in the bitcoin.conf file (in Bitcoin Regtest)WALLET_NAME: Useuser1anduser2, respectively.DATABASE_URL: You can use<HOME_DIR>/.ipc/user1/regtest_dband<HOME_DIR>/.ipc/user2/regtest_db, respectivelyPROVIDER_PORT: Use 3040, 3041, respectivelyPROVIDER_AUTH_TOKEN: You can useuser1_auth_tokenanduser2_auth_token, respectivelyVALIDATOR_SK_PATH: It is irrelevant, it is only used by validatorsreplace
<HOME_DIR>with your absolute home directory path.
Let's see the ~/.ipc/validator1/.env file as an example:
Step 5: Initialise the config file for each validator and user
The config.toml of each validator file is used by Fendermint and by ipc-cli.
Navigate to the ipc repo and run the following.
For each validator's and user's config file, modify:
provider_httpto match the port you set inPROVIDER_PORTin the .env file of the validator, that is, using ports 3030, 3031, 3032, 3033, 3034 for the validators and 3040, 3041 for the user.auth_tokento match thePARENT_AUTH_TOKENyou've set in the .env file of the validator, that is usevalidator1_auth_token, ... ,validator5_auth_tokenfor validators anduser1_auth_token, ... ,user2_auth_tokenfor users.
Let's see ~/.ipc/validator1/config.toml for example. It should look similar to the following.
/b4 is the identifier for the Bitcoin regtest network.
Last updated