16

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 to use constructor instead of the contract name constructor(string initialMessage) public { message = initialMessage; } this will compile without warnings


7

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 your plugins is called "Solidity Extended" by beaugunderson and disable it.


5

[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 version of the compiler 0.4.17 but not the latest version 0.4.23. Set it by opening your VS Code setting at /home/userXYZ/.config/Code/User/settings.json in ...


5

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 that does not break functionality (up to, but not including, version 0.5.0) (from solidity.readthedocs.io). This may lead to different byte code, resulting in a ...


5

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 solidity and the solidity documentation. I played a little bit with your code and when you try to create a function in an interface with a modifier, like this: ...


4

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 clients. Your example above, seems to pass a single member of the source mapping. I would interpret that roughly like this: pragma solidity ^0.4.6; ...


4

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 ownerInfo() public view returns (string)


4

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 = 123456789; } } Main contract code: pragma solidity ^0.5.10; import './Foo.sol'; contract Bar { Foo.F public f; function bar () public { ...


4

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 dropdown and choose 0.5.12 nightly. You should probably downgrade to a full commit version like 0.5.11 commit. I hope this helps!


4

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 many problems later on, you will see some errors using meta mask and Web3. that course teachs you a lot, so i really recommend you to keep learning that course ...


3

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: Warning: This function is named "constructor" but is not the constructor of the contract. If you intend this to be a constructor, use "constructor(...) ...


3

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 make sure you set it to the contract creator owner = msg.sender; then to create the modifier, this would probably do the trick. modifier onlyOwner(){ ...


3

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 been compiled with any Solidity compiler >= 0.4.16. Now, you need to discover the version of the compiler that was actually used to make the bytecode that's on ...


3

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 to name the return argument here; you can just put its type: function totalSupply() constant returns (uint) { [For future reference, it would be easier to ...


3

In general you can let a code run ignoring the compiler warnings. But it's always good not to do so. Most the time compiler warnings are warning you about something that may cause a bug in your code. Compared to compiler errors, the difference is your code is syntactically correct, hence can be compiled, but can lead to problems, specially when someone try ...


3

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: .vscode/settings.json { "solidity.compileUsingRemoteVersion": "v0.7.4+commit.3f05b770", "solidity.enableLocalNodeCompiler":...


3

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 ethereum.org. The extension provides a very easy way of toggling compilers: In any *.sol file, right click and press "change workspace compiler version (Remote)&...


3

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

As other answers also have pointed, You just have missed the ; at the end of the very first line.


3

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 get itself. It will compile using whatever is set as the pragma. As for verification. You will need to know what pragma was set in the solidity code itself. ...


3

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 bytecode, but only new releases of the mainnet (e.g. Metropolis) which introduce new opcodes (but don't remove old opcodes generally) would impact the way that ...


3

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, Solidity also tries its best to be backwards-compatible. This means that the next version of Solidity will also run code which was created with a previous version of ...


3

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 implemented in the compiler. It appears you are right about a breaking change, given that it compiles without complaint under 0.4.25. Possibly another kind soul will ...


3

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 errors in the latter, which you have not received in the former. If you don't want to update your contracts to solc 0.5.x, but still be able to compile them with ...


3

Generally, you should always only use the latest released version available, no prior version whatsoever. As far as I know, there has not been major exploits caused by a Solidity compiler error ever. Thus, the only non-subjective historic data point we have is that "any Solidity compiler version has always been safe." Personally I prefer the major ...


2

Here is the discussion where it was decided to deprecate eth_compile. To summarize, it's not really geth's responsibility to compile code. Or parity's. Or any other node's. Continuing to support in-node compilation would force nodes to host compilers written in other languages. In addition, the interface to compile was poor, as there are many more ...


2

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 is how much each step in the EVM costs, which is the same regardless. Solidity's optimization, by optimizing the EVM-level code, makes contracts cheaper in gas. ...


2

In this case, the "strings" library only has functions with internal visibility therefore all the functions from the library are copied to the Contract contract therefore "strings" library was never deployed and so there isn't any placeholder to add the "strings" library address in the bytecode of Contract. To know why it was copied read this http://...


2

Even, I had the same error. From the Doc When using the Command Prompt on Windows, the default configuration file name can cause a conflict with the truffle executable.If this is the case, we recommend using Windows PowerShell or Git BASH as these shells do not have this conflict. Alternatively, you can rename the configuration file to truffle-config.js ...


2

Option 1 A typical fix and implementation of an ERC20 token is to rename the public variable to totalSupply (no underscore) and remove the function totalSupply as it would then be auto-generated by Solidity. Explanation of shadowing error message function totalSupply() constant returns (uint256 totalSupply) indicates to the compiler that the return value ...


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