I'm trying to configure some protocols in Solidity (4.4 or olders) but I'm struggling right now an issue with the [thirdPartyAddress]. The code is the following:

function transfer(address _to, uint256 _value) {
require(_value%100 == 0);
uint fee = _value/100;
require (balanceOf[msg.sender] > _value);
require (balanceOf[_to] + _value > balanceOf[_to]);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += (_value-fee);
balanceOf[thirdPartyAddress] += _value;

Error message is: DeclarationError: Undeclared identifier. balanceOf[thirdPartyAddress] += _value;

Is there some suggestion to solve this issue?

Thanks in advance!


thirdPartyAddress is not declared, hence the error.

To solve the issue you could :

  • declare thirdPartyAddress as a state variable and write a function to set it
  • add thirdPartyAddress as a parameter of your function : function transfer(address _to, uint256 _value, address thirdPartyAddress). However, note that in this case you will not follow the ERC20 interface anymore. So it may not be suitable.

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.