If I understand correctly CALLCODE substitute/replace (and not add) the ledger of the target contract with the one the calling contract, isn’t it ?

So that when contract Victor CALLCODE Alice, Alice does no longer use Alice´s ledger but Victor’s ledger, right ?

If true, when contract Alice calls contract Bob normally and when Bob checks msg.sender, who is msg.sender Alice or Victor ?

  • Of course, I forgot to say Alice Bob and Victor are all contract stored at different addresses. – user2284570 Jun 20 '18 at 14:58

You can not delegatecall normal accounts, only contract accounts.

  • Of course, I forgot to say Alice Bob and Victor are all contract. – user2284570 Jun 20 '18 at 14:58
  • But you could guess it by reading the title. – user2284570 Jun 20 '18 at 15:37
  • Apologies, I found the abstraction of using names a bit weird :). Delegatecall is merely a forwarder. Imagine this: User --call--> Contract Victor --delegatecall--> Contract Alice (msg.sender here is Victor) --> delegatecall Contract Bob (msg.sender here still Victor). Keep in mind delegatecall also forwards the storage. Check out this real life example I'm working on : github.com/designisdead/blockchain-programmable-incentives/tree/… User --Call--> Controller --call-->Storage --Delegatecall-->Proxy --Delegatecall--> Library – Nico Vergauwen Jun 20 '18 at 15:59
  • The purpose of the repo is to create upgradeable libraries so our storage delegates calls (with it's storage) to the library that contains the logic. More here : blog.zeppelin.solutions/… – Nico Vergauwen Jun 20 '18 at 16:01
  • And one more time you didn’t read me. I wrote If true : when contract Alice calls contract Bob normally. So this means User --call--> Contract Victor --delegatecall or CALLCODE--> Contract Alice (msg.sender here is Victor) --> CALL Contract Bob normally (not Callcode or delegatecall) (who is msg.sender in that case ?) – user2284570 Jun 20 '18 at 16:55

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.