This tutorial will walk you through how to convert FCT to PEG on OSX and Linux. Experienced Windows users will be able to retrofit it for their needs, but Windows is not directly supported.
Disclaimer: I suggest you run through this process with a small amount of FCT to make sure everything is working before breaking out the big guns. This process is done at your own risk. Be cautious.
I offer here a brief overview so that you can better understand the process as we go through it in detail below.
There are 4 components working together to form PegNet. Factomd is the Factom blockchain daemon and is analogous to Geth or Bitcoin Core. The PegNet miner is used to burn FCT to pFCT. Pegnetd is used to handle the PegNet smart contract (i.e. tracking transactions and conversions). Finally, walletd is needed to store and handle your keys.
The aim of this guide is to get each of these components working together. We will use a remote factomd instance hosted by OpenNode so that you do not need to sync your own factomd instance. If you want to sync factomd yourself, you can.
1. Download the required binaries
Four binaries are required to perform the conversion from FCT to PEG. Note that Mac binaries are marked as Darwin.
Burns FCT to pFCT. Download here
Tracks PegNet and handle pAsset conversions/transactions. Download here
The Sha256 of the OSX zip is
2. Rename the binaries
Rename each binary to pegnet and pegnetd respectively. The other binaries, factom-cli and factom-walletd, should already be named correctly. If not, rename those too.
3. Place binaries in your PATH
/usr/local/bin is in your $PATH:
If you do not see it anywhere in the output string, head over to Google to discover how to create it or use another directory that is listed in that output. Again, Google will help you with which.
OSX and Linux GUI users can simply drag and drop the above binaries into
/usr/local/bin. CLI users can use the following command, modified for each of the binaries (hint: might need sudo):
mv [binary] /usr/local/bin/[binary]
4. Grant execute permissions
Pegnet and pegnetd need execute permissions (hint: might need sudo):
chmod +x /usr/local/bin/pegnet
chmod +x /usr/local/bin/pegnetd
Check that each binary is installed correctly:
pegnetd help pegnet help factom-cli help factom-walletd
If any of the above commands fail, something went wrong. Go back and check everything was done correctly.
The final command would have opened walletd. You can close it again for now.
5. Create pegnetd config file
.pegnetd directory in your $HOME folder. CLI users can use:
Next, copy the contents of this default config file into
server = "http://localhost:8088/v2" to be
server = https://api.factomd.net/v2
6. Bootstrap pegnetd
It would take a while to sync pegnetd from OpenNode, so let's bootstrap it.
First, download mainnet.tar.gz (Sha256:
Next, place it in
Finally, unzip it. You should now have the databse in
7. Start pegnetd
Next, you need to start pegnetd to let it build the bytemap table. This should take 10 to 20 minutes and is complete when Pass 4 reaches 100%. It will also need to sync the remaining blocks since I last updated the above DB bootstrap. That could take a few minutes to a few hours, depending on when I last updated it.
8. Create PegNet config file
Copy the contents of this default config file into
FactomdLocation="localhost:8088" to be
9. Create a factomd config file
Yes, another config file!
Place the following config into
[Walletd] FactomdLocation = "https://api.factomd.net"
10. Start walletd
Now open a terminal window (if you do not have one already) and start walletd.
Advanced users can create an encrypted wallet. However, the rest of this guide assumes the wallet is unencrypted as it adds another layer of complexity. CLI reference commands can be found here.
factom-walletd -encrypted -passphrase="[ENTER A PASSPHRASE]"
11. Create new FCT and EC addresses or import address into walletd
We're making progress now. Just hang in there.
Next we need to get your FCT and EC into walletd. If you don't have any EC yet, don't worry. We will create some later.
Make sure walletd is still running and open a new terminal. You can either import existing Factom addresses or create new addresses that you will then fund.
a. Create new addresses
factom-cli newfctaddress factom-cli newecaddress
Copy down the public addresses.
b. Import existing addresses
The imported address should be a private address that starts with
factom-cli importaddress FS... factom-cli importaddress EC...
12. Export your private keys
Export your private keys and keep them somewhere safe and secure.
13. Use your FCT to create some EC
This will burn a small amount of FCT. You won't need much.
factom-cli buyec [publicFctAddress] [publicEcAddress] [ecAmount]
For example, to create 100 EC, issue the following command with your own public addresses:
factom-cli buyec FA... EC... 100
14. Convert FCT to pFCT
We're finally ready to make a transaction from FCT to pFCT! Phew!
Make sure walletd is running, then open a new terminal and input:
pegnet burn [address] [amount]
Where address is the FCT address in walletd and amount is the number of FCT you wish to burn. Remember that a small amount of FCT will have been burnt to create the EC in step 13. If you need to know how much FCT you have before running the above command, use:
factom-cli balance [fctAddress]
15. Convert pFCT to PEG.
Okay, final step, I promise!
First, eyeball the pegnetd process we started in step 6 to ensure that it has finished syncing. This could take several hours.
Next, you need to make sure the conversion from FCT to pFCT has completed. You can check it with:
pegnetd balance pFCT [fctAddress]
Once you see your pFCT balance there, you are ready to rock. Issue the conversion from pFCT to PEG like so:
pegnetd newcvt [ecAddress] [fctAddress] [srcAsset] [amount] [destAsset]
A little explainer on the above:
- ecAddress is the EC address that you credited with EC in step 11.
- fctAddress is the FCT address you are using - no mystery here!
- srcAsset is the source asset (i.e. the asset you are converting from). In this intance, that is pFCT.
- amount is the total amount of srcAsset that you are converting.
- destAsset is the asset you are converting to. In this case, it is PEG.
So, an example command would be:
pegnetd newcvt EC... FA... pFCT 100 PEG
The conversion will be done in 2 blocks. You can check your PEG balance with:
pegnetd balance PEG [fctAddress]