Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
16 votes
Accepted

I've got an error while compiling.Use "constructor(...) { ... }" instead

It should be a warning not an error. Anyway using this syntax function Inbox(string initialMessage) public { message = initialMessage; } is deprecated in the newer version of Solidity. You have ...
qbsp's user avatar
  • 4,367
9 votes

Solved: How to change Solidity linter [solc] compiler version in Visual Studio Code?

Assuming your using VS code and have the official solidity extension maintained by Juan Blanco (found here). The extension is official in the sense that it is the only extension recommended by ...
Christoph Hansen's user avatar
8 votes
Accepted

VS code Expected identifier, got 'LParen'solc

I have had a similar error, then I realized the culprit in this case was in fact a malfunctioning VS Code plugin not Solidity nor truffle. Please check your plugins list in VS Code and see if one of ...
Marxx Theresias's user avatar
7 votes
Accepted

Do modifiers work in interfaces

SHORT ANSWER No, maybe with abstract contracts you can achieve something similar LONG ANSWER First of all to create an interface the keyword interface should be used (I used version 0.4.24 of ...
Briomkez's user avatar
  • 1,894
7 votes

Why is there a difference between a public array and a function which returns it?

Solidity creates getter functions automatically for public variables. As your array is public, a public getter function a generated for it automatically. The getter function is used to access the ...
Lauri Peltonen's user avatar
6 votes

Solved: How to change Solidity linter [solc] compiler version in Visual Studio Code?

[Solved] Thank you Juan Blanco for his advice. So the main issue is that the forked extension(Solidity Extended by beaugunderson) was highjacking this one(solidity by Juan Blanco) hence I had the old ...
Russo's user avatar
  • 1,784
6 votes

Solidity Compiler - Error: Identifier already declared

This is because the method and the property have the same name. Since solidity automatically creates a public getter function for every public variable in the contract, you don't need function ...
Hari GTT Psicolabis's user avatar
6 votes

Why is there a difference between a public array and a function which returns it?

This mechanism exists to avoid high gas costs when returning an entire array. Taken form Documentation, which is interesting to understand for me that it could be related to best practice to abstract ...
Nikhil Kuyya's user avatar
6 votes
Accepted

How to configure multiple solidity compiler versions in foundry?

So it doesn't seem like Foundry allows you to manually configure multiple solc versions however Foundry does automatically detect and configure the required compilers for your project, you'll need to ...
MShakeG's user avatar
  • 1,693
5 votes

Solidity function that accepts mapping as input

You can't pass the whole mapping. You could pass a struct internally. Ideally, you would enumerate the fields you really need to pass so you can create an interface that works with other contracts and ...
Rob Hitchens's user avatar
  • 55.3k
5 votes

unable to verify the contract on etherscan.io. How to resolve this issue?

Try changing your pragmastatement to pragma solidity 0.4.16 (without the ^). There may be issues due to the pragma... statement, since with the ^, you allow version 0.4.16 or anything newer ...
gisdev_p's user avatar
  • 1,801
5 votes
Accepted

Solidity Compiler - Error: Identifier already declared

@Hari GTT Psicolabis' answer is right, but that means that you have to specify the ownerInfo field as public to get the benefit of a public getter. string public ownerInfo = "Contract Owner name XYZ";...
qbsp's user avatar
  • 4,367
5 votes
Accepted

How to deploy Library contract separate from the main contract and link it

It seems that Remix does this automatically. Library code: pragma solidity ^0.5.10; library Foo { struct F { uint256 x; } function foo (F storage f) external { f.x = ...
Mikhail Vladimirov's user avatar
4 votes

Solved: How to change Solidity linter [solc] compiler version in Visual Studio Code?

Go to node_modules -> solc -> package.json -> version of your compiler can be found at the bottom. Never edit the package.json file To fix the problem -Copy the version number at the bottom ex:-"...
brooks's user avatar
  • 41
4 votes
Accepted

Solved: How to change Solidity linter [solc] compiler version in Visual Studio Code?

If you still have a problem with the version in VS Code, this worked for me: Install specific solc version locally or globally: npm i -g solc or npm i solc. Add this setting in local VSCode settings: ....
drab's user avatar
  • 245
4 votes

Error While Compiling In Remix During Tutorial

You need to choose the right compiler version. On the right sidebar you can see your current compiler version. The compiler version must match the number used in the pragma solidity! Expand the ...
cqx's user avatar
  • 3,462
4 votes

Trying to compile running: 'node compile.js', but get error: "assert.js:350 throw err;" [Udemy 'Complete Developers Guide' Course]

That course is outdated, solidity version 0.6.6 is released and you better update your code to that version. if you are not a good programmer you better refund that course, cause you will encounter ...
Masoud jt's user avatar
  • 761
4 votes
Accepted

Error HH8: There's one or more errors in your config file, Expected a value of type HttpNetworkConfig

had to run source .env to enable the .env in Ubuntu 20.04 LTS
GoGetterMeme's user avatar
4 votes

Error HH8: There's one or more errors in your config file, Expected a value of type HttpNetworkConfig

You're getting this error because hardhat needs to be able to verify that the URL and accounts you're using for a network are valid for that network. In your specific case, your Private key isn't ...
Patrick Collins's user avatar
4 votes
Accepted

Is it possible to compile to YUL?

Yep, you can use the compiler option solc --ir a.sol to see the Yul output.
Leonardo Alt's user avatar
3 votes

unable to verify the contract on etherscan.io. How to resolve this issue?

I agree with @gisdev_p, to a point. The carrot ^ symbol creates just the sort of ambiguity we don't want at this stage. Your contract is already deployed and, based on the source code, it may have ...
Rob Hitchens's user avatar
  • 55.3k
3 votes

I've got an error while compiling.Use "constructor(...) { ... }" instead

Just use constructor() should be good. constructor(string initialMessage) public { message = initialMessage; } If you use function constructor(...)... , I think you'll get the following warning:...
alant's user avatar
  • 31
3 votes

Solidity Help - Undeclared Identifier - onlyOwner WithdrawEther

Yes, you must define the modifier within your contract. Assuming by owner you mean the contract creator, you must define a variable in your contract. address private owner; and in the constructor ...
AnAllergyToAnalogy's user avatar
3 votes
Accepted

totalSupply() Solidity signature causing conflict error

I think your function return argument should be renamed - this is what the compiler is really complaining about: function totalSupply() constant returns (uint256 something) { It's actually optional ...
benjaminion's user avatar
  • 9,287
3 votes
Accepted

Remix Warning - No visibility specified, Violate Checks-Effects-Interaction pattern, Function state mutability can be restricted to pure - Can ignore?

In general You can let the code run, ignoring the compiler warnings, but it's always good not to do so. Most of the time, compiler warnings are warning you about something that may cause a bug in your ...
Achala Dissanayake's user avatar
3 votes

Solidity optimizer vs LLVM optimizer

Regardless of how a contract is executed, it's the EVM's accounting that matters. The protocol doesn't know if you're executing a contract on x86, a ARM7, a 6502, or pen and paper. What it does know ...
Matthew Schmidt's user avatar
3 votes

Solved: How to change Solidity linter [solc] compiler version in Visual Studio Code?

I tried sooooooooo many things to fix this in Nov 2021 and this is finally what did it for me....btw, many thanks to Russo for his insight about Blanco's extension vs Beaugunderson's! While his quick ...
OrangeDeuce's user avatar
3 votes

ParseError in solidity code

pragma keyword in solidity has a ; at the end of the line. you've forgotten it. It should be like, pragma solidity ^0.4.6;
shaish's user avatar
  • 335
3 votes

ParseError in solidity code

As other answers also have pointed, You just have missed the ; at the end of the very first line.
ETHER's user avatar
  • 180
3 votes

How do I find out what compiler version was used to deploy with MyEtherWallet

In order to deploy contract on MyEtherWallet, you need the bytecode. The bytecode contains the solidity pragma version in the metadata which is converted into the object parameter in the bytecode you ...
ReyHaynes's user avatar
  • 1,515

Only top scored, non community-wiki answers of a minimum length are eligible