Skip to content

Code Draft 1 Compilation Results

Andreas E edited this page Jan 27, 2020 · 9 revisions

Build Results

I am trying to compile the code in draft 1 and am listing errors and potential fixes here.

Line 40:

receive() external payable
{
    emit PaymentReceived(msg.sender, msg.value);
}

Error: 40:12: ParserError: Expected identifier but got '(' receive() external payable

Line 47 & 64:

requires (_balance > 21000 gwei, "Not enough funds.");

Error: 47:36: ParserError: Expected ',' but got identifier requires (_balance > 21000 gwei, "Not enough funds.");

Potential fixes:

_require_ (_balance > 21000 _wei_, "Not enough funds.");

40:12: ParserError: Expected identifier but got '(' receive() external payable

Line 58:

fallback () external payable { }

Error: 58:14: ParserError: Expected identifier but got '(' fallback () external payable { }

Line 66:

payable(owner).transfer(_balance);

Error: 66:9: ParserError: Expected primary expression. payable(owner).transfer(_balance);

Line 66:

function addDelegate(address _newDelegate) public onlyDelegates
{
    delegates[_newDelegate] = true;
    emit DelegationChanged(msg.sender, _newDelegate, "added as new delegate.");
}

Error: 73:5: ParserError: Expected pragma, import directive or contract/interface/library definition. function addDelegate(address _newDelegate) public onlyDelegates

Line 66:

    function delDelegate(address _removeDelegate) public onlyDelegates
    {
        // TO-DO: add additional safe-guard here not to delete the last remaining delegate!
        // Within this code, delegates[] is a hash table, which does not allow counting its members.
        // We'll have to think about different options. Otherwise we may lose access to the main functionality.
        // For now: The owner of the contract is always the first delegate, and we'll ensure here that the owner cannot be removed.
        require(_removeDelegate != owner, "Removal of the owner as delegate is not provided.");
        if (delegates[_removeDelegate])
        {
            delegates[_removeDelegate] = false;
            emit DelegationChanged(msg.sender, _removeDelegate, "removed as delegate.");
        }
    }

Error: 80:5: ParserError: Expected pragma, import directive or contract/interface/library definition. function delDelegate(address _removeDelegate) public onlyDelegates

Corrections

  • Change requires() to require().
  • Using the modifier onlyDelegates() (with brackets) in the function headers.

incorporated into the code draft.

Feel free to correct the code directly on the wiki page if you have suggestions for corrections. ;-)

Clone this wiki locally