Guest User

Untitled

a guest
Aug 7th, 2015
4,129
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. These are the first ever verifiable pyramid schemes with provably known rules! Each level has one more member than the previous one. Once a level fills up, each member in the preceding two layers gets half of their investment back. The remaining funds are distributed between all members in all of the preceding layers so that the members in the upper layers get a slightly larger amount. Anyone can verify that the code provided below is identical to the one in the Ethereum blockchain, by compiling it (with optimizations enabled), for example at
  2. https://chriseth.github.io/browser-solidity/
  3. and comparing the data with the output of:
  4. eth.getCode("0x109c4f2ccc82c4d77bde15f306707320294aea3f")
  5. This is the 1 ether scheme, the 0.1 and 10 schemes can be verified in the same way (by adding or removing zeros in the code provided below)
  6.  
  7. USAGE:
  8. In a geth console, type one of the three following commands (either the 1 ether, 10 ether, or 0.1 ether pyramid):
  9.  
  10. eth.sendTransaction({from:eth.accounts[0], to:"0x109c4f2ccc82c4d77bde15f306707320294aea3f", value: 100000000000000000000})
  11. eth.sendTransaction({from:eth.accounts[0], to:"0xa327075af2a223a1c83a36ada1126afe7430f955", value: 1000000000000000000000})
  12. eth.sendTransaction({from:eth.accounts[0], to:"0xbaa54d6e90c3f4d7ebec11bd180134c7ed8ebb52", value: 10000000000000000000})
  13.  
  14. That's it! Make sure the amounts are precisely as written. Simply wait for other people to do the same, and watch your investment grow. You might need to increase the default gas amount.
  15.  
  16. In order to see the current number of investors, type the following commands in the geth console:
  17.  
  18. var myschemeContract = web3.eth.contract([{"constant":true,"inputs":[],"name":"getNumInvestors","outputs":[{"name":"a","type":"uint256"}],"type":"function"},{"inputs":[],"type":"constructor"}]);
  19.  
  20. var c = myschemeContract.at("0x109c4f2ccc82c4d77bde15f306707320294aea3f")
  21.  
  22. c.getNumInvestors()
  23.  
  24.  
  25. SOLIDITY CODE:
  26.  
  27.  
  28. contract MyScheme {
  29.  
  30. uint treeBalance;
  31. uint numInvestorsMinusOne;
  32. uint treeDepth;
  33. address[] myTree;
  34.  
  35. function MyScheme() {
  36. treeBalance = 0;
  37. myTree.length = 6;
  38. myTree[0] = msg.sender;
  39. numInvestorsMinusOne = 0;
  40. }
  41.  
  42. function getNumInvestors() constant returns (uint a){
  43. a = numInvestorsMinusOne+1;
  44. }
  45.  
  46. function() {
  47. uint amount = msg.value;
  48. if (amount>=1000000000000000000){
  49. numInvestorsMinusOne+=1;
  50. myTree[numInvestorsMinusOne]=msg.sender;
  51. amount-=1000000000000000000;
  52. treeBalance+=1000000000000000000;
  53. if (numInvestorsMinusOne<=2){
  54. myTree[0].send(treeBalance);
  55. treeBalance=0;
  56. treeDepth=1;
  57. }
  58. else if (numInvestorsMinusOne+1==myTree.length){
  59. for(uint i=myTree.length-3*(treeDepth+1);i<myTree.length-treeDepth-2;i++){
  60. myTree[i].send(500000000000000000);
  61. treeBalance-=500000000000000000;
  62. }
  63. uint eachLevelGets = treeBalance/(treeDepth+1)-1;
  64. uint numInLevel = 1;
  65. for(i=0;i<myTree.length-treeDepth-2;i++){
  66. myTree[i].send(eachLevelGets/numInLevel-1);
  67. treeBalance -= eachLevelGets/numInLevel-1;
  68. if (numInLevel*(numInLevel+1)/2 -1== i){
  69. numInLevel+=1;
  70. }
  71. }
  72. myTree.length+=treeDepth+3;
  73. treeDepth+=1;
  74. }
  75. }
  76. treeBalance+=amount;
  77. }
  78. }
RAW Paste Data