Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.15;
- contract Node {
- Pyramid public pyramid;
- uint public amount;
- address public owner;
- address public parent;
- function Node(Pyramid _pyramid, address _parent) {
- pyramid = _pyramid;
- owner = msg.sender;
- parent = _parent;
- accrue(1);
- }
- function accrue(uint8 i) {
- if (i <= 5) {
- owner.transfer(pyramid.at(i));
- if (address(0) != parent) {
- Node(parent).accrue(i + 1);
- }
- }
- }
- }
- contract Pyramid {
- uint[6] public levels;
- function Pyramid(uint[6] marketing) {
- levels = marketing;
- }
- function at(uint i) external returns(uint) {
- return levels[i];
- }
- function enter(address parent) external payable returns (Node) {
- uint diff = msg.value - levels[0];
- require(diff >= 0);
- if (diff > 0) {
- msg.sender.transfer(diff);
- }
- return new Node(this, parent);
- }
- }
Add Comment
Please, Sign In to add comment