1

I have a contract A calling another contract B

Contract A

contract A {

   function sendValue(B _externalContract, uint _value) {
     _externalContract.acceptValue(_value);
   }
}

contract B {
   function acceptValue(unit value);
}

Contract B (contract A expect contract B acceptValue to be safe)

  contract B {
       function acceptValue(unit _value) {
         dosomethingWith(_value)
       }
    }

If a malicious user now design contract B function acceptValue to self destruct like so

Contract B

  contract B {
       function acceptValue(unit _value) {
         selfdestruct(msg.sender);
       }
    }
  • Will that function destroy my contract A or malicious user Contract B?
  • Is there a check I can perform in contract A sendValue to prevent that?
3

It destroys Contract B and sends B's Eth balance to contract A, if called from A.

There is no way B can destroy A. Otherwise, there would be chaos.

Hope it helps.

  • Thanks for the answer. It helps a lot. – Abk Apr 13 at 17:53
  • My pleasure. Thanks for accepting my answer. – Rob Hitchens - B9lab Apr 14 at 2:46

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.