Author

Topic: How to create your own altcoin (v0.20.1) (Read 636 times)

newbie
Activity: 2
Merit: 0
March 14, 2022, 02:34:45 AM
#6
i have followed your post to created new altcoin from bitcoin core.

one problem i have. when i send altcoin-cli getblocktemplate commend core Floating point exception and dumped.  


NODE1
2022-03-14T07:32:56Z addcon thread start
2022-03-14T07:32:56Z msghand thread start
2022-03-14T07:33:00Z Leaving InitialBlockDownload (latching to false)
2022-03-14T07:33:08Z ThreadRPCServer method=getblocktemplate
Floating point exception (core dumped)
btcnodeu@btcnode1:~/b18coin/core/src$


NODE2
2022-03-14T07:33:00Z opencon thread start
2022-03-14T07:33:00Z init message: Done loading
2022-03-14T07:33:00Z msghand thread start
2022-03-14T07:33:00Z Leaving InitialBlockDownload (latching to false)
2022-03-14T07:33:00Z New outbound peer connected: version: 70015, blocks=0, peer=0

NODE1
btcnodeu@btcnode1:~/b18coin/core/src$ ./b18coin-cli getblocktemplate
error: Could not connect to the server 127.0.0.1:9090 (error code 1 - "EOF reached")

Make sure the b18coind server is running and that you are connecting to the correct RPC port.
btcnodeu@btcnode1:~/b18coin/core/src$






newbie
Activity: 7
Merit: 4
December 12, 2021, 08:40:02 AM
#5
If you want to make an altcoin without writing any code Upneko could be useful to you (https://upneko.com)
You can choose a name, symbol, supply type/quantity, and additional features like minting/burning.

It uses Ethereum blockchain and there is a free tier on Mainnet, but if you want to try all features you can try it on test networks like Ropsten completely for free.
You just need a MetaMask wallet to interact with the application.

Full disclaimer: I'm the founder of Upneko
newbie
Activity: 8
Merit: 0
November 28, 2021, 05:19:23 PM
#4
Quote
I personally found difficulties on my way to achieve this.


 Cheesy Cheesy Cheesy

I feel your pain!!  Cry I been and still am in a heavy battle with making a altcoin for my self. I was able to make a working altcoin on a older version of Litecoin but now i want it update it to the latest Litecoin core. Pure hell! Over the past weeks i been able to compile almost every coin / cross compile almost every coin, been dealing with down and upgrading openssl , fixing openssl versions for MXE , fixing outdated qt.mk files  Cheesy Cheesy

Thnx to tut like this im getting closer and closer to being able to do most stuff my self. Thnx + bookmarked
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Bump.
member
Activity: 280
Merit: 71
January 13, 2021, 06:47:02 AM
#2
I have always wanted to create my own altcoin. I tried to do something with erc-20 but then I postponed. Now I see OP posted a guideline which is interesting for me. I will try to work on this hwn I have time. Thanks for the thread. Even the altcoin I will try to create will not be published by meö at least I will learn something Smiley
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
January 13, 2021, 06:31:45 AM
#1
Even if I am not in favor of the altcoins' philosophy and I put bitcoin above all, I believe that everyone has the right to create their own cryptocurrency since the code is open source. I personally found difficulties on my way to achieve this. I created tons of threads, but fortunately I made it.

Whoever wants to keep reading and hasn't tried to do this in the past, he'll need Windows 10 and patience. If he doesn't have these two, he can not make altcoin, at least in the way I will describe. The final result will run on windows only. Note that it isn't difficult to run it on linux, but there are just extra steps, which aren't considered needed for a beginner.

First we need to install an Ubuntu terminal to make our lives easier, so you will go to the windows store and download Ubuntu 18.04:


(Once you open it enter a username and a password)

Now I will follow the steps of build-windows.md from github to install some dependencies.

Copy each line below and run it in the terminal:
Code:
sudo apt update
sudo apt upgrade
sudo apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git

This may take some time. Then you will clone the source code of the bitcoin core from github. Right after the "bitcoin.git" is the name of the folder that will be created and the name of the cryptocurrency that we will create. In this guide I will use the classic example "altcoin". If you decide to use another name, be sure to change it in every other part of this tutorial.

Code:
git clone https://github.com/bitcoin/bitcoin.git altcoin

Once it's done, you'll need to find the bitcoin core files. They will probably be at:
Code:
C:\Users\\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\home\

In the "altcoin" folder the files will look like this:


At the moment we can build them, the problem is that we will make a copy of the bitcoin core that will follow the bitcoin blockchain, something we obviously don't want. We want our own blockchain. The first thing we need to cover is to replace where the word "bitcoin" is with "altcoin". (it is not necessary, but it won't confuse us)

Run these lines:
Code:
cd altcoin
find . -type f -print0 | xargs -0 sed -i 's/bitcoin/altcoin/g'
find . -type f -print0 | xargs -0 sed -i 's/Bitcoin/Altcoin/g'
find . -type f -print0 | xargs -0 sed -i 's/BTC/ATC/g'
find . -type f -print0 | xargs -0 sed -i 's/BITCOIN/ALTCOIN/g'
find . -type f -print0 | xargs -0 sed -i 's/BitCoin/AltCoin/g'
(It will take some time)

