<commit_before>---
title: Building A New Sidechain with Elements
edit: https://github.com/ElementsProject/elementsproject.github.io/blob/master/source/sidechains/creating-your-own.md
source: https://github.com/ElementsProject/elementsproject.github.io/edit/master/source/sidechains/creating-your-own.md
---
This is a basic step-by-step guide to building your own sidechain and setting up
a federated pegging mechanism.  This configuration works to run a sidechain with
a 1-of-1 functionary/blocksigner. (Not tested on multiple nodes with more than 1
signer).

There are several other ways of deriving consensus on a sidechain.  See [the Deterministic Peg Element](/elements/deterministic-peg.html) for more details.

#### Elements
Please look over [the Elements
Git Repository](https://github.com/ElementsProject/elements), if you haven't already.
Also read [Alpha
README](https://github.com/ElementsProject/elements/blob/alpha/alpha-README.md)
for building dependencies and to follow along. The instructions for building the
dependencies are pretty cut and clear, however, the building of a new fedpeg
isn't as detailed. Keep the Elements Project's Alpha-README open in a separate
tab for reference.

#### Prerequisites
1. *Linux.* Building with Windows is possible - publish a guide if you know how as there isn't one publicly available! :)
2. *All dependencies for Elements Alpha.*  See [Build Notes](https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md)

#### Build
Try to follow this order to avoid unneccessary recompilations. This is an extension of the instructions to "Run a fedpeg operator" in the Element's alpha README.

Edit your `.bashrc`. We'll come back to this file later:
```shell
RPC_USER=your_username_here
RPC_PASSWORD=<PASSWORD>
export RPC_USER
export RPC_PASS
```

Build bitcoin (mainchain):
```shell
git clone https://github.com/ElementsProject/elements
cd elements
git checkout mainchain
./autogen.sh && ./configure && make
mv src/bitcoin{d,-cli,-tx} ../
```

Run testnet. If you get an error asking to rebuild the blockchain, replace `-txindex` with `-reindex`. If you have to rebuild it, continue these instructions while it syncs:
```shell
./bitcoind -rpcuser=$RPC_USER -rpcpassword=$RPC_PASS -testnet -txindex -daemon
```

Checkout `alpha`. Before making any changes of your own,`fetch/merge` a [patch](https://github.com/TomMcCabe/elements/tree/patch) for a few code changes that will consolidate our settings in `sidechain-manipulation.py` and `constants.py` ([PR #86 of Elements Repo](https://github.com/ElementsProject/elements/pull/86)):
```shell
git checkout alpha<commit_msg>Remove instructions relating to a now-merged patch.<commit_after>---
title: Building A New Sidechain with Elements
edit: https://github.com/ElementsProject/elementsproject.github.io/blob/master/source/sidechains/creating-your-own.md
source: https://github.com/ElementsProject/elementsproject.github.io/edit/master/source/sidechains/creating-your-own.md
---
This is a basic step-by-step guide to building your own sidechain and setting up
a federated pegging mechanism.  This configuration works to run a sidechain with
a 1-of-1 functionary/blocksigner. (Not tested on multiple nodes with more than 1
signer).

There are several other ways of deriving consensus on a sidechain.  See [the Deterministic Peg Element](/elements/deterministic-peg.html) for more details.

#### Elements
Please look over [the Elements
Git Repository](https://github.com/ElementsProject/elements), if you haven't already.
Also read [Alpha
README](https://github.com/ElementsProject/elements/blob/alpha/alpha-README.md)
for building dependencies and to follow along. The instructions for building the
dependencies are pretty cut and clear, however, the building of a new fedpeg
isn't as detailed. Keep the Elements Project's Alpha-README open in a separate
tab for reference.

#### Prerequisites
1. *Linux.* Building with Windows is possible - publish a guide if you know how as there isn't one publicly available! :)
2. *All dependencies for Elements Alpha.*  See [Build Notes](https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md)

#### Build
Try to follow this order to avoid unneccessary recompilations. This is an extension of the instructions to "Run a fedpeg operator" in the Element's alpha README.

Edit your `.bashrc`. We'll come back to this file later:
```shell
RPC_USER=your_username_here
RPC_PASSWORD=<PASSWORD>
export RPC_USER
export RPC_PASS
```

Build bitcoin (mainchain):
```shell
git clone https://github.com/ElementsProject/elements
cd elements
git checkout mainchain
./autogen.sh && ./configure && make
mv src/bitcoin{d,-cli,-tx} ../
```

Run testnet. If you get an error asking to rebuild the blockchain, replace `-txindex` with `-reindex`. If you have to rebuild it, continue these instructions while it syncs:
```shell
./bitcoind -rpcuser=$RPC_USER -rpcpassword=$RPC_PASS -testnet -txindex -daemon
```

Checkout the `alpha` branch.
```shell
git checkout alpha
{'fraction_non_alphanumeric': 0.10034047666733427, 'fraction_numerical': 0.0028039254956939716, 'mean_word_length': 4.854630715123095, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1674073', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1383, 'n_words': 551}