I'm familiar with proxy contracts in solidity using the 'delegatecall' to separate out the proxy contract from the logic contract. Is there a simple way to choose the logic contract based on an argument that I pass into the call as opposed to "upgrading" a contract permanently?

I feel like I've seen people do this in various contracts, but I haven't really seen documentation on it so I'm not sure what it's called. I think of it as dynamic proxying, but it may be called something else.

Basically, I would like my proxy contract to point to 1 of many logic contracts depending on an argument that I pass into the function call. So say I'm making a call to a function "GetValue" and I want to pass it a number as a parameter. I'm thinking one way to do this would be to pass an additional parameter that tells the proxy contract which logic contract to use. It seems like I'd have to use some assembly code inside my proxy contract to pull that off. So the proxy contract would read the first few bytes of the data and use that to determine what logic contract to call. Then it would delegate the call off to the logic contract (possibly without that additional parameter...)

Openzeppelin may have something that does this. I personally prefer using Python for my Ethereum development as opposed to javascript. Since Openzeppelin's tools tend to rely on javascript, I haven't really been using them outside of following their solidity patterns.

Note: I understand that I could just leave the proxy contract as is, and sub proxy within my logic contract. But that seems unnecessary when that's supposed to be the purpose of the proxy contract to begin with.

Additional thought: So in the code I linked above, it would be almost as if I called "upgradeTo" everytime I call the contract. But instead of the overhead of upgrading the logic contract, just choose which logic contract to forward the delegated call to.

1 Answer 1


Answer from the OpenZeppelin Community Forum: https://forum.openzeppelin.com/t/proxy-that-routes-to-multiple-logic-contracts-based-on-param/2595/2

Is there a reason that you can’t use OpenZeppelin upgradeable contracts and just have a single logic contract? See Upgrading Smart Contracts Learn guide. I would suggest looking at this first to see if it meets your needs.

I would be very cautious about rolling your own upgrade mechanism, and recommend any such mechanism you create be appropriately tested and audited. (OpenZeppelin perform security audits: https://openzeppelin.com/security-audits/)

Nick Mudge has been working on some alternative upgrade mechanisms, including ethereum/EIPs#2535 that you could look at if you are going down that path.

  • Exactly what I was looking for. Thanks!
    – LampShade
    Commented Apr 7, 2020 at 16:40

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.