14

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


6

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.


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

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 ...


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!


3

[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.


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

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

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

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)


3

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: ...


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

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 ...


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 ...


2

You're missing a ; after declaring what version of solidity you're using. Use this pragma solidity ^0.4.19; in the first line instead. Consider using remix IDE in the future to help solve these small errors. You can also use view on the getName function, this can be used as the function only reads data and will not cost Ether to run. Here is the updated ...


2

function ConstructorFunction(uint _inputOne, uint _inputTwo) public returns (bool success) { callAnotherFunction('string'); return true; } With summarized explanation: // describe the function i/o and visibility // input - types and optional variable name assigments function ConstructorFunction(uint _inputOne, uint _inputTwo) // visibility ...


2

Check your adblock. I think that's the issue. I also had the same problem today in Chrome, but when I tried it in Firefox (where I don't use adblocks) it works.


2

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:-"version": "0.5.1" -go to your contract and paste on pragma. ex:- pragma solidity ^0.5.1; This should fix your issue.


2

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(){ ...


2

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":...


2

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;


2

You have missed the semicolon in the first line. It should be, pragma solidity ^0.4.6; I tried the code in Remix IDE and it compiles after the above correction.


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