Skip to main content
Modified some grammatical mistakes
Source Link
Henk
  • 4.3k
  • 1
  • 13
  • 27

My code on Solidity is:

contract Recoverable is Ownable {

  /// @dev Empty constructor (for now)
  function Recoverable() public {
  }

  /// @dev This will be invoked by the owner, when owner wants to rescue tokens
  /// @param token Token which will we rescue to the owner from the contract
  function recoverTokens(ERC20Basic token) onlyOwner public {
    token.transfer(owner, tokensToBeReturned(token));
  }

  /// @dev Interface function, can be overwritten by the superclass
  /// @param token Token which balance we will check and return
  /// @return The amount of tokens (in smallest denominator) the contract owns
  function tokensToBeReturned(ERC20Basic token) public returns (uint) {
    return token.balanceOf(this);
  }
}

And I get next error: Function state mutability can be restricted to view function tokensToBeReturned(ERC20Basic token) public returns (uint) { ^ (Relevant source part starts here and spans across multiple lines).

I take this example from GitHub, and when I try куdeclare a function as internal pure, then get the next error:

A function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
    return token.balanceOf(this);
                           ^--^

P.S. Help me, I really don`t understand.

My code on Solidity is:

contract Recoverable is Ownable {

  /// @dev Empty constructor (for now)
  function Recoverable() public {
  }

  /// @dev This will be invoked by the owner, when owner wants to rescue tokens
  /// @param token Token which will we rescue to the owner from the contract
  function recoverTokens(ERC20Basic token) onlyOwner public {
    token.transfer(owner, tokensToBeReturned(token));
  }

  /// @dev Interface function, can be overwritten by the superclass
  /// @param token Token which balance we will check and return
  /// @return The amount of tokens (in smallest denominator) the contract owns
  function tokensToBeReturned(ERC20Basic token) public returns (uint) {
    return token.balanceOf(this);
  }
}

And I get next error: Function state mutability can be restricted to view function tokensToBeReturned(ERC20Basic token) public returns (uint) { ^ (Relevant source part starts here and spans across multiple lines).

I take this example from GitHub, and when I try куdeclare a function as internal pure, then get the next error:

A function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
    return token.balanceOf(this);
                           ^--^

P.S. Help me, I really don`t understand.

My code on Solidity is:

contract Recoverable is Ownable {

  /// @dev Empty constructor (for now)
  function Recoverable() public {
  }

  /// @dev This will be invoked by the owner, when owner wants to rescue tokens
  /// @param token Token which will we rescue to the owner from the contract
  function recoverTokens(ERC20Basic token) onlyOwner public {
    token.transfer(owner, tokensToBeReturned(token));
  }

  /// @dev Interface function, can be overwritten by the superclass
  /// @param token Token which balance we will check and return
  /// @return The amount of tokens (in smallest denominator) the contract owns
  function tokensToBeReturned(ERC20Basic token) public returns (uint) {
    return token.balanceOf(this);
  }
}

And I get next error: Function state mutability can be restricted to view function tokensToBeReturned(ERC20Basic token) public returns (uint) { ^ (Relevant source part starts here and spans across multiple lines).

I take this example from GitHub, and when I try куdeclare a function as internal pure, then get the next error:

function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
    return token.balanceOf(this);
                           ^--^

P.S. Help me, I really don`t understand.

Need help with smurtsmart contract

My code on Solidity is:

contract Recoverable is Ownable {

  /// @dev Empty constructor (for now)
  function Recoverable() public {
  }

  /// @dev This will be invoked by the owner, when owner wants to rescue tokens
  /// @param token Token which will we rescue to the owner from the contract
  function recoverTokens(ERC20Basic token) onlyOwner public {
    token.transfer(owner, tokensToBeReturned(token));
  }

  /// @dev Interface function, can be overwritten by the superclass
  /// @param token Token which balance we will check and return
  /// @return The amount of tokens (in smallest denominator) the contract owns
  function tokensToBeReturned(ERC20Basic token) public returns (uint) {
    return token.balanceOf(this);
  }
}

And I get next error: Function state mutability can be restricted to view function tokensToBeReturned(ERC20Basic token) public returns (uint) { ^ (Relevant source part starts here and spans across multiple lines).

I take this exempleexample from githubGitHub, and when I try куdeclare a function as internal pure, then get the next error:

FunctionA function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
    return token.balanceOf(this);
                           ^--^

P.S. Help me, I really don`t understand.

Need help with smurt contract

My code on Solidity is:

contract Recoverable is Ownable {

  /// @dev Empty constructor (for now)
  function Recoverable() public {
  }

  /// @dev This will be invoked by the owner, when owner wants to rescue tokens
  /// @param token Token which will we rescue to the owner from the contract
  function recoverTokens(ERC20Basic token) onlyOwner public {
    token.transfer(owner, tokensToBeReturned(token));
  }

  /// @dev Interface function, can be overwritten by the superclass
  /// @param token Token which balance we will check and return
  /// @return The amount of tokens (in smallest denominator) the contract owns
  function tokensToBeReturned(ERC20Basic token) public returns (uint) {
    return token.balanceOf(this);
  }
}

And I get next error: Function state mutability can be restricted to view function tokensToBeReturned(ERC20Basic token) public returns (uint) { ^ (Relevant source part starts here and spans across multiple lines).

I take this exemple from github, and when I try куdeclare a function as internal pure, then get next error:

Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
    return token.balanceOf(this);
                           ^--^

P.S. Help me, I really don`t understand.

Need help with smart contract

My code on Solidity is:

contract Recoverable is Ownable {

  /// @dev Empty constructor (for now)
  function Recoverable() public {
  }

  /// @dev This will be invoked by the owner, when owner wants to rescue tokens
  /// @param token Token which will we rescue to the owner from the contract
  function recoverTokens(ERC20Basic token) onlyOwner public {
    token.transfer(owner, tokensToBeReturned(token));
  }

  /// @dev Interface function, can be overwritten by the superclass
  /// @param token Token which balance we will check and return
  /// @return The amount of tokens (in smallest denominator) the contract owns
  function tokensToBeReturned(ERC20Basic token) public returns (uint) {
    return token.balanceOf(this);
  }
}

And I get next error: Function state mutability can be restricted to view function tokensToBeReturned(ERC20Basic token) public returns (uint) { ^ (Relevant source part starts here and spans across multiple lines).

I take this example from GitHub, and when I try куdeclare a function as internal pure, then get the next error:

A function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
    return token.balanceOf(this);
                           ^--^

P.S. Help me, I really don`t understand.

Source Link

Need help with smurt contract

My code on Solidity is:

contract Recoverable is Ownable {

  /// @dev Empty constructor (for now)
  function Recoverable() public {
  }

  /// @dev This will be invoked by the owner, when owner wants to rescue tokens
  /// @param token Token which will we rescue to the owner from the contract
  function recoverTokens(ERC20Basic token) onlyOwner public {
    token.transfer(owner, tokensToBeReturned(token));
  }

  /// @dev Interface function, can be overwritten by the superclass
  /// @param token Token which balance we will check and return
  /// @return The amount of tokens (in smallest denominator) the contract owns
  function tokensToBeReturned(ERC20Basic token) public returns (uint) {
    return token.balanceOf(this);
  }
}

And I get next error: Function state mutability can be restricted to view function tokensToBeReturned(ERC20Basic token) public returns (uint) { ^ (Relevant source part starts here and spans across multiple lines).

I take this exemple from github, and when I try куdeclare a function as internal pure, then get next error:

Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
    return token.balanceOf(this);
                           ^--^

P.S. Help me, I really don`t understand.