Questions tagged [compilation]
For questions regarding contracts compilation.
192 questions
2
votes
1
answer
41
views
Please help me how to calculate the correct function name in bytes 4
Good day, dear forum members. I apologize for my possibly stupid question. I can't figure out the problem. There is a function in my smart contract
///----------------
struct parmsData{
address ...
1
vote
1
answer
142
views
How to test contract with old solidity version in Foundry?
I need to test contract that uses version ^0.5.16 in Foundry. I get this error ->
ERROR
ERROR foundry_compilers::resolver: failed to resolve versions
Error:
Found incompatible Solidity versions:
...
0
votes
2
answers
39
views
Contract verify [duplicate]
I get such error of compilation in Optimism Sepolia testnet network.The contract succesfully compiles using hardhat with needed configuration.What should I do to get verified the contract ?
0
votes
0
answers
139
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
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
28
views
The Solidity version pragma statement in these files doesn't match any of the configured compilers in your config. hardhat-deployment
in trying to compile a contract i keep getting this error:
The Solidity version pragma statement in these files doesn't match any of the configured compilers in your config. Change the pragma or ...
0
votes
1
answer
46
views
Facing Issue with test files in Hardhat
I am trying to build a Dapp with hardhat installed in my vs Code my smart contracts parts are over and it gets compiled but I am facing a problem with test files I don't know why they are not getting ...
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 ...
4
votes
2
answers
2k
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 ...
2
votes
2
answers
1k
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 ...
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 ...
0
votes
2
answers
100
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/...
0
votes
1
answer
115
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(...
2
votes
0
answers
254
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";...
2
votes
1
answer
81
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 ...
1
vote
1
answer
661
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 ...
1
vote
1
answer
123
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/...
1
vote
1
answer
338
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?
1
vote
1
answer
221
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,...
0
votes
1
answer
194
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 ...
6
votes
3
answers
2k
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.
...
1
vote
0
answers
80
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 ...
0
votes
1
answer
448
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 ...
0
votes
1
answer
289
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 "...
0
votes
2
answers
278
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 ...
1
vote
1
answer
112
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 ...
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
...
1
vote
1
answer
536
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 ...
0
votes
1
answer
8
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(...
1
vote
0
answers
218
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. ...
3
votes
1
answer
596
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 =&...
0
votes
1
answer
209
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 ...
2
votes
1
answer
1k
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 ...
0
votes
1
answer
522
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 ...
0
votes
2
answers
2k
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 @...
1
vote
1
answer
39
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 ...
0
votes
2
answers
3k
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 ...
0
votes
1
answer
26
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.
1
vote
1
answer
57
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) {
...
2
votes
0
answers
147
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 ...
3
votes
1
answer
47
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 ...
1
vote
0
answers
31
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 ...
0
votes
1
answer
248
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-...
1
vote
3
answers
2k
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 ...
0
votes
1
answer
35
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 ...
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 = ...
0
votes
2
answers
478
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;
...
2
votes
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 ...