Create Own Altcoin With CryptoNote - aanwhs/aanwhs.github.io GitHub Wiki
Starting a coin
Preparation
Create an account on github.com
Buy one or two Ubuntu-based dedicated servers (at least 2Gb of RAM) for seed nodes.
Name Your Coin
Good name must be unique. Check uniqueness with Google and Map of Coins.
Name must be specified twice:
— in file src/CryptoNoteConfig.h — CRYPTONOTE_NAME constant
Example:
const char CRYPTONOTE_NAME[] = "bitrupiah";
— in src/CMakeList.txt file — set_property(TARGET daemon PROPERTY OUTPUT_NAME "YOURCOINNAMEd")
Example:
set_property(TARGET daemon PROPERTY OUTPUT_NAME "bitrupiahd")
Note: You should also change the repository name.
Emission Logic
Total Money Supply — src/CryptoNoteConfig.h
Total amount of coins to be emitted. Most of CryptoNote-based coins use (uint64_t)(-1) (equals to 18446744073709551616).
You can define number explicitly (for example UINT64_C(858986905600000000)).
Example:
const uint64_t MONEY_SUPPLY = (uint64_t)(-1);
Emission Curve — src/CryptoNoteConfig.h
By default CryptoNote provides emission formula with a slight decrease of block reward each block. This is different from
Bitcoin where block reward halves every 4 years.
EMISSION_SPEED_FACTOR constant defines emission curve slope. This parameter is required to calulate block reward.
Example:
const unsigned EMISSION_SPEED_FACTOR = 18;
Difficulty Target — src/CryptoNoteConfig.h
Difficulty target is an ideal time period between blocks. In case an average time between blocks becomes less than difficulty target, difficulty increases. Difficulty target is measured in seconds.
Difficulty target directly influences several aspects of coin's behavior:
— transaction confirmation speed: the longer time between the blocks is, the slower transaction confirmation is
— emission speed: the longer the time between blocks is the slower the emission is
— orphan rate: chains with very fast blocks have greater orphan rate
For most coins difficulty target is 60 or 120 seconds.
Example:
const uint64_t DIFFICULTY_TARGET = 120;
Block Reward Formula
In case you are not satisfied with CryptoNote default implementation of block reward logic you can also change it. The implementation is in src/CryptoNoteCore/Currency.cpp:
bool Currency::getBlockReward(size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee, uint64_t& reward, int64_t& emissionChange) const
This function has two parts:
—basic block reward calculation
uint64_t baseReward = (m_moneySupply - alreadyGeneratedCoins) >> m_emissionSpeedFactor;
—big block penalty calculation
This is the way CryptoNote protects chain from transaction flooding attacks and preserves opportunities for organic network growth at the same time.
Only the first part of this function is directly related to emission logic. You can change it the way you want. See MonetaVerde and DarkNote as the examples where this function is modified.
Emission Calculator
You may play around with DIFFICULTY_TARGET and EMISSION_SPEED_FACTOR parameters and check how your coin's emission will look like compared to Bitcoin. The graph below projects emission percentage for the first 30 years.
Networking
Default Ports For P2P And RPC Networking — src/CryptoNoteConfig.h
P2P port is used by daemons to communicate with each other through P2P protocol.
RPC port is used by wallet and other software to communicate with the daemon.
It's better to choose ports that aren't used by some other software. See known TCP ports lists:
— http://www.speedguide.net/ports.php
— http://www.networksorcery.com/enp/protocol/ip/ports00000.htm
— http://keir.net/portlist.html
Example:
const int P2P_DEFAULT_PORT = 2033;
const int RPC_DEFAULT_PORT = 2032;
Network Identifier — src/P2p/P2pNetworks.h
This identifier is used for network packages in order not to mix two different cryptocoin networks. Change all bytes to random values for your network:
const static boost::uuids::uuid CRYPTONOTE_NETWORK = { { 0xA1, 0x1A, 0xA1, 0x1A, 0xA1, 0x0A, 0xA1, 0x0A, 0xA0, 0x1A, 0xA0, 0x1A, 0xA0, 0x1A, 0xA1, 0x1A } };
Seed Nodes — src/CryptoNoteConfig.h
Add IP addresses of your seed nodes.
Example:
const std::initializer_list<const char*> SEED_NODES = {
"203.20.33.033:2033",
"203.20.32.032:2033",
Transaction Fee And Related Parameters
Minimum Transaction Fee — src/CryptoNoteConfig.h
Zero minimum fee can lead to transaction flooding. Transactions cheaper than the minimum transaction fee wouldn't be accepted by daemons. 100000 value for MINIMUM_FEE is usually enough.
Example:
const uint64_t MINIMUM_FEE = 100000;
Penalty Free Block Size — src/CryptoNoteConfig.h
CryptoNote protects chain from tx flooding by reducing block reward for blocks larger than the median block size. However, this rule applies for blocks larger than CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE bytes.
Example:
const size_t CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE = 20000;
Address Prefix
You may choose a letter (in some cases several letters) all the coin's public addresses will start with. It is defined by CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX constant. Since the rules for address prefixes are nontrivial you may use the prefix generator tool below.
Example:
const uint64_t CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 0xd1; // addresses start with "b"
Genesis Block
Build The Binaries With A Blank Genesis tx hex — src/CryptoNoteConfig.h
You should leave const char GENESIS_COINBASE_TX_HEX[] blank and compile the binaries without it.
Example:
const char GENESIS_COINBASE_TX_HEX[] = "";
Start The Daemon To Print Out The Genesis Block
Run your daemon with --print-genesis-tx argument. It will print out the genesis block coinbase transaction hash.
Example:
furiouscoind --print-genesis-tx
Insert The Printed Transaction Hash — src/CryptoNoteConfig.h
Copy the tx hash that has been printed out by the deamon to GENESIS_COINBASE_TX_HEX in src/CryptoNoteConfig.h
Example:
const char GENESIS_COINBASE_TX_HEX[] = "013c01ff0001ffff...785a33d9ebdba68b0";
Recompile the binaries
Recompile everything again. Your coin code is ready now. Make an announcement on CryptoNote Forum and enjoy!
Submit Your Coin For The Review
In order to be officially announced as a CryptoNote currency you should submit your coin for the review.
Creating A GUI Wallet
Preparation
This instruction will help you create an Open-Source GUI wallet for your coin. Please note that the wallet won’t compile if you don’t have a separate repository for your coin.
Create a repository for your coin on https://github.com/
Detailed instruction on how to do this can be found here: https://cryptonotestarter.org/inner.html
Clone Wallet Sources
Self-explanatory step. Simply copy-paste this command to the console to clone the sources.
Example:
git clone https://github.com/aanwhs/cryptonotewallet.git
Modify cmake File
Put the name of your coin into CryptoNoteWallet.cmake file.
Example:
set(CN_PROJECT_NAME "bitrupiah")
set(CN_CURRENCY_DISPLAY_NAME "Bitrupiah")
set(CN_CURRENCY_TICKER "BRP")
Set Symbolic Link
Set symbolic link to coin sources at the same level as src.
Example:
ln -s ../cryptonote cryptonote
Alternative way is to create git submodule.
Example:
git submodule add https://github.com/aanwhs/cryptonote.git
Replace URL with git remote repository of your coin.
Build
Example
mkdir build && cd build && cmake .. && make
And finally build a wallet for you coin.
Knowledge Base
Binaries overview
Every CryptoNote coin interacts with the network through 2 binaries.
1. Daemon
Default name is “cryptonotecoind”. Daemon is responsible for any communication with the network:
Mining
Interaction with the blockchain, e.g. blocks relaying, getting info about the block, etc.
Peer list look up
Connections look up
Transaction pool information and relaying
2. Wallet
Default name is “simplewallet”. It carries out basic wallet's functions:
Wallet creation Financial operations, e.g. sending, receiving, checking for incoming transfers, etc.
Simplewallet also allows user to start/stop mining without a need to specify the wallet in the daemon.
In CryptoNote only the simplewallet knows about user's private keys and funds. The daemon is used solely for the purpose of network communication. Simplewallet and daemon binaries work through JSON RPC. You may run the binaries from the separate machines, but for the security purposes you should make sure that daemon won't be accesible from anywhere but the simplewallet's ip address.
Source: https://cryptonotestarter.org