For example, I want to deploy a contract to my local testnet. But I only have its opcode from etherscan. How to deploy the contract with just those runtime bytecode?

3 Answers 3


You will also need ABI, not just bytecode. Look at the next article, it will give you good starting point: https://medium.com/@prashantprabhakarsingh/deploying-contract-using-bytecode-myetherwallet-and-remix-10f643a82d40

  • 2
    You do not need the ABI to deploy a contract. It is needed if you want to interact with the contract.
    – Ismael
    Sep 30, 2018 at 15:50
  • 2
    How can you set constructor parameters if you don't have ABI? Oct 1, 2018 at 13:29
  • 2
    You are correct! If the constructor need parameters you only need the constructor ABI.
    – Ismael
    Oct 1, 2018 at 17:15
  • how can I construct ABI? I know the parameters eg. (address to, address from, unit amount)
    – anonymous
    Jun 15, 2021 at 7:39

If you just want to deploy exactly the same contract and don't need the ABI, you can simply copy the transaction data of the deployment transaction. And then, depending on what kind of provider you have, it would look something like this.

  const sendTx = async () => {
    const data = '0x....'; // opcode here
    const params = [
        from: account,
        data: data,
    await provider.send('eth_sendTransaction', params)

If you can connect to it via an rpc endpoint and add that to MetaMask, you can go here: https://lovethewired.github.io/abi-playground and paste in the deployment data and click on 'send'.


When someone needs to use the mainnet contracts and also the data in their local networks, the most convenient way is - the forking. We use hardhat/mainnet-forking. Due to the deterministic storage access in EVM, the forking works fast and seamlessly:

  • when you call a method of a contract address that is not yet in the local chain, the contract will be downloaded under the hood with getCode.
  • when during the method execution a storage slot is accessed, which is not yet in the local chain, the data will be automatically fetched with getStorageAt.

Sometimes if you want to call a method that is for example with onlyOwner modifier, with hardhat you have a lot of development methods:

  • you can execute transactions with any EOA address as the sender
  • you can modify the contract's storage to set your own EOA address for the owner state variable

You may need the verified contracts from Etherscan when you need to modify the source code of a contract and redeploy it to the local network. We use 0xweb for this purpose

0xweb i 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 --name USDC --chain eth

This downloads the ABI and the source code from Etherscan, after that you modify the source code you find in ./0xweb/eth/USDC/**.sol

0xweb deploy USDC --deployer Foo --chain hardhat 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.