Ethereum: Debugging Binary Differences Between Local and Remix
As a solidity development, In this article,
The Issue: Different Binary Formats
(Solidity Compiler) Locally, it produces a binary file with a specific format that’s compatible only with the local machine’s architecture. However
The Problem: Solc Compiler Version
A potential cause of these binary differentences is a mismatch between the version of the solc compiler being used locally versus what remix is ​​used. The SOLC
Compiler version might not be compatible with your local setup, leading to different binary outputs when compiling and deploying on both platforms.
Testing with remix
. We’ll create a new contract and deploy it using remix,
Here’s an updated version of your code:
`Solidity
Pragma Solidity 0.8.20;
Helloworld contract {
Function Test () Public Pure Returns (Bool) {}
}
// Deployment with remix
Main Function () Public Payable {
Helloworld Memory Hello = Hello ();
Require (hello.test () == true, "hello");
}
Deployment to Remix
We Solana compiler used.
Testing with Solc Compiler Version
Now, let’s test this scenario by comparing the binary output produced locally versus when we use remix.
Local Compilation
`Bash
cd ~/truffle
-V SOLIDITY -0.8.20.JS -BIN HELLOWORLED.JS
`
Remix Deployment (with Solana)
Solana blockchain and interact with it to test our deployment.
`JavaScript
Const {Web3} = Require ('Web3');
Const Web3 = New Web3 ();
Async Function Main () {
Const Networkname = 'Mainnet';
Const accountdress = '0x ...'; // replace with your own solana address
try {
Const transactioncount = Await web3.eth.gettransactioncount (accountdress);
Const tx = Await Web3.eth.sendtransaction ({
From: Accountdrys,
to: '0x ...', // replace with the Recipient's Address
Value: web3.utils.towei ('1', 'ether'),
Gas: 200000,
Gassrice: 20,
});
console.log (tx);
} Catch (Error) {
Console.Error (Error);
}
}
Slender ();
Compare Binary Outputs
We can compare the binary output produced locally and when
Comparison Output
When we run the code in local Let’s take a look at the potential differences:
`Bash
$ Objdump -h Helloworld_0x12345678.bin
File Format bin
`
We’ll compare the output of objdump
for both scenarios.
In this example, the `helloworld_0x12345678. Binary produced locally has a different structure and layout compared to what’s deployed with remix. This difference might be caused by the solana compiler used in remix versus the solc compiler being used locally.