0

I wrote a smart contract earlier today using Remix. I was away for a few hours, and when I came back my computer was out of battery. I've configured my browser to never save cookies, so even when I go back to Remix it isn't in the IDE. I still have the ABI, bytecode, and contract address. Is this info enough to recover the contract?

I've tried to use the At Address option for deploying the contract, but an error comes up:

No compiled contracts found.

Thank you.

2 Answers 2

1

To bring back a previously deployed instance is only possible if you have deployed on a testnet or mainnet or if the localnet that you were using at that time is still the same and was not cleared.If not, you have no choice but to redeploy a new instance.

If you have deployed this contract on a testnet, mainnet or still the same localnet here is how to do:

You simply have to have the contract you wish to deploy in the active tab.

Here is a full rundown in case:

  1. download back the same contracts to Remix:

enter image description here

  1. open the file you wish to deploy in a new tab by clicking on it and stay on it:

enter image description here

  1. make sure to compile them (I generally tick the 'autocompile' checkbox):

enter image description here

  1. select the contract you wish to deploy in the dropdown menu:

enter image description here

  1. use the at address to bring up the already deployed instance of your contract:

enter image description here

And there you go !

2
  • 1
    This is not really helpful because I don't have access to the .sol file. So when you say: You simply have to have the contract you wish to deploy in the active tab. I can't do that. I think the only other option is a recompiler, so I'll just rewrite the code.
    – Spaghetti
    Commented May 20 at 23:41
  • You did not say you did not have access to the file. How could I guess. Be clear and you will get relevant answers. In that case what @Awais said will be useful to you in the future. Always save your files. Without the file there is obviously not much you can do to bring back the exact same code.
    – Torof
    Commented May 21 at 2:00
0

If your contract is verified and published on the testnet/mainnet explorer, you can get the code from there. But if you accidentally delete the code, you can't recover it. It's best to code in VS Code or connect VS Code to Remix using 'remixd',Below are the steps, your code will be saved locally and won't be accidentally deleted:

  1. Make solidity files in VS code.
  2. Install 'remixd' via this command: sudo npm install -g @remix-project/remixd
  3. Run the local server by using this command: remixd -s ./ --remix-ide https://remix.ethereum.org
  4. Then finally go to remix and connect to LocalHost

Now when you will code on remix, it will save automatically in local.

4
  • 1
    That is not what the person asked. They want to bring back the same instance previously deployed. Although that is only possible on testnets or mainnet.
    – Torof
    Commented May 20 at 9:26
  • Well Done @Torof. Exactly its possible on Testnet/Mainnet Commented May 20 at 9:32
  • So @Torof I answered right. Commented May 22 at 21:55
  • @Spaghetti kindly accept it if it is useful. Commented May 22 at 21:55

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.