Now that we replaced everything with our cryptocurrency's title, we can't stop. We'll have to rename the files' titles too. Otherwise, it will try to find files that don't exist like "altcoind.cpp". In order to change all titles run these lines:
Code:
cd ..
find altcoin -type d -exec chmod 755 {} \;
cd altcoin
find -iname \*.* | rename -v "s/bitcoin/altcoin/g"


Changes in code

We need to differentiate our blockchain from bitcoin's. Let's start by changing the ports. Go to your files from windows explorer and click on the "src" folder.

In chainparamsbase.cpp change the nRPCPort to whatever you want. I suggest to just change the eight e.g.
Code:
if (chain == CBaseChainParams::MAIN) {
        return MakeUnique("", 2332, 2334);
    } else if (chain == CBaseChainParams::TESTNET) {
        return MakeUnique("testnet3", 12332, 12334);
    } else if (chain == CBaseChainParams::SIGNET) {
        return MakeUnique("signet", 32332, 32334);
    } else if (chain == CBaseChainParams::REGTEST) {
        return MakeUnique("regtest", 12443, 12445);
    }

Do the same for the nDefaultPort of chainparams.cpp:
Code:
nDefaultPort = 2333;

Now we will choose a different signature message in pchMessageStart of chainparams.cpp. This is a very important step, if it is not changed and you connect to a bitcoin node it will consider the bitcoin blockchain as the correct one. Do it like this:
Code:
pchMessageStart[0] = 0xf0;
pchMessageStart[1] = 0xb0;
pchMessageStart[2] = 0xb0;
pchMessageStart[3] = 0xd0;

Optional, but you can change the address prefix too. (1, 3, bc1)
Link of all prefixes: https://en.bitcoin.it/wiki/List_of_address_prefixes
In the base58Prefixes of chainparams.cpp I will show an example of the "X" prefix:
Code:
base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,75);

Also optional, you can change the block reward of your currency. In bitcoin it starts with BTC50 per block.
GetBlockSubsidy at validation.cpp:
Code:
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
    int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
    // Force block reward to zero when right shift is undefined.
    if (halvings >= 64)
        return 0;

    CAmount nSubsidy = 50 * COIN;
    // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
    nSubsidy >>= halvings;
    return nSubsidy;
}

I leave it at 50.

We have to set the difficulty equal with 1, since you will be the only miner at the beginning. At chainparams.cpp change nMinimumChainWork:

Code:
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000100010001");

In chainparams.cpp there are some lines that include IP addresses. They're written so you can automatically connect a node(s) once you open Bitcoin Core for the first time (without adding a node with the addnode "xxx.xxx.xx.xx" add ). So wherever you find a line that starts with vSeeds.emplace_back delete it. Also, lines that start with vFixedSeeds must be replaced with:
Code:
vFixedSeeds.clear();

There shouldn't be any vFixedSeeds that do something else.

In chainparams.cpp, we need to change checkpointData to:
Code:
checkpointData = {
            {
                { 0, uint256S("0x0")}
            }
        };

In this tutorial I will not explain how to make our own genesis block, because we want to achieve something simple. Anyone who takes it more seriously can search and learn how it is done. Thus, we need to change the value of nMaxTipAge in validation.cpp:

Multiply it with a big number like 10000.
Code:
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE * 10000;

In consensus/consensus.h we need to change COINBASE_MATURITY which means how "deep" a block must be for the miner to spend its reward. In bitcoin it is 100, that is, someone who will mine 1 block must wait 100 blocks to spend its coins. We can give it any value, I will put it equal with 3:

Code:
static const int COINBASE_MATURITY = 3;

Finally, we need to change these two lines of chainparams.cpp:
Code:
m_assumed_blockchain_size = 1;
m_assumed_chain_state_size = 1;
(They are related with the block height in order for nodes to share information)

Most notepads change permissions when we mess with LTS. That's why you must run the following lines:
Code:
cd src
sudo chmod 640 validation.cpp
sudo chmod 640 chainparams.cpp
sudo chmod 640 chainparamsbase.cpp
cd consensus
sudo chmod 640 consensus.h
cd ..
cd ..


Building.

Before we get started we need to install the mingw-w64 cross-compilation tool chain:
Code:
sudo apt install g++-mingw-w64-x86-64

When it is finished, we build with the following commands:
Code:
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g')
sudo bash -c "echo 0 > /proc/sys/fs/binfmt_misc/status"
cd depends
make HOST=x86_64-w64-mingw32
cd ..
./autogen.sh
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure --prefix=/
make
(It may take more than an hour)

The files to open the new Altcoin Core are in altcoin/src/qt:


You can start mining by clicking window -> console -> generatetoaddress 1 . On enter something like 1000000000, otherwise you'll most unlikely be able to mine a block. The bitcoin core images can be changed if we had replaced them at the beginning and then went to building.



That was it, now you have created your own coin, but more importantly, your own blockchain. It is worth mentioning that this is for educational purposes only. You obviously can't expect to be the new Satoshi Nakamoto, neither that your coins will have value.

And that's because: There is only one Bitcoin.
Jump to: