danicoin/README.md

226 lines
7.8 KiB
Markdown
Raw Normal View History

2015-02-17 15:13:48 +00:00
This is the reference code for [CryptoNote](https://cryptonote.org) cryptocurrency protocol.
* Launch your own CryptoNote currency: [CryptoNote Starter](https://cryptonotestarter.org/)
* CryptoNote reference implementation: [CryptoNoteCoin](https://cryptonote-coin.org)
* Discussion board and support: [CryptoNote Forum](https://forum.cryptonote.org)
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
## CryptoNote forking how-to
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
### Preparation
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
1. Create an account on [GitHub.com](github.com)
2. Fork [CryptoNote repository](https://github.com/cryptonotefoundation/cryptonote)
3. Buy one or two Ubuntu-based dedicated servers (at least 2Gb of RAM) for seed nodes.
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
### First step. Give a name to your coin
**Good name must be unique.*** Check uniqueness with [google](http://google.com) and [Map of Coins](mapofcoins.com) or any other similar service.
2014-06-24 19:35:25 +00:00
Name must be specified twice:
2015-02-17 15:13:48 +00:00
**1. in file src/cryptonote_config.h** - CRYPTONOTE_NAME macro
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
Example:
```
2014-06-24 19:35:25 +00:00
#define CRYPTONOTE_NAME "furiouscoin"
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**2. in CMakeList.txt file** - set_property(TARGET daemon PROPERTY OUTPUT_NAME "YOURCOINNAMEd")
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
Example:
```
2014-06-24 19:35:25 +00:00
set_property(TARGET daemon PROPERTY OUTPUT_NAME "furiouscoind")
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**Note:** You should also change a repository name.
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
### Second step. Emission logic
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**1. Total money supply** (src/cryptonote_config.h)
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
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)).
2014-06-24 19:35:25 +00:00
Example:
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
#define MONEY_SUPPLY ((uint64_t)(-1))
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**2. Emission curve** (src/cryptonote_config.h)
2014-06-24 19:35:25 +00:00
Be default CryptoNote provides emission formula with slight decrease of block reward with each block. This is different from Bitcoin where block reward halves every 4 years.
EMISSION_SPEED_FACTOR macro defines emission curve slope. This parameter is required to calulate block reward.
Example:
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
#define EMISSION_SPEED_FACTOR (18)
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**3. Difficulty target** (src/cryptonote_config.h)
2014-06-24 19:35:25 +00:00
Difficulty target is an ideal time period between blocks. In case an average time between blocks becomes less than difficulty target, the difficulty increases. Difficulty target is measured in seconds.
Difficulty target directly influences several aspects of coin's behavior:
- transaction confirmation speed: the longer the time between the blocks is, the slower transaction confirmation is
- emission speed: the longer the time between the blocks is the slower the emission process is
- orphan rate: chains with very fast blocks have greater orphan rate
For most coins difficulty target is 60 or 120 seconds.
Example:
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
#define DIFFICULTY_TARGET 120
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**4. Block reward formula**
2014-06-24 19:35:25 +00:00
In case you are not satisfied with CryptoNote default implementation of block reward logic you can also change it. The implementation is in src/cryptonote_core/cryptonote_basic_impl.cpp:
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward)
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
This function has two parts:
2015-02-17 15:13:48 +00:00
- basic block reward calculation: `uint64_t base_reward = (MONEY_SUPPLY - already_generated_coins) >> EMISSION_SPEED_FACTOR;`
- big block penalty calculation: this is the way CryptoNote protects the block chain from transaction flooding attacks and preserves opportunities for organic network growth at the same time.
2014-06-24 19:35:25 +00:00
Only the first part of this function is directly related to the emission logic. You can change it the way you want. See MonetaVerde and DuckNote as the examples where this function is modified.
2015-02-17 15:13:48 +00:00
### Third step. Networking
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**1. Default ports for P2P and RPC networking** (src/cryptonote_config.h)
2014-06-24 19:35:25 +00:00
P2P port is used by daemons to talk to each other through P2P protocol.
RPC port is used by wallet and other programs to talk to daemon.
It's better to choose ports that aren't used by other software or coins. See known TCP ports lists:
2015-02-17 15:13:48 +00:00
* http://www.speedguide.net/ports.php
* http://www.networksorcery.com/enp/protocol/ip/ports00000.htm
* http://keir.net/portlist.html
2014-06-24 19:35:25 +00:00
Example:
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
#define P2P_DEFAULT_PORT 17236
#define RPC_DEFAULT_PORT 18236
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**2. Network identifier** (src/p2p/p2p_networks.h)
2014-06-24 19:35:25 +00:00
This identifier is used in network packages in order not to mix two different cryptocoin networks. Change all the bytes to random values for your network:
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
const static boost::uuids::uuid CRYPTONOTE_NETWORK = { { 0xA1 ,0x1A, 0xA1, 0x1A , 0xA1, 0x0A , 0xA1, 0x0A, 0xA0, 0x1A, 0xA0, 0x1A, 0xA0, 0x1A, 0xA1, 0x1A} };
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**3. Seed nodes** (src/p2p/net_node.inl)
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
Add ip addresses of your seed nodes to the beginning of `node_server<t_payload_net_handler>::init(const boost::program_options::variables_map& vm)` function.
2014-06-24 19:35:25 +00:00
Example:
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
ADD_HARDCODED_SEED_NODE("111.11.11.11:17236");
ADD_HARDCODED_SEED_NODE("222.22.22.22:17236");
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
### Fourth step. Transaction fee and related parameters
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**1. Default transaction fee** (src/cryptonote_config.h)
2014-06-24 19:35:25 +00:00
Zero default fee can lead to transaction flooding. Transactions cheaper than the default transaction fee wouldn't be accepted by daemons. 100000 value for DEFAULT_FEE is usually enough.
Example:
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
#define DEFAULT_FEE 100000
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**2. Penalty free block size** (src/cryptonote_config.h)
2014-06-24 19:35:25 +00:00
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:
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE 20000
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
### Fifth step. Genesis block
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**1. Build the binaries with blank genesis tx hex** (src/cryptonote_config.h)
2014-06-24 19:35:25 +00:00
2014-07-18 12:35:40 +00:00
You should leave #define GENESIS_COINBASE_TX_HEX blank and compile the binaries without it.
2014-06-24 19:35:25 +00:00
2014-07-18 12:35:40 +00:00
Example:
2015-02-17 15:13:48 +00:00
```
2014-07-18 12:35:40 +00:00
#define GENESIS_COINBASE_TX_HEX ""
2015-02-17 15:13:48 +00:00
```
2014-07-18 12:35:40 +00:00
2015-02-17 15:13:48 +00:00
**2. Start the daemon to print out the genesis block**
2014-06-24 19:35:25 +00:00
2014-07-18 12:35:40 +00:00
Run your daemon with --print-genesis-tx argument. It will print out the genesis block coinbase transaction hash.
Example:
2015-02-17 15:13:48 +00:00
```
2014-07-18 12:35:40 +00:00
cryptonotecoind --print-genesis-tx
2015-02-17 15:13:48 +00:00
```
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**3. Copy the printed transaction hash** (src/cryptonote_config.h)
2014-07-18 12:35:40 +00:00
Copy the tx hash that has been printed by the daemon to GENESIS_COINBASE_TX_HEX in /src/cryptonote_config.h
Example:
2015-02-17 15:13:48 +00:00
```
2014-07-18 12:35:40 +00:00
#define GENESIS_COINBASE_TX_HEX "013c01ff0001ffff...785a33d9ebdba68b0"
2015-02-17 15:13:48 +00:00
```
2014-07-18 12:35:40 +00:00
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
**4. Recompile the binaries**
2014-06-24 19:35:25 +00:00
2014-07-18 12:35:40 +00:00
Recompile everything again. Your coin code is ready now. Make an announcement for the potential users and enjoy!
2014-06-24 19:35:25 +00:00
2015-02-17 15:13:48 +00:00
## Building CryptoNote
### On *nix
2014-03-03 22:07:58 +00:00
2015-02-17 15:13:48 +00:00
Dependencies: GCC 4.7.3 or later, CMake 2.8.6 or later, and Boost 1.53 or later (except 1.54, more details here: http://goo.gl/RrCFmA).
2014-03-03 22:07:58 +00:00
You may download them from:
2015-02-17 15:13:48 +00:00
* http://gcc.gnu.org/
* http://www.cmake.org/
* http://www.boost.org/
*
2014-03-03 22:07:58 +00:00
Alternatively, it may be possible to install them using a package manager.
To build, change to a directory where this file is located, and run `make'. The resulting executables can be found in build/release/src.
2015-02-17 15:13:48 +00:00
**Advanced options:**
* Parallel build: run `make -j<number of threads>` instead of `make`.
* Debug build: run `make build-debug`.
* Test suite: run `make test-release` to run tests in addition to building. Running `make test-debug` will do the same to the debug version.
* Building with Clang: it may be possible to use Clang instead of GCC, but this may not work everywhere. To build, run `export CC=clang CXX=clang++` before running `make`.
2014-03-03 22:07:58 +00:00
2015-02-17 15:13:48 +00:00
### On Windows
2014-03-03 22:07:58 +00:00
Dependencies: MSVC 2012 or later, CMake 2.8.6 or later, and Boost 1.53 or later. You may download them from:
2015-02-17 15:13:48 +00:00
* http://www.microsoft.com/
* http://www.cmake.org/
* http://www.boost.org/
2014-03-03 22:07:58 +00:00
2014-07-18 12:35:40 +00:00
To build, change to a directory where this file is located, and run theas commands:
2015-02-17 15:13:48 +00:00
```
2014-03-03 22:07:58 +00:00
mkdir build
cd build
cmake -G "Visual Studio 11 Win64" ..
2015-02-17 15:13:48 +00:00
```
2014-03-03 22:07:58 +00:00
And then do Build.
2014-04-29 16:26:45 +00:00
Good luck!