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 ...
7
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
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 ...
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
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 ...
5
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 ...
4
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 ...
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
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 ...
4
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
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 ...
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
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
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
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
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";...
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 ...
3
votes
How smart contract versioning work with compiler?
Deprecating a keyword does not mean that it can't be used. It simply means that it may be removed in a future version and it should not be used.
As is the case with all programming languages, ...
3
votes
Nested structs that are part of a mapping broken in Solidity 0.5.0?
You can solve it by removing the word public from the mapping.
The storage structure itself is acceptable and can be expected to work. However, the "free" getter for such a structure is not ...
3
votes
Accepted
Unable to run truffle compile
Truffle 4.1.14 relies on solc 0.4.24.
Truffle 5.0.1 relies on solc 0.5.0.
Between these two versions of solc there are breaking changes, meaning that you're very much likely to get compilation ...
3
votes
Accepted
Understanding the ".send" warning message
transfer reverts in the case that the call to the address given fails. send on the other hand doesn't, and instead returns true/false for a success/failure. If you don't do anything with that failure ...
3
votes
Accepted
Function declared as view, but this expression (potentially) modifies the state requires payable
Let's go over the compilation error that you're getting:
Function declared as view
That one is clearly true, since this is how you've declared the function:
function getHighestBidID() public ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
compiler × 151solidity × 104
remix × 32
solc × 24
compilation × 19
contract-development × 16
error × 11
truffle × 9
etherscan × 7
import × 7
evm × 6
go-ethereum × 5
blockchain × 5
contract-deployment × 5
brownie × 5
bytecode × 5
web3js × 4
hardhat × 4
library × 4
truffle-compile × 4
optimization × 4
erc-20 × 3
ethereum-wallet-dapp × 3
assembly × 3
contract-verification × 3