8

I am new to solidity and trying to deploy a contract to see whether the address is EOA or Smart Contract. The code is listed below. I am not able to see the boolean value when I executed the contract in the mainnet.

pragma solidity ^0.4.0;
contract Ballot {

event isEOAOrNot(bool val);

function isContract(address addr) returns (bool) {
  uint size;

  assembly { size := extcodesize(addr) }
  bool val = size > 0;
  isEOAOrNot(val);
  return val;
}




}

3 Answers 3

9

Here's the best way I know:

  1. Launch contract:

Step 1

  1. Run transaction:

Step 2

  1. View transaction data:

enter image description here

  1. Find the "event" and "args" parameters under logs: enter image description here

And there you have it; the event and the arguments.

4
  • It's not there. Commented Jun 15, 2018 at 20:28
  • @ErickRobertson if you could provide more details, I will try and see what went wrong. On what step did you get stuck?
    – Nicholas
    Commented Jun 17, 2018 at 19:22
  • It was there for me, this should be the accepted answer.
    – cmikeb1
    Commented Nov 10, 2018 at 17:28
  • This is pretty uncomfortable to have to extract the events from the details like this. Can't it be automated and the events printed below the transaction somehow? Is there a plugin that could do it?
    – Qwerty
    Commented Jan 22, 2022 at 20:28
3

You've missed the emit when calling the isEOAOrNot(val) event. should be:

emit isEOAOrNot(val);
1

If you compile a different contract, previous contracts that you deployed will no longer show events. So, recompile the contract you want to see the events for before calling the method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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