Questions tagged [compilation]

For questions regarding contracts compilation.

Filter by
Sorted by
Tagged with
1 vote
1 answer
50 views

How to Resolve Compiler Version Conflicts in Foundry Test Contracts?

I'm working on a Foundry project, and I'm encountering issues with compiler versions when trying to deploy Uniswap V3 core and periphery contracts in a test contract(i.e. UniswapTest shown below). The ...
MShakeG's user avatar
  • 1,054
1 vote
2 answers
71 views

How to compile contracts independently with Hardhat?

I'm facing the following error, when compiling my contracts in Hardhat: Warning: Contract code size exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on ...
Alexander Herranz's user avatar
5 votes
1 answer
283 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....
MShakeG's user avatar
  • 1,054
1 vote
1 answer
18 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 ...
Alexander Herranz's user avatar
0 votes
2 answers
17 views

Compilation Warning: Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting name of variable

I am getting a compilation error Warning: Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable. --> contracts/...
sounxk's user avatar
  • 1
0 votes
1 answer
25 views

"Warning: Unreachable code" in solidity when overriding a function to make it fail and that is used elsewhere

I have the following code sample pragma solidity ^0.8.13; error MyError(); abstract contract A { function f1() public pure virtual returns(bool); function f2() public pure virtual returns(...
tazous's user avatar
  • 1
2 votes
0 answers
91 views

Compilation error in deploying a contract on zksync, using deploy zksync

I'm trying to compile the code but I keep getting an error. Here is the hardhat.config.ts code: import "@matterlabs/hardhat-zksync-deploy"; import "@matterlabs/hardhat-zksync-solc";...
Mitchell Nwafor's user avatar
2 votes
1 answer
58 views

error when working with arrays: DeclarationError: Undeclared identifier

**I am developing a smart contract distributor in the solidity language that will accept BEP20 tokens from the owner with the special contract address: 0x0000000000000000000000000000. the owner of the ...
Lll Cilician's user avatar
1 vote
1 answer
250 views

Compiler error: Stack too deep

I am getting this error when trying to deploy my smart contract using zkSync but on a different chain (Polygon Mumbai): CompilerError: Stack too deep. Try compiling with `--via-ir` (cli) or the ...
Falcon Stakepool's user avatar
1 vote
1 answer
66 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/...
Falcon Stakepool's user avatar
1 vote
1 answer
123 views

How to compile with --bin option in solcjs?

I want to compile using --bin option because I want to get to see the bytecode of the compilation. Using solc I know it is something like this: solc --bin How can I achieve this using solcjs?
Falcon Stakepool's user avatar
1 vote
1 answer
83 views

Warning: This declaration shadows an existing declaration with a Struct

I 'm looking for a way to clean my compile warning, i have a Warning: This declaration shadows an existing declaration. on the function below. The Transaction in the return is a Struct compose with id,...
Hutgin's user avatar
  • 13
0 votes
1 answer
46 views

Is there an api that compiles solidity contracts?

I have a static webpage and it should remain static. In this website a user generates solidity files. I would like to compile them by sending the uncompiled solidity via an api to a compiler and then ...
Marlo's user avatar
  • 305
0 votes
0 answers
25 views

Is there anyway to set a smart contract into Debug mode so only certain events are emitted?

I'd like to be able to set my Solidity smart contract into runtime DEBUG mode so that only certain events are defined and emitted in that mode, similar to a preprocessor directive. For example, I ...
reselbob's user avatar
  • 131
5 votes
3 answers
1k views

Where are the smart contract constants stored?

I want to double-check something. I had been writing upgradable smart contact that uses a lot of constants. As far as I can see, smart contracts aren't storing constant variables in their storage. ...
Sky's user avatar
  • 2,144
1 vote
0 answers
47 views

How to import interface from lower level of Solidity?

I'm extending a large codebase with another contract and I need to import an interface. My new contract uses 0.8.9 but the rest of the codebase is in 0.6.12. I'm using Hardhat multi compile to do ...
doylio's user avatar
  • 115
0 votes
1 answer
262 views

How to unpack Tuple to Struct in Solidity?

I saw a similar question here which I tried to use in my example but I still get confused from the code. Can you tell me what is the difference between those two examples? contract First { struct ...
Dakata's user avatar
  • 195
0 votes
1 answer
157 views

help with DeclarationError: Undeclared identifier

thats my code: // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import "https://github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol"; import "...
Tomasz KoZa Kozanecki's user avatar
0 votes
2 answers
151 views

TypeError: Contract should be marked as abstract

I'm getting this error: TypeError: Contract "BaseRegistrarImplementation" should be marked as abstract. --> Contracts/BaseRegistrarImplementation.sol:7:1: | 7 | contract ...
gerbil's user avatar
  • 225
1 vote
1 answer
74 views

Need help on solidity compiling

I am not getting expected files after: yarn add solc. But the command works with some warning. yarn add v1.22.19 warning package.json: No license field warning package-lock.json found. Your project ...
Hacek 's user avatar
  • 645
0 votes
3 answers
300 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 ...
António Gonçalves's user avatar
0 votes
1 answer
300 views

The file {location} is treated as local but is inside a node_modules directory | Error HH1006

I am trying to compile my contracts which are present in ./contracts directory (normal hardhat setup), I am not using deploy script to compile, just trying to compile with yarn hardhat compile, it is ...
Priyanshu Jha's user avatar
0 votes
1 answer
7 views

Large Size Disparity Between Contract and Its Library Wrapper

I have this contract called Pool.sol, and an external library for deploying it: pragma solidity ^0.8.0; // Contracts import "../Pool.sol"; library DeployerOfPools { function deployPool(...
mermeladeK's user avatar
1 vote
0 answers
149 views

Find metadata URL from EVM bytecode

Currently, I am looking for a way to extract the metadata.json file URL from the ethereum bytecode. I have referred to this doc and figured out that metadata mapping is stored CBOR-encoded manner. ...
Sajitha Liyanage's user avatar
2 votes
1 answer
285 views

Different bytecode when compiling from both solc-js and Remix IDE

Currently, I'm trying to get the bytecode from this contract code for example: // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract GetSet { uint256 private total; mapping(address =&...
Linh Nguyen's user avatar
0 votes
1 answer
181 views

DeclarationError: Undeclared identifier on mapping

I recently upgraded from solidity v0.4.25 to 0.8.6. I noticed that expectedly required some code modifications, all of which we easy to debug resulting in a changed contract code. The final error on ...
simon's user avatar
  • 1
2 votes
1 answer
985 views

Hardhat coverage tests failure - Stack too deep

I got my smart contracts ready over Hardhat and once I'm running hh test all the tests are passing successfully but while running hh coverage I'm getting the below error. Any idea why the regular ...
forhas's user avatar
  • 715
0 votes
1 answer
388 views

Brownie unable to compile contracts on Apple M1 Mac

I recently got an M1 mac and I'm trying to compile my brownie project's contracts which compiled fine on my previous machine. I've installed Brownie v1.18.2 and when attempting to run brownie compile ...
MShakeG's user avatar
  • 1,054
0 votes
2 answers
804 views

hardhat beginner "Nothing to compile" error

following hardhat beginner tutorial. This is how I did it, first run "npx hardhat " command and created basic sample project. After that run following command npm install --save-dev @...
yasurid's user avatar
1 vote
1 answer
35 views

Any document for the layout of the smart contract binary?

I'm trying to write a disassembler to disassemble the binary code of smart contract. There are trailing bytes at the end, which causes disassemble problem. For example, the last few lines of this ...
aj3423's user avatar
  • 251
0 votes
2 answers
2k views

Hardhat compile/deploy error

I'm following this tutorial for creating and deploying a smart contract (https://docs.alchemy.com/alchemy/tutorials/how-to-create-an-nft), but instead of deploying it on the ropstein test network I ...
filippo's user avatar
0 votes
1 answer
23 views

What am I doing wrong? cannot compile

Hi for some reason i keep getting this error, while trying to compile, im using a code I found in forums, but i seem not to be able to understand why it doesnt compile, what am I missing?. Thanks.
Klord's user avatar
  • 1
1 vote
1 answer
43 views

Converting from Version 4 to Version 5: Problem with Compilation

I got the following Solidity code from: https://www.zupzup.org/smart-contract-interaction/ pragma solidity ^0.5.6; contract Caller { function someAction(address addr) returns(uint) { ...
zak100's user avatar
  • 1,406
2 votes
0 answers
135 views

Solidity array has no SLOAD optimization

Suppose a function writes to storage, and then reads from the same storage location before it has been overwritten. In solidity 0.8.11 in these cases the SLOAD gets optimized away (there is 1 SSTORE ...
Jesbus's user avatar
  • 10.2k
2 votes
1 answer
41 views

Is there an EVM compiler that supports coroutines? (e.g. generator functions)

With coroutine I mean a subroutine that can be paused and resumed from another subroutine; preserving its internal state across pauses and resumes. For example, a feature similar to: Javascript's ...
Jesbus's user avatar
  • 10.2k
1 vote
0 answers
30 views

What pragma version to use? [duplicate]

When I start with a project and have to decide which pragma I want to use, what are the main things I have to consider? For simplicity, lets first assume I start a project from scratch, without ...
PhilippB's user avatar
  • 151
0 votes
1 answer
245 views

Solidity safeTransferFrom compile error

I am getting the following Solidity error in my contract and I'm not sure what the problem is: Expected identifier but got '(' Here is my contract stripped down to the problem. // SPDX-License-...
M2 Learner's user avatar
1 vote
3 answers
1k views

Problem compiling subgraph with graph-ts new version

I'm getting this error: ERROR TS2322: Type '~lib/@graphprotocol/graph-ts/common/value/Value | null' is not assignable to type '~lib/@graphprotocol/graph-ts/common/value/Value'. I know it is for this ...
Falcon Stakepool's user avatar
0 votes
1 answer
27 views

Does solidity language optimizes code or is it dependent on Compiler for gas/machine cycles?

Take the following case uint256 x = z * 100/1000;//1st statement uint256 y = z * 1/10;// 2nd statement Now in terms of Gas and Machinecyles as well as will solidity spend more computational ...
Uint256's user avatar
2 votes
2 answers
1k views

Can`t fix: AssertionError [ERR_ASSERTION]: Invalid callback object specified

I´m doing my first smart contract, these errors are probably no npm but versioning problems. Though intensive research I could not find a proper way to fix it. Thank you for your help! const assert = ...
D. J.K.'s user avatar
  • 21
0 votes
2 answers
415 views

DeclarationError: Undeclared identifier. Did you mean "balances" or "balanceOf"?

I have gone through the similar questions and weirdly, none of them seem to solve this problem. I am creating a simple token contract contract Token { mapping(address => uint) public balances; ...
Pe Dro's user avatar
  • 127
1 vote
1 answer
2k views

How to override when inherited contracts have same method name but slightly different signatures?

I'm inheriting 2 abstract contracts having the same function name but slightly different signature. These are the 2 base contracts: abstract contract Base1 { function foo() internal view virtual ...
xenon's user avatar
  • 437
0 votes
0 answers
25 views

Stack too deep, try removing local variables when using remix [duplicate]

while compiling in remix i get the above error: CompilerError: Stack too deep, try removing local variables. --> work/youkie.sol:1015:80: | 1015 | (uint256 rAmount, uint256 ...
stofu's user avatar
  • 91
0 votes
2 answers
688 views

How to generate Natspec docs using version 0.6.x of the Solidity compiler

I'm trying to run solc --userdoc --devdoc myContract.sol to generate natspec. However, the compiler complains that the contract has a different pragma-version. In fact the contract pragma is at ^0.6....
Marlo's user avatar
  • 305
0 votes
1 answer
303 views

Truffle Compile Fails with Error " Expected pragma, import directive or contract/interface/library/struct/enum/constant/function definition"

When running truffle compile in the root directory of my project I get the following error: ParserError: Expected pragma, import directive or contract/interface/library/struct/enum/constant/function ...
Conscious Nova's user avatar
0 votes
2 answers
732 views

Is it possible to import smart contracts with different compiler versions?

I'm using hardhat to compile my contracts. I am aware that hardhat is good at compiling contracts with different pragma versions, however, the contracts can't compile because they're importing ...
Kaleb Amarante's user avatar
2 votes
0 answers
1k views

Stack too deep when compiling inline assembly: Variable headStart is 1 slot(s) too deep inside the stack [duplicate]

I tried to add another parameter to my constructor and I get the following error when compiling with hardtest to test. If I remove one parameter it compiles again, so clearly it's related to the ...
Tom's user avatar
  • 123
0 votes
1 answer
1k views

JSON-RPC Error - Exection Reverted (-32000) / Empty ABI

I am attempting to deploy a BEP20 contract on BSC testnet via Remix. I am using compiler v6.12 and am successfully compiling my Solidity. However, when I deploy the contract, I am receiving the ...
Nomad's user avatar
  • 1
0 votes
0 answers
97 views

Error while compiling with nodejs

Im trying to set up the compiler for my project. sol: pragma solidity ^0.4.25; contract Inbox { string public message; function Inbox(string initialMessage) public{ message = ...
Maruko's user avatar
  • 51
0 votes
0 answers
18 views

How to locate the source codes by PC for smart contracts

Similar to the debugger module in remix https://remix.ethereum.org/, it can locate the source codes of each PC. Now, I want a tool that can locate the source codes given a PC for large-scale smart ...
Jocelyn's user avatar
  • 71