0

enter image description here

DeclarationError: Undeclared identifier.on line 8,12,14.

胡镡文
  • 3
  • 2

1 Answers1

0

_success is not defined anywhere. Is just a parameter of the event isNotify but is not a field neither in your function nor in your contract.

So you need to define your local field and then use it to emit the event.

function register(string _name) public {
    bool _success = false;
    if (nameToAddress[_name] == address(0)) {
        nameToAddress[_name] = msg.sender;
        _success = true;
    }

    emit isNotify(_success);
}

please note that tx.oring is not safe to use, better to use msg.sender; more info here and here.

qbsp
  • 4,367
  • 2
  • 15
  • 26