Bitcoin Forum
July 04, 2024, 06:41:41 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1]
  Print  
Author Topic: need help !!  (Read 262 times)
Dark.coder (OP)
Newbie
*
Offline Offline

Activity: 18
Merit: 0


View Profile
September 27, 2017, 10:18:16 AM
 #1

Iam cloning a coin (basic script)  so i can explore crypto programming need a little help.

I want to code 100000coin
premine 10000 coin and then 100 coins per block. how to do this

{
    int64 nSubsidy = 100 * COIN;

    if(nHeight == 1) 
     {
         nSubsidy = 10000 * COIN;
     }




is this correct Huh?
paraboul
Newbie
*
Offline Offline

Activity: 29
Merit: 0


View Profile WWW
September 27, 2017, 11:15:46 AM
Last edit: September 27, 2017, 11:29:25 AM by paraboul
 #2

I guess you're refering to GetBlockSubsidy() function.

nSubsidy is the number of coin "mined".
nHeight is the block number.

Here you're just telling the function to reward "10000" coins for the first block (provided that you're returning this value).

Given what you asked, a more comprehensible way to achieve the same result would be :

Code:
   nSubsidy = (nHeight == 1) ? 
                      10000 * COIN :
                      100 * COIN;

Also, not sure, but the first block is probably 0 (nHeight)
Dark.coder (OP)
Newbie
*
Offline Offline

Activity: 18
Merit: 0


View Profile
September 27, 2017, 11:27:55 AM
 #3

I guess you're refering to GetBlockSubsidy() function.

nSubsidy is the number of coin "mined".
nHeight is the block number.

Here you're just telling the function to reward "10000" coins for the first block (provided that you're returning this value).

Given what you asked, a more comprehensible way to achieve the same result would be :

Code:
   nSubsidy = (nHeight == 1) ? 
                      10000 * COIN :
                      100 * COIN;

Also, not sure, but the first block is probably 0 (nHeight)

i want 10000coins  in the first block and he rest blocks should have 100 coins each  considering the simple liteocin source i guess mine is right but still need some expert advice
paraboul
Newbie
*
Offline Offline

Activity: 29
Merit: 0


View Profile WWW
September 27, 2017, 11:29:14 AM
 #4

I guess you're refering to GetBlockSubsidy() function.

nSubsidy is the number of coin "mined".
nHeight is the block number.

Here you're just telling the function to reward "10000" coins for the first block (provided that you're returning this value).

Given what you asked, a more comprehensible way to achieve the same result would be :

Code:
   nSubsidy = (nHeight == 1) ? 
                      10000 * COIN :
                      100 * COIN;

Also, not sure, but the first block is probably 0 (nHeight)

i want 10000coins  in the first block and he rest blocks should have 100 coins each  considering the simple liteocin source i guess mine is right but still need some expert advice


Since you only want 100000 coins total, you need to stop rewarding coin after 1000 blocks minus the first premined. So 900 blocks. (900*100 + 10000 = 100000).

Just add at the beginning :

Code:
if (nHeight > 900) return 0;

Not sure what your problem is? This is very simple
Dark.coder (OP)
Newbie
*
Offline Offline

Activity: 18
Merit: 0


View Profile
September 27, 2017, 11:51:32 AM
 #5

I guess you're refering to GetBlockSubsidy() function.

nSubsidy is the number of coin "mined".
nHeight is the block number.

Here you're just telling the function to reward "10000" coins for the first block (provided that you're returning this value).

Given what you asked, a more comprehensible way to achieve the same result would be :

Code:
   nSubsidy = (nHeight == 1) ? 
                      10000 * COIN :
                      100 * COIN;

Also, not sure, but the first block is probably 0 (nHeight)

i want 10000coins  in the first block and he rest blocks should have 100 coins each  considering the simple liteocin source i guess mine is right but still need some expert advice


Since you only want 100000 coins total, you need to stop rewarding coin after 1000 blocks minus the first premined. So 900 blocks. (900*100 + 10000 = 100000).

Just add at the beginning :

Code:
if (nHeight > 900) return 0;

Not sure what your problem is? This is very simple
Just pmed you
patrik1012
Member
**
Offline Offline

Activity: 69
Merit: 10

Blockchain the future of democratic payment!


View Profile
September 27, 2017, 01:57:20 PM
 #6

if (nHeight > 900) return 0;

This should work? Did it work?

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!