Advertisement
Guest User

QRL Migration Splitter Script

a guest
Dec 6th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     QRL Migration Splitter
  3.  
  4.     This tool helps you protecting your privacy by suggesting how to
  5.     migrate your ERC-20 QRL tokens into mainnet QRL before
  6.     the end of the migration process on 28 Feb 2019.
  7.    
  8.     The idea behind this script is to hide your total holdings by
  9.     splitting them in multiple addresses of your choice, each with
  10.     a randomized migration date and held amount.
  11.    
  12.     After the script has run, a text based table will be printed
  13.     on your console so that you can copy it and use it as a reminder.
  14.  
  15.     Instructions:  
  16.     1) Generate as many QRL addresses as you desire
  17.     you can either use the online wallet at https://wallet.theqrl.org
  18.     or the safer command line version https://github.com/theqrl/qrl)
  19.     2) Fill the Configuration Section below according to your addresses
  20.     and preferences
  21.     3) Run this script in a javascript console.
  22.     ( on chrome you can open it by left-clicking anywhere on any page,
  23.     then select 'inspect' --> 'console' tab,
  24.     paste this script in the console, press enter and you're done:
  25.     you should now see a table with dates, amounts and the corresponding
  26.     address to carry out the migration. )
  27.  
  28.     Cheers from /u/sire_giarasso
  29.     donations:
  30.     Q010600d4bb6f045df6a95f3ad32d802798b32be9d09366f1d85c9846021c707d08dda8f5a34185
  31. */
  32.  
  33. ///////////////////////////////////////////////////////////
  34. //
  35. // CONFIGURATION SECTION
  36. // -- edit the variables below according to your holdings.
  37. //
  38. ///////////////////////////////////////////////////////////
  39.  
  40. // Mandatory:
  41. total_quanta_to_distribute = 100.00000000 // The amount of QRL you own
  42. destination_addresses = [
  43.     'Q010600d4bb6f045df6a95f3ad32d802798b32be9d09366f1d85c9846021c707d08dda8f5a34185',
  44.     'Q0106000dc923eb43f1dce12c5cdeefd424cd9ba7dfe00534c6b613a60518efc5866029f266a10a',
  45.     'Q0106002f0c933e0f88805625a5548dae65d9011c80e8b624e881d4d5534513fd9f32a494d40e2f'
  46. ]
  47.  
  48. // Optional:
  49. minimum_balance_per_wallet = 1
  50. start_date = new Date('Dec 6 2018 14:44:29 GMT+0100')
  51. end_date = new Date('Jan 31 2019 18:00:00 GMT+0100') // Migration ends on 28 Feb 2019
  52.  
  53. ///////////////////////////////////////////////////////////
  54. //
  55. // CODE SECTION
  56. // -- no need to edit stuff from here onwards.
  57. //
  58. ///////////////////////////////////////////////////////////
  59.  
  60. period = (1000*60*60*24)
  61. periods = (end_date-start_date)/period
  62. shor_per_quanta = 10**9
  63. total_quanta_to_distribute *= shor_per_quanta
  64.  
  65. distribute = function (addresses, shor_amount, min) {
  66.     var qrl_addresses = {}
  67.     var reserved_amount = (min * addresses.length)
  68.     var available_amount = shor_amount - reserved_amount
  69.     if (reserved_amount >= available_amount) {
  70.         throw new Error('distribute(): Wrong amounts')
  71.     }
  72.     var distribution_table = {}
  73.  
  74.     addresses.forEach((a)=>{
  75.         distribution_table[a] = Math.random()
  76.     })
  77.  
  78.     total = 0
  79.     addresses.forEach((address)=> {
  80.         total += distribution_table[address]
  81.     })
  82.  
  83.     addresses.forEach((address)=> {
  84.         distribution_table[address] = distribution_table[address] / total
  85.     })
  86.  
  87.  
  88.     var remaining_amount = available_amount
  89.     for (var i = 0; i < addresses.length; i++) {
  90.         if (i < addresses.length - 1) {
  91.             distributed_amount = parseInt(available_amount * distribution_table[addresses[i]])
  92.             amount = min + distributed_amount
  93.             remaining_amount -= distributed_amount
  94.         } else {
  95.             amount = min + remaining_amount
  96.         }
  97.  
  98.         if (!qrl_addresses[addresses[i]]) {
  99.             qrl_addresses[addresses[i]] = 0
  100.         }
  101.  
  102.         qrl_addresses[addresses[i]] += amount / shor_per_quanta
  103.     }
  104.  
  105.     return qrl_addresses
  106. }
  107.  
  108. distribution = distribute(destination_addresses, total_quanta_to_distribute, minimum_balance_per_wallet * shor_per_quanta)
  109.  
  110. payments = []
  111. for (var i in distribution) {
  112.     date = new Date(start_date.getTime() + (period * Math.random() * periods) )
  113.     payments.push({ address: i, quantity: distribution[i], date: date })
  114. }
  115. payments = payments.sort( (a,b)=> a.date - b.date )
  116.  
  117. out=''
  118. payments.forEach(x=>{
  119.     out += `${x.date.toDateString()}\t\t${x.quantity}\t\t${x.address}\n`
  120. })
  121. console.log(out)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement