Questions tagged [compiler]
A compiler is a computer program that translates a higher-level programming language into a lower-level language. For example: Solidity is compiled into EVM opcodes.
198 questions
1
vote
0
answers
20
views
Solidity: Source file requires different compiler version (current compiler is 0.8.28+commit.7893614a.Emscripten.clang)
Hey all, sorry if this aint the right place, but I feel like I'm losing my mind.
I'm getting this error, which I've tried troubleshooting through searches and chatgpt and nothing has really worked, ...
0
votes
1
answer
29
views
"Undeclared identifier" errors when compiling contract with npx hardhat
I am trying to compile a contract in solidity for flash loan node bot, but it does not compile, so I can deploy it on L2 networks.
Contract code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8....
0
votes
0
answers
13
views
Error: pragma solidity >0.4.0 <= 0.9.0; ParserError: Expected ';' but got '}'
Please help me the error: from solidity:
ParserError: Expected ';' but got '}'
Here is the code:
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) {
...
0
votes
0
answers
11
views
Compilation of inheritance chain
I came to know that given contracts
fileA.sol
pragma solidity >= 0.7.0;
contract A {}
is imported by
fileB.sol
import './fileA.sol';
pragma solidity 0.8.0;
contract B {}
where B is the top-level ...
0
votes
1
answer
96
views
Foundry Compile Error [duplicate]
Error: Compiler error (C:\Users\circleci\project\libsolidity\codegen\CompilerUtils.cpp:1459):Stack too deep. Try compiling with --via-ir (cli) or the
equivalent viaIR: true (standard JSON) while ...
0
votes
0
answers
138
views
Solc too slow compiling
The solc compiler that I'm using (0.8.21) is taking too much time to compile. It's compiling 20 files for a foundry test campaign in ~90 seconds when it should be milliseconds.
Any ideas on what I ...
0
votes
1
answer
26
views
TypeError: Contract "TestContract" should be marked as abstract
I have issues so I slowly add one library at a time.
This code compiles.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/Ownable.sol";
import ...
0
votes
2
answers
45
views
Error import : "File import callback not supported" (using remappings) [Pyth Network]
Im following the "create a contract" part in the tutorial of Pyth Network (https://docs.pyth.network/price-feeds/create-your-first-pyth-app/evm/part-1) and i have this error in the import. ...
0
votes
1
answer
68
views
Getting different binary for the same Solidity source code compiling with solc and Remix
I'm noticing a difference in the binary generated using the same solc compiler in local and with Remix.
Here's the source code:
pragma solidity 0.8.20;
contract HelloWorld {}
I compiled it in local ...
0
votes
1
answer
22
views
confusion in reference type in solidity
Suppose a struct is made in solidity and pushed the same struct to an array and a mapping (assume a random key), will the change in struct accessed through mapping will affect the change in the same ...
1
vote
0
answers
132
views
incompatible Solidity versions
I am trying to compile the code with multiple solidity versions e.g. =0.7.6, =0.8.15 etc in foundry with the configuration of auto_detect_solc but still getting this error
Here's my foundry.toml file
[...
0
votes
1
answer
81
views
Unable to compile
I am unable to compile any solidity program on remix ide. The compiler just keeps on buffering. Also the compiler version is disabled. I am unable to change it. How to solve this issue?
edit: I know ...
0
votes
1
answer
49
views
Reliably disassamble bytecode to opcodes across various evm versions
Is there a reliable way of disassembling bytecode into opcodes across different EVM versions, to make it agnostic to the EVM version used during compilation?
As the second best option - is there a ...
1
vote
1
answer
109
views
Run optimizer on opcodes
According to documentation, one of the steps of solidity compilation is the optimization on opcodes level, with the following set of rules.
How can I apply optimization directly on opcodes?
Details
...
1
vote
1
answer
52
views
Can't run Fe language on M2 MacOS Ventura: bad CPU type in executable
I tried installing Fe lang on M2 MacOS Ventura through Homebrew and by downloading the executable but both installation options ended up with me seeing the following error.
zsh: bad CPU type in ...
1
vote
1
answer
80
views
Call or assignment expected. Getting this error while upgrading solidity version
I am not aware of the Assembly code. I copied the ERC1820 registry contract from here. This is written in 0.5.3. When I tried to compile it with 0.8.0 it gave me this error :
I know it's because of ...
2
votes
1
answer
233
views
Determine compiler used to create a given bytecode
Context
The method that the solc compiler uses to set storage slots for a mapping is slightly different from how the Vyper compiler does so. In Vyper, it's keccak256(slotMapping, key), while in ...
2
votes
1
answer
78
views
Possible way to hack Solidity into executing a function directly from a struct as a method? (v0.8.20)
pragma solidity 0.8.20;
contract SolidityLimitTest {
mapping (address => Hack) private Hackable;
struct Hack {
uint amount;
function(uint) returns (uint) ten_x;
}
...
1
vote
1
answer
612
views
What solidity version is used when you give a range to the compiler e.g. pragma solidity >0.7.0 <0.9.0?
I am new to Solidity but have learned you can tell the compiler to use a range of Solidity versions e.g ^0.8.10 || > 0.7.0 < 0.9.0 when deploying smart contracts. My question is how does the ...
1
vote
1
answer
139
views
How to fix naming scheme and undeclared identifier errors?
I have a question about something that has been bugging me for quite some time now. I am a bit confused on naming schemes in solidity and how I should go about it. For example, the biggest thing for ...
9
votes
2
answers
5k
views
How to configure multiple solidity compiler versions in foundry?
I have a foundry project with files that have multiple solidity versions(0.7.x and 0.8.x). hardhat can relatively easily be configured to compile all files in the project as follows:
https://hardhat....
1
vote
1
answer
35
views
Hardhat compile code on file change (like remix)
Is there any way (preferably an official Hardhat plugin) to automatically compile the Smart Contracts' code on file change?
I'd want to have the same developer experience as when using Remix, or ...
1
vote
0
answers
16
views
Problem with veryfing contract
Hi I had my smart contract previously deployed and verified. However mythril warned me of floating pragma so I changed version explicitly to
pragma solidity 0.8.1;
I deployed it tot testnet using ...
1
vote
1
answer
40
views
can't find contract after compile successfully in remix: No Contract Compiled Yet
I compile this file in 0.4.8 successfully,
pragma solidity 0.4.8;
contract A {
function f(uint[] arr) constant external returns (uint len) {
assembly {
pop arr := len
}...
0
votes
1
answer
383
views
Compiler version error in Visual Studio Code
I started getting this error...
Source file requires different compiler version (current compiler is 0.7.3+commit.9bfce1f6.Emscripten.clang) - note that nightly builds are considered to be strictly ...
1
vote
1
answer
48
views
Compiler doesn't show a warning if empty function is not marked as pure
When compiling a function without marking its state mutability as pure, the compiler shows the following warning:
Warning: Function state mutability can be restricted to pure
For example:
contract ...
1
vote
1
answer
167
views
How to disable log that when compile?
I using script "yarn hardhat compile" alway log like image. I want to disable that.
1
vote
1
answer
128
views
developing a contract that distributes tokens
I am developing a contract that distributes tokens and has already implemented the main functionality. The contract accepts tokens from the owner and distributes them by 1KK to each address from the ...
1
vote
1
answer
202
views
Get bytecode offset(entrypoint) for the function in solidity contract
Suppose, I have the following source code:
contract Test {
function add(uint a, uint b) public returns(uint) {
return a + b;
}
}
And bytecode after compilation:
...
1
vote
1
answer
74
views
I do not understand how to fix the error: "req.add"
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";
contract RealEstateDataConsumer is ChainlinkClient {
uint256 ...
1
vote
1
answer
122
views
Compilation is successful but getting bytecode = "0x"
I am trying to compile this very simple smart contract but I am getting its bytecode = "0x":
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "@openzeppelin/...
2
votes
1
answer
525
views
Adding viaIR: true option Brownie
I'm getting
CompilerError: Stack too deep. Try compiling with `--via-ir` (cli) or the equivalent `viaIR: true` (standard JSON) while enabling the optimizer. Otherwise, try removing local variables. ...
1
vote
1
answer
183
views
Solc: Source file requires different compiler version
in my brownie project i have imported LinkTokenReceiver.sol contract which its pragma solidity is pragma solidity ^0.7.0;, which means that it requires compiler version equal or greater than 0.7.0, ...
1
vote
2
answers
872
views
Operator == not compatible with types string memory and string memory [duplicate]
function hasRole(uint256 tokenId, string memory role) public view returns (bool) {
string[] memory userRoles = tokenToRoles[tokenId];
uint256 userRolesLength = userRoles.length;
unchecked {...
1
vote
0
answers
129
views
How do I use a remapping with solidity compiler?
If my contract is importing for example "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol", how do I make it work?
I know import_remappings ...
0
votes
0
answers
26
views
Run manticore return 'Stack too deep when compiling inline assembly: Variable headStart is 1 slot(s) too deep inside the stack' error
I compile my project just fine but when I run manticore for my solidity file, it return Stack too deep error. I did some research but none of which I found work. Here is the config I'm setting:
...
0
votes
1
answer
324
views
Compiler version error
I am following a YouTube tutorial and I have the following contract (in Remix):
// SPDX-License-Identifier: MIT
pragma solidity >= 0.6.0 < 0.9.0;
import "@chainlink/contracts/src/v0.8/...
0
votes
4
answers
523
views
Contract is below size limit, but Hardhat says it's not?
When I run npx hardhat compile, Hardhat says one of my contracts is above the size limit.
But hardhat-contract-sizer says it's not.
See below:
Versions:
hardhat-contract-sizer version: ^2.5.1
...
5
votes
1
answer
3k
views
Is it possible to get the "creation bytecode" of an already deployed contract in Solidity?
I am looking to get some already deployed code working for myself.
With ethers.js I can get the bytecode in the following way
ethers.getCode("CONTRACT ADDRESS")
However, this is a ...
1
vote
1
answer
555
views
Problem with Solidity compiler
recently I started doing solidity tutorial. Everything was going okay on remix but when i switched to VS Code I got compiler error
I changed it to:
but it doesnt solve the question why 0.8.8 ...
2
votes
0
answers
28
views
Why No Constant Linking?
Similarly to library linking
https://docs.soliditylang.org/en/latest/using-the-compiler.html?highlight=compiler%20options#library-linking
why is there no constant linking for the compiler?
The only ...
1
vote
1
answer
43
views
Hi Everyone. Newbie here in solidity . I am getting the common erro "ParserError: Expected '(' but got identifier" with my code
I am getting the common error "ParserError: Expected '(' but got identifier" with my codeb.
I have tried to solve it using the existing solutions but seems my knowledge is limited, hence not ...
1
vote
0
answers
294
views
Trouble with Solidity Compiler Version when combining Aave and Openzeppelin in Foundry
I'm trying to follow this tutorial by Patrick Collins on Flashloans but in Foundry: https://www.youtube.com/watch?v=Aw7yvGFtOvI&t=328s
When in try to forge build I get the following error:
: src\...
2
votes
1
answer
315
views
How to enable multiple compiler versions in solc js?
I'm trying to compile contract A(located in A.sol) that has a dependency on contract B(located in B.sol) using solc-js,
where A has solidity version 0.8.0 and B version 0.7.6. The solcjs version that ...
1
vote
1
answer
89
views
Brownie doesnt compile but says it did
if i run brownie compile i get INFO: Could not find files for the given pattern(s). Brownie v1.19.0 - Python development framework for Ethereum
Project has been compiled. Build artifacts saved at C:\...
1
vote
1
answer
1k
views
Is it possible to compile to YUL?
So the solidity compiler compiles solidity first to YUL and then to machine code. Is it possible to compile it just to YUL and look it over?
It would be really helpful to learn how YUL works.
Thanks.
1
vote
1
answer
1k
views
I can not import openzeppelin, but get error 'File import callback not supported'
I get 'File import callback not supported' when I try to compile my simple solidity contract, that imports ERC721. Can anybody help?
Here is what I have already done:
I have installed openzeppelin in ...
1
vote
1
answer
872
views
TypeError: Invalid URL at new NodeError when typing the command npx hardhat run scripts/deployGoldenFoxNFT.js --network rinkeby
I run into this error when i try to run with Hardhat. Any idea of what it can be the solution? Thanks a lot in advance
0
votes
0
answers
38
views
CompilingError: Stack too deep, try removing local variables [duplicate]
I have a function that lists an NFT on a marketplace for sale. In the process, it keeps records by saving data in a struct inside nested maps represented by the NFT address and token ID. I am running ...
0
votes
1
answer
390
views
Variable declaration
I am new to solidity.Below is the snippet of solidity source code which I came across :-
pragma solidity ^0.5.1;
library SafeMath {
function sub(uint256 a, uint256 b) internal pure returns (...