Resources

People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!

Debugging Deployed Smart Contracts from Etherscan- 1362

bytes032Posted 2 Years Ago
  • Being able to debug live code deployed on mainnet is a real pain in the butt. So, this is a strategy to do that.
  • First, fork the chain you want to work with using Foundry. This gives us control over a network to do what we want.
  • Next, download the flattened source code from Etherscan. Now, we can make changes, such as print statements to the code to help out. We need to be careful not to modify the state or storage slots of anything.
  • Finally, call vm.etch with our new code. This will overwrite the code at our target contract with our debug version but with the state of the mainnet one! Just a small tip to debug live contracts deployed on mainnet better.