2

I am using Remix to compile and deploy my smart contract to Rinkeby and RSK test networks. I don't understand why the bytecode of my contract on Rinkeby explorer is different from the metadata.data.deployedBytecode.object in Remix artifacts and also different from evm.deployedBytecode.object coming from solcjs compiler. I also tried this on RSK and I got the same issue.

That's what I do in Remix:

I create a MegaHonk.sol file in contracts folder

// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.7;

contract MegaHonk {
  uint256 public count;

  event LoudSound(address indexed source);

  function honk() external {
    require(tx.origin != msg.sender, 'EOA not allowed');
    count += 1;
    emit LoudSound(tx.origin);
  }
}

I select the appropriate compiler version 0.8.7, select Environment: Injected provider - Metamask, compile and deploy to Rinkeby. The contract successfully deploys. Then I go to Rinkeby explorer, find my contract bytecode and compare it with the one in remix-file-explorer/contracts/artifacts/MegaHonk.js in the metadata.data.deployedBytecode.object property.

Bytecode from Rinkeby is 1348 symbols long and Bytecode from Remix is 1350 symbols long.

The exact same thing happens when I am compiling the same smart contract with solcjs compiler. I use the right version 0.8.7 and these input parameters:

const input = {
  language: 'Solidity',
  settings: {
    outputSelection: {
      '*': {
        '*': ['evm.deployedBytecode', 'evm.bytecode'],
      },
    },
    optimizer: {
      enabled: false,
    },
  },
  sources: {
    'MegaHonk.sol': {
      content: MegaHonk,
    },
  },
};

Why does this happen? What compiler parameters should I use to make the bytecodes identical in the Remix artifacts, solcjs compiler and in blockchain explorer (Ethereum or RSK testnets)?

Aleks Shenshin
  • 2,117
  • 5
  • 18

0 Answers0