• 空投合约代码实现


    contract ReceviedContract {

    address public owner;
    

    //收款合约
    constructor(address XX) public payable {
    owner = XX;
    }
    function () payable public {
    owner.transfer(msg.value);
    }
    address public owner;
    uint public amount;

    modifier onlyOwner {
        require(msg.sender == owner);
        //为什么
        _;
    }
    
    constructor() public {
        owner = msg.sender;
    }
    

    address add=0xb09ffe8cc514a9ccdbb990f17df4722151505a82;
    function () public payable {
    amount += msg.value;
    }

    function transferOwnership(address newOwner) onlyOwner public {
        if (newOwner != address(0)) {
            owner = newOwner;
        }
    }
      //提现函数
    function withdraw() onlyOwner public {
        msg.sender.transfer(amount);
        amount = 0;
    }
    
    //获取发送者地址 计算总额 空投0/a
    //web3 remix
    var aa=new Web3(contract(0x04e226d8f2e0021820cb830277dcdd7b685481a2));
    //js 遍历   mysql/浏览器/map记录
    
    
    
    //        //转0.1ETH 送3万,
    //        //转0.5ETH 送17万,
    //        //转1ETH 送35万
    //        //其它数额按1:30万送出
    
    
    
    
    //    function support(address contract_address,address _to,address _from,uint256 _value) public payable{
    

    // //检查总量大于400000
    // require(balanceOf[manager] >=40000000);
    // // require(msg.value == 0 );
    // //转0.1ETH 送3万,
    // //转0.5ETH 送17万,
    // //转1ETH 送35万
    // //其它数额按1:30万送出
    // if(_value0){
    //
    // }
    // if(_value == 0.11000000000000000000) {
    // transfer(msg.sender,_value
    30000);
    // //保存 发送的地址的钱
    //
    // }
    // else if (_value == 0.51000000000000000000) {
    // transfer(msg.sender,_value
    170000);
    // }else if(_value
    11000000000000000000){
    // transfer(msg.sender,_value
    350000);
    // }else{
    // //给他的账户增加 增加一笔数量是300000乘以发送的值
    // transfer(msg.sender,_value*300000/1000000000000000000);
    // }
    // }

    }

    edu合约
    pragma solidity ^0.4.18;

    interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; }

    //和官方的给的有些类似
    contract Token {
    //总供应量
    /// total amount of tokens
    uint256 public totalSupply;
    //获取余额的账户
    /// @param _owner The address from which the balance will be retrieved
    /// @return The balance
    function balanceOf(address _owner) constant public returns (uint256 balance);

    //发送者的地址和接收者的地址 返回使得否成功
    /// @notice send `_value` token to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transfer(address _to, uint256 _value) public returns (bool success);
    
    /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
    /// @param _from The address of the sender
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    //转账 没有做任何检查
    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
    
    /// @notice `msg.sender` approves `_spender` to spend `_value` tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _value The amount of tokens to be approved for transfer
    /// @return Whether the approval was successful or not
    function approve(address _spender, uint256 _value) public returns (bool success);
    
    /// @param _owner The address of the account owning tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens allowed to spent
    function allowance(address _owner, address _spender) constant public returns (uint256 remaining);
    
    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);
    

    }

    /*
    You should inherit from StandardToken or, for a token like you would want to
    deploy in something like Mist, see HumanStandardToken.sol.
    (This implements ONLY the standard functions and NOTHING else.
    If you deploy this, you won't have anything useful.)

    Implements ERC 20 Token standard: https://github.com/ethereum/EIPs/issues/20
    .*/
    //官方给的token接口 放在各种钱包
    contract StandardToken is Token {
    //官方给的转账合同
    function transfer(address _to, uint256 _value) public returns (bool success) {
    // Prevent transfer to 0x0 address.
    require(_to != 0x0);
    // Check if the sender has enough
    require(balances[msg.sender] >= _value);
    // Check for overflows
    require(balances[_to] + _value > balances[_to]);

        uint previousBalances = balances[msg.sender] + balances[_to];
        balances[msg.sender] -= _value;
        balances[_to] += _value;
        Transfer(msg.sender, _to, _value);
        // Asserts are used to use static analysis to find bugs in your code. They should never fail
        assert(balances[msg.sender] + balances[_to] == previousBalances);
    
        return true;
    }
    
    //向这个账户转账
    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        //和上面一模一样
        /// same as above
        require(_to != 0x0);
        require(balances[_from] >= _value);
        require(balances[_to] + _value > balances[_to]);
    
        uint previousBalances = balances[_from] + balances[_to];
        balances[_from] -= _value;
        balances[_to] += _value;
        allowed[_from][msg.sender] -= _value;
        Transfer(_from, _to, _value);
        assert(balances[_from] + balances[_to] == previousBalances);
    
        return true;
    }
    

    //主人账户的余额
    function balanceOf(address _owner) constant public returns (uint256 balance) {
    return balances[_owner];
    }
    //批转转账
    function approve(address _spender, uint256 _value) public returns (bool success) {
    allowed[msg.sender][_spender] = _value;
    Approval(msg.sender, _spender, _value);
    return true;
    }

    //主人账户 用钱人的账户
    function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
        return allowed[_owner][_spender];
    }
    
    mapping (address => uint256) balances;
    ///地址的token余额
    /// balance amount of tokens for address
    mapping (address => mapping (address => uint256)) allowed;
    

    }

    contract EduCoin is StandardToken {

    //如果ether被发送到这个账户
    function () payable public {
        //if ether is sent to this address, send it back.
        //throw;
        require(false);
    }
    
    string public constant name = "EduCoinToken";
    string public constant symbol = "EDU";
    uint256 private constant _INITIAL_SUPPLY = 15*10**27;
    uint8 public decimals = 18;
    uint256 public totalSupply;
    //版本号
    //string public version = 'H0.1';
    
    function EduCoin(
    ) public {
        ///初始化
        // init
        balances[msg.sender] = _INITIAL_SUPPLY;
        totalSupply = _INITIAL_SUPPLY;
    
    }
    
    //批准和调用接受合约
    /* Approves and then calls the receiving contract */
    //道理 发代币
    function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
        tokenRecipient spender = tokenRecipient(_spender);
        if (approve(_spender, _value)) {
            spender.receiveApproval(msg.sender, _value, this, _extraData);
            return true;
        }
    }
  • 相关阅读:
    ORA-39126 KUPW$WORKER.PUT_DDLS [TABLE_STATISTICS]中Worker发生意外致命错误
    C# 9 新特性 —— 增强的 foreach
    在 xunit 测试项目中使用依赖注入
    gitee.com 码农中添加私有仓库并通过ssh链接
    强化学习 —— reinforce算法中更新一次策略网络时episodes个数的设置对算法性能的影响 —— reinforce算法中迭代训练一次神经网络时batch_size大小的不同设置对算法性能的影响
    如何在 Ubuntu18.04 server 服务器版本的操作系统下 配置IP
    东北某海滨城市的某高校的某分校区的校园网登录程序,(python3, 模拟浏览器的登入方式)
    强化学习中经典算法 —— reinforce算法 —— (进一步理解, 理论推导出的计算模型和实际应用中的计算模型的区别)
    【转载】 Linux 设置CPU Performance模式
    深度学习中使用TensorFlow或Pytorch框架时到底是应该使用CPU还是GPU来进行运算???
  • 原文地址:https://www.cnblogs.com/xiaocongcong888/p/9498238.html
Copyright © 2020-2023  润新知