0

a is the contract that contains the delegate call, b is the calling contract,

I wonder if this B contract can be used for another contract also which contains delegate call?

In the end, I'm interested in how in this case contract B should be made in accordance with contract A to call delegatecall, what should I take into account? and if the same contract B calls another contract that contains delegatecall, What should I change in contract B?

1 Answer 1

1

I suggest you to take a look a the diamond structure where you define one main contract that will delegatecall to the right contracts depending on the function signature https://eips.ethereum.org/EIPS/eip-2535

Otherwise concerning your questions, the main thing to take into account is storage collision, contract A delegateCall to contract B will modify contract A storage. You can add a check inside contract B depending if you want to delegateCall to another contract, based on the Diamond structure, one way to do so is to define a function signature with contract addresses to delegateCall to the right contract.

5
  • Ok I will read all of this, Also I can't combine two smart contracts on remix when I try to call a delegatecall or fallback function, how can I do this?
    – tomas
    Aug 24, 2022 at 11:28
  • solidity-by-example.org/delegatecall Try with this example, deploy B first
    – Cheen
    Aug 24, 2022 at 12:57
  • Should I deploy to a different address? If some address?
    – tomas
    Aug 24, 2022 at 14:33
  • If you use Remix. From the example, you deploy contract B and copy its address. Then you deploy contract A with contract B address in parameters.
    – Cheen
    Aug 24, 2022 at 14:43
  • when i deploy contract B, contract B address load ,, At address load contract from address,, when i deploy contract A?
    – tomas
    Aug 24, 2022 at 16:56

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.