Guest User

Untitled

a guest
Oct 22nd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. pragma solidity ^0.4.15;
  2.  
  3. contract Node {
  4. Pyramid public pyramid;
  5. uint public amount;
  6. address public owner;
  7. address public parent;
  8.  
  9. function Node(Pyramid _pyramid, address _parent) {
  10. pyramid = _pyramid;
  11. owner = msg.sender;
  12. parent = _parent;
  13. accrue(1);
  14. }
  15.  
  16. function accrue(uint8 i) {
  17. if (i <= 5) {
  18. owner.transfer(pyramid.at(i));
  19. if (address(0) != parent) {
  20. Node(parent).accrue(i + 1);
  21. }
  22. }
  23. }
  24. }
  25.  
  26. contract Pyramid {
  27. uint[6] public levels;
  28.  
  29. function Pyramid(uint[6] marketing) {
  30. levels = marketing;
  31. }
  32.  
  33. function at(uint i) external returns(uint) {
  34. return levels[i];
  35. }
  36.  
  37. function enter(address parent) external payable returns (Node) {
  38. uint diff = msg.value - levels[0];
  39. require(diff >= 0);
  40. if (diff > 0) {
  41. msg.sender.transfer(diff);
  42. }
  43. return new Node(this, parent);
  44. }
  45. }
Add Comment
Please, Sign In to add comment