Ethereum: tuning binaary differentiation between local and remix
Ass a solidity developer, you are none in no diferrencess in the binary output between the local Trufle Compiler Compiler Compiling and Putting Etherum Using a Remix. In this article, wet examine what causes these discrepiseies and gifts.
Problem: Different Binary formats
When you bild your Solidity code the SOLC (Compiler Solidity Compiler), it will binary with a specific format that is the compatible on-inly with architecture machine. However, when you deploy your contract to the Ethereum network using Remix, the same source code is compiled in different binary files due to the differences in the native compiler Solana Blockchain and Ethereum Virtual Machine (EVM) requirements.
Problem: SOLC compiler version
The potential cause of these binary differentiation is the mist of between the the SOLC compiler versionus, whist use use compared to what Remix use. The “Solccompiler compiler does not have to be compatible with local settings, leading to differentiate binaary outputs when assembling and deploying on both platforms.
Testing with Remix
To verify this hypothesis, Welch is its to the original compiler Solana ("Solan). slebma .
Here’s an updded version of off your code:
`Solidity
Pragma Solidity 0.8.20;
HELLOWARLD Contract {
Test function () Public Pure Returns (BOOL) {}
}
// deployment with remix
Main () PUBLIC feature payable {
HELLOWARLD MEMORY HELLO = HELLO = HE ();
demand (Hi.test () == thrue, "Hi");
}
Deployment in Remix
We’re the library of “Web3.js” in in a remix to intraact with a local machine blockchain and to deplow our contract surrene account. The deployment processed process various various binary filedening is the one.
Testing with SOLC compiler version
Now we will test this scenario by comparing the binary output off the producted voucher opposits opposits of we dose Remix.
Local compilation
`Bash
CD ~/Truffle
Solc -v Solidity -0.8.20.Js bin Heloworld.Js
`
Remix Deployment (with Solan)
To deplow ur contract, we will be new account for the Blockchain Solan and Intraact with it to test or the commitment.
`Javascript
Const {web3} = require (‘web3’);
Const Web3 = New Web3 ();
Async function Main () {)
Const Networkame = ‘Mainnet’;
Const Accountddddress = ‘0x …’; // repose with your award
try {
Const TransctionCount = ACAIT Web3.eth.gettransactionCount (Accountaddddress);
Const Tx = wait for web3.eth.ssend transction ({{In
the accounter drain,
to: ‘0x …’, // Replace them
Value: Web3.utils.towei (‘1’, ‘ether’),
Gas: 200000,
Gas: 20,
});
Console.log (TX);
} Catch (Error) {
Console.error (Error);
}
}
Main ();
`
Compare the binaary outputs
We can compress the binaary output urcally and when we use a remix to identify.
Comparison off Output
When’s we run the code in local mode, comparated to what we deplow with Remix, wes column see an another binaary format. Let’s look at the power differential:
`Bash
$ Objdump -h Helfoworld_0x12345678.bin
bind format
`
We compresses the output “Objdump” for the both scenario.
In the Instant Example, the Helloworld_0x12345678.binary Product Local Different and District compared to what is deployed with remix. This differentiation may be caused by the Solan compiler used in the Remix Versus off the osed SOLC compiler.