How to create your own HTML Blockchain based

in blockchain •  7 years ago  (edited)

The aim of this post is to explain how to create your own blockchain based in HTML

Fork the html github project at HTML

Modifies Readme according to your coin

Change all files in the repo according to your coin:
example:

Replace

htmlcoin --> yourcoinname

HTMLCOIN --> Yourcoinname

HTM--> YOURCOINNAME

In src/qt/guiutil.cpp

replace uri.replace(0, 11, "htmlcoin:"); // HTMLCOIN: change string length to 11 to correctly parse htmlcoin://

for uri.replace(0, 12, "yourcoinname:"); // YOURCOINNAME: change string length to 12 to correctly parse yourcoinname://

Now we have to change all configurations and create the genesis block

Create genesis block

In our new coin, we have to create a new genesis block to start the chain, this is done changing the chainparams.cpp

First, we have to change with the current timestamp, go to Timestamp

`genesis = CreateGenesisBlock(mytimestamp, 23815, 0x1f00ffff, 1, 1 * COIN);``

example:

genesis = CreateGenesisBlock(1521515740, 23815, 0x1f00ffff, 1, 1 * COIN);

This timestamp to a recent news, as example

const char* pszTimestamp = "NYT 3/28/2018 States Take On Trump Over a Census Change Seen as Political";

Finally

startNewChain = true;

comment these with \\ like

//assert(consensus.hashGenesisBlock == uint256S("0x0000bf23c6424c270a24a17a3db723361c349e0f966d7b55a6bca4bfb2d951b0")); //assert(genesis.hashMerkleRoot == uint256S("0xb07b60977e6f1ebfc23c074fb319c654e38dba5d7db16902863a4a98dd981f68"));

run the first time with ./yourcoind,

then stop, go to .yourcoindiretory
gedit debug.log
use the genesis hash, merkle root and nounce logs from debug.log

now use the genesis hash, merkleroot and nnounce value founded and put in

assert(consensus.hashGenesisBlock == uint256S("0xyourgenesishash")
assert(consensus.hashMerkleRoot == uint256S("0xyourmerkleroot")

`genesis = CreateGenesisBlock(mytimestamp, yournounce, 0x1f00ffff, 1, 1 * COIN);``

change

// The best chain should have at least this much work. consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000010000"); //

this value has to be updated later when chain is working

Now you have a blockchain running

Modify

`chainTxData = ChainTxData{
// Data as of block 00000000000000000166d612d5595e2b1cd88d71d695fc580af64d8da8658c23 (height 446482).
0, // * UNIX timestamp of last known number of transactions
0, // * total number of transactions between genesis and that timestamp
// (the tx=... number in the SetBestChain debug.log lines)
0 // * estimated number of transactions per second after that timestamp
};``

because we not have blocks yet

put
checkpointData = (CCheckpointData) { boost::assign::map_list_of ( 0, uint256S("0xyourgenesishash")) };

example
checkpointData = (CCheckpointData) { boost::assign::map_list_of ( 0, uint256S("0x0000875a5fd721640c8cdb7769a74099c1fa943e62777abf3a79a2ea21bb819f")) };

with only the genesis block hash

Change random all the characters
``
pchMessageStart[0] = 0x1f;
pchMessageStart[1] = 0x2e;
pchMessageStart[2] = 0x3d;
pchMessageStart[3] = 0x4c;

`
Change

nDefaultPort = 4888;

to a port not used by a chain, for example

nDefaultPort = 4900;

delete or change with your seeds

vSeeds.push_back(CDNSSeedData("htmlcoin.com", "seed1.htmlcoin.com", false)); vSeeds.push_back(CDNSSeedData("htmlcoin.com", "seed2.htmlcoin.com", false)); vSeeds.push_back(CDNSSeedData("htmlcoin.com", "seed3.htmlcoin.com", false)); vSeeds.push_back(CDNSSeedData("htmlcoin.com", "seed4.htmlcoin.com", false));

for example

vSeeds.push_back(CDNSSeedData("yourcoin.com", "seed1.yourcoin.com", false)); vSeeds.push_back(CDNSSeedData("yourcoin.com", "seed2.yourcoin.com", false)); vSeeds.push_back(CDNSSeedData("yourcoin.com", "seed3.yourcoin.com", false)); vSeeds.push_back(CDNSSeedData("yourcoin.com", "seed4.yourcoin.com", false));

Change now

startNewChain = false;

Now in chainparamsbase.cpp

Change

CBaseMainParams() { nRPCPort = 4889; }

to, for example

CBaseMainParams()
{
nRPCPort = 4901;
}

Testing MAIN Chain

Now you can run your with ./yourcoind or ./yourcoin-qt. We need a minimum of two machines to test the chain.

Setup two machines with the changed repo and create an yourcoin.conf and put it in .yourcoin diretory

VPS1

rpcuser=test rpcpassword=test rpcallowip=127.0.0.1 daemon=1 server=1 listen=1 port=4900 rpcport=4901 connect= vps 2 ip machine

VPS2

rpcuser=test rpcpassword=test rpcallowip=127.0.0.1 daemon=1 server=1 listen=1 port=4900 rpcport=4901 connect= vps 1 ip machine

type in one machine

``./yourcoin-cli generate 1 99999`

to start mining

in the other machine type

./yourcoin-cli getinfo

if it appears with blocs=1, your chain is working and syncing

If you find this tutorial useful support me, my html address:

HpzdD5S8RgeBT1DhBBSPXcLXCoRmky2jWt

TODO

Change testNet

Premine

Revert coingather code

References

Bitcoin tutorial

Create your ethereum blockchain

What is premine

Genesis Creator

Genesis Creator 2

Tutorials About how to create Altcoins

Which is checkpoint

Why change nMinimumChainWork

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!