0

Airdrop スマートコントラクトを作成しようとしていますが、「このコントラクトは抽象的である可能性があります。抽象的な親のメソッドを完全に実装していないか、継承されたコントラクトのコンストラクターを正しく呼び出していません。」展開時のメッセージ.....ただし、コンパイルは正常に機能します。以下のコードを確認してください

pragma solidity ^0.4.18;

contract ERC20 {
    function transfer(address _to, uint256 _value)public returns(bool);
    function balanceOf(address tokenOwner)public view returns(uint balance);
    function transferFrom(address from, address to, uint256 tokens)public returns(bool success);
}

contract SimpleAirdrop is IERC20 {

        IERC20 public token;
        uint256 public _decimals = 18;
        uint256 public _amount = 1*10**6*10**_decimals;
        
        function SimpleAirdrop(address _tokenAddr) public {
            token = IERC20(_tokenAddr);
        }
        
        function setAirdrop(uint256 amount, uint256 decimals) public {
            _decimals = decimals;
            _amount = amount*10**_decimals;
        }
        
        function getAirdrop(address reff) public returns (bool success) {
            require (token.balanceOf(msg.sender) == 0);
            //token.transfer(msg.sender, 1000000000000000000000);
            //token.transfer(reff , 200000000000000000000);
            token.transfer(msg.sender, _amount);
            token.transfer(reff , _amount);
            return true;
        }
} 
4

2 に答える 2

0

以下のコードで誤解がないか確認してください コンパイルに問題はありません , パラメータを使用してデプロイされ、テストネットで成功しました startAirdrop関数を呼び出すときに問題が発生します...ガスに問題があります

ご承知おき下さい

pragma solidity ^0.4.18;


contract ERC20 {
    function transfer(address _to, uint256 _value)public returns(bool);
    function balanceOf(address tokenOwner)public view returns(uint balance);
    function transferFrom(address from, address to, uint256 tokens)public returns(bool success);
}


contract SimpleAirdrop {

        ERC20 public token;
        uint256 public _decimals = 9;
        uint256 public _amount = 1*10**6*10**_decimals;
        uint256 public _cap = _amount *10**6;
        address public tokenOwner = 0x0;
        uint256 public _totalClaimed = 0; 
        uint256 public _reffPercent = 10; 
        
        
        function SimpleAirdrop(address _tokenAddr ,address _tokenOwner ) public {
            token = ERC20(_tokenAddr);
            tokenOwner = _tokenOwner;
            
            
        }
        
        function setAirdrop(uint256 amount, uint256 cap, uint256 decimals ,uint256 reffPercent) public returns (bool success){
            require (msg.sender == tokenOwner);
            _decimals = decimals;
            _amount = amount*10**_decimals;
            _cap = cap*10**_decimals;
            _reffPercent = reffPercent;
            return true;
            
        }
        
        
        function sendAirdropToken() public returns (bool success){
            require (msg.sender == tokenOwner);
            token.transferFrom(msg.sender,address(this),_cap);
            return true;
        }
        
        function returnAirdropToOwner() public returns (bool success){
            require (msg.sender == tokenOwner);
            token.transferFrom(address(this), msg.sender, address(this).balance);
            return true;
            
        }
        
        function getAirdrop(address reff) public returns (bool success){
            if(msg.sender != reff && token.balanceOf(reff) != 0 && reff != 0x0000000000000000000000000000000000000000 && _cap >= _amount){
                token.transfer(reff , _amount*(_reffPercent/100));
                _cap = _cap - (_amount*(_reffPercent/100));
                
             }
            if(msg.sender != reff && token.balanceOf(reff) != 0 && token.balanceOf(msg.sender) == 0 && reff != 0x0000000000000000000000000000000000000000 && _cap >= _amount)
            {   token.transfer(msg.sender, _amount);
                _cap = _cap - _amount;
                _totalClaimed ++;
            }
            return true;
            
        }
        
        
    

    
}
于 2021-06-17T01:05:15.060 に答える