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 ...
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 ...
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 ...
7
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 ...
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 ...
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 ...
6
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 ...
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 ...
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 ...
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 = ...
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:-"...
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: ....
4
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";...
4
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 ...
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 ...
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 ...
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
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 ...
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.
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 ...
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:...
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 ...
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 ...
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 ...
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 ...
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 ...
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;
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.
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 ...
3
votes
How smart contract versioning work with compiler?
Solidity is compiled down to EVM bytecode which is what is actually executed on the blockchain by miners.
Changes to the Solidity compiler affect the way that Solidity code is transformed into ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
compiler × 187solidity × 126
remix × 37
solc × 30
compilation × 22
contract-development × 16
error × 12
truffle × 10
hardhat × 10
evm × 8
bytecode × 8
import × 8
blockchain × 6
contract-deployment × 6
etherscan × 6
go-ethereum × 5
brownie × 5
optimization × 5
library × 4
truffle-compile × 4
web3js × 3
erc-20 × 3
ethereum-wallet-dapp × 3
struct × 3
openzeppelin × 3