Smart contract Dapp system development (plan)

DAPP is called a distributed application, and DAPP is an application based on blockchain technology. DApp runs on P2P networks of different computers, not on one computer. DApps have existed since the beginning of P2P networks. It is actually a software program designed to run on the Internet in a way that is not controlled by any single entity. All data on decentralized applications is stored in a distributed ledger. It is impossible to crack a decentralized network.
To become a blockchain DApp, the following conditions must be met: the
application must be completely open source: it must run autonomously, and no entity controls most of its tokens. The application may adjust its protocol based on proposed improvements and market feedback, but its final changes must be based on user consensus.
Application data and operation records: must be encrypted and stored in public, decentralized blockchain nodes to avoid any central point of failure.
The application must use cryptocurrency (bitcoin or its system token) and provide certain token incentives to miners.
The application must generate tokens based on a standard encryption algorithm as a proof of value, and the node is contributing to the application (Bitcoin uses a proof-of-work algorithm).

  function registration(address userAddress, address referrerAddress) private {
    require(msg.value == 0.05 ether, "registration cost 0.05");
    require(!isUserExists(userAddress), "user exists");
    require(isUserExists(referrerAddress), "referrer not exists");
    
    uint32 size;
    assembly {
        size := extcodesize(userAddress)
    }
    require(size == 0, "cannot be a contract");
    
    User memory user = User({
        id: lastUserId,
        referrer: referrerAddress,
        partnersCount: 0
    });
    
    users[userAddress] = user;
    idToAddress[lastUserId] = userAddress;
    
    users[userAddress].referrer = referrerAddress;
    
    users[userAddress].activeX3Levels[1] = true; 
    users[userAddress].activeX6Levels[1] = true;
    
    
    userIds[lastUserId] = userAddress;
    lastUserId++;
    
    users[referrerAddress].partnersCount++;

    address freeX3Referrer = findFreeX3Referrer(userAddress, 1);
    users[userAddress].x3Matrix[1].currentReferrer = freeX3Referrer;
    updateX3Referrer(userAddress, freeX3Referrer, 1);

    updateX6Referrer(userAddress, findFreeX6Referrer(userAddress, 1), 1);
    
    emit Registration(userAddress, referrerAddress, users[userAddress].id, users[referrerAddress].id);
}

Guess you like

Origin blog.csdn.net/m0_51754086/article/details/109290032