getting this error, any assistance is greatly appreciated.

browser/ballot.sol:166:17: DeclarationError: Undeclared identifier.
      require(_to != address(0));

function mintToken(address _target, uint256 _mintedAmount) onlyAdmin supplyLock public {
    require(_to != address(0));
    balances[_target] = SafeMath.add(balances[_target], _mintedAmount);
    totalSupply = SafeMath.add(totalSupply, _mintedAmount);
    Transfer(0, this, _mintedAmount);
    Transfer(this, _target, _mintedAmount);
  • Where is _to defined? Maybe you meant to write _target?
    – user19510
    Feb 24 '18 at 5:10
  • _target works great.. tyvm Feb 24 '18 at 5:46

you have to first declare the _to variable before using it. The error name says it all.

DeclarationError: Undeclared identifier.

In your code there's nothing declared before as _to, to compare with address(0) at require(_to != address(0));.

You may have to include it in function parameters as function mintToken(address _target, address _to, uint256 _mintedAmount) or first declare it as address _to = <some address goes here>.

Or else here require(_to != address(0));, _to should be something else. Possibly _target as suggested by @smarx in comments.

  • 1
    @MorganChan it's better if you can an accept answer, it might help other users as well
    – Refiner
    Feb 24 '18 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.