0

Ganache has recently introduced the ability to fork from a live blockchain at a particular block number. https://github.com/trufflesuite/ganache/releases/tag/v7.0.0

After forking, I would like to be able to modify the smart contract code of an existing contract in order to test what happens with different versions of this contract in the current state of the blockchain. An obvious example why I might do this is to add in some events to the contract that aren't already there and then trace those events for debugging purposes.

Is this possible in any way?

Of course, you can't normally modify code after contract deployment. But since this is a local blockchain, I was hoping there would be a way of breaking the rules and force some new code in?

Most importantly, I can't deploy a new contract because I want to have access to this contract's storage, and also, performing this extra transaction will interfere with the block number, and I intend to do some simulations from the exact block number at fork-time.

I want to be able to do this with arbitrary contracts, so I won't have control over the original contract code deployed to the real blockchain. And so my only opinion is to forcefully modify the code after forking.

Any ideas?

1 Answer 1

2

This is not easily possible judging by https://github.com/trufflesuite/ganache/issues/649

You can pipe in a custom db and adjust the contract storage there, but this requires knowledge about ganache internals.

Note: network forking is a quite old feature and you can potentially find quite some reference code how to work around your issue.

1

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.