You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently I have been using flatten a lot (awesome tool!), and I noticed a repeated issue that came up in my compilation pipeline with using flatten'd contracts.
The flattened files tend to have multiple pragma solidity ... statements, and often times they do not match exactly. Some statements may use ^0.8.0 and others =0.8.X. Of course, this can still compile fine if you know the correct solc version to use, but specifically the ethers-rs and foundry suite of tools often fails to compile these types of files, as it struggles to auto-detect the solc version required to satisfy each of the pragma statements in these. I assume dapptools, hardhat etc have similar issues with multiple pragma solidity ... statements.
I noticed there is a Compiler Version field on the etherscan-like sites that displays the exact solc version that was used to compile the contracts. This is a required field upon contract verification, so it should be present on all verified contracts. Would it be possible to utilize this field and insert a pragma solidity =<compiler version>; at the top of the file and comment out each of the other pragma solidity ... statements?
Recently I have been using
flatten
a lot (awesome tool!), and I noticed a repeated issue that came up in my compilation pipeline with usingflatten
'd contracts.The flattened files tend to have multiple
pragma solidity ...
statements, and often times they do not match exactly. Some statements may use^0.8.0
and others=0.8.X
. Of course, this can still compile fine if you know the correct solc version to use, but specifically theethers-rs
andfoundry
suite of tools often fails to compile these types of files, as it struggles to auto-detect the solc version required to satisfy each of the pragma statements in these. I assume dapptools, hardhat etc have similar issues with multiplepragma solidity ...
statements.I noticed there is a
Compiler Version
field on the etherscan-like sites that displays the exact solc version that was used to compile the contracts. This is a required field upon contract verification, so it should be present on all verified contracts. Would it be possible to utilize this field and insert apragma solidity =<compiler version>;
at the top of the file and comment out each of the otherpragma solidity ...
statements?Example of different etherscan-like sites verified contracts with
Compiler Version
:https://etherscan.io/address/0x27761c482000f2fc91e74587576c2b267eeb4546#code
https://polygonscan.com/address/0xAe8C44b49f9756BFEdA7b6B5F0F66bf42d96aD8C#code
https://snowtrace.io/address/0x711555f2b421da9a86a18dc163d04699310fe297#code
https://arbiscan.io/address/0xD91D0d52D6e09f0b93db80E1A8935aA47CFFd075#code
Minimal file example for failed auto-detect solc version compilation
Foundry + ethers-rs detects this as requiring latest solc (0.8.17) as it matches on
last
entry ofpragma solidity
Proposed Feature
Say
Compiler Version: v0.8.15+commit.e14f2714
Footguns
pragma solidity
should be commented as to not accidentally comment outpragma experimental ...
lines<compiler version>
should likely always be pre-pended with an=
The text was updated successfully, but these errors were encountered: