1

I'm currently facing a challenging issue with an investment smart contract deployed on the Binance Smart Chain (BSC). The contract already has active investments, but it contains a critical bug that needs to be fixed.

The Situation: I have an existing investment smart contract on BSC. The contract has a considerable amount of active investments. I've identified a bug in the contract logic that needs to be fixed immediately. The Challenge: I understand that I can't simply update the existing contract because smart contracts are immutable. Also, redeploying a new contract would mean losing all the active investments in the current contract. Hence, I'm considering implementing a proxy contract to resolve this issue.

My Questions:

  1. What is the best practice for implementing a proxy contract to handle this specific situation?
  2. How can I migrate the existing data (i.e., active investments and other states) from the original contract to the new proxy contract?
  3. Are there any security considerations I should be aware of when performing this migration?
  4. Do you recommend any specific tools or libraries for implementing the proxy contract and migration on BSC?
  5. Are there any code snippets or tutorials that can guide me through this process?

Any guidance or recommendations would be highly appreciated.

Thank you!

1 Answer 1

1

Im afraid that if your contract was not originally deployed using a proxy pattern, then it is not possible to make that kind of upgrade now.

Proxy patterns separate storage from logic. Hence your state would have been stored in the proxy and all the logic would be used through delegatecall on the proxy contract.

However, in regular contracts the logic and state are tied together, and you cant just separate them and migrate the state to a different contract.

The only solution I see is to deploy a V2 of the contract (maybe this time using a proxy pattern, check UUPS), tell your users to redeem their investment and migrate to the new contract

2
  • Yes, i understand that, but the contract right now doesn't have a "redeem" function by anyone, even the owner. The investors only can redeem their profits valid in time. so how can i do this?
    – vasik
    Commented Sep 28, 2023 at 2:51
  • Is there anything like a Pausable modifier in the contract so at least you can freeze it until the timelock expires? The situation is thorny to be honest. I cant think about any solution if this was not contemplated in the original contract. Also, its probably better not to share the contract code here, even if people have good intentions and want to help, you can make it discoverable by bad actors
    – IpastorSan
    Commented Sep 28, 2023 at 7:33

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.