Hot answers tagged

29 votes
Accepted

Error while compiling: Stack too deep

You're hitting a StackTooDeepException. The Solidity code doesn't appear to be consistent in the number of variables it sees as a problem, but you've got a limit of around 16 or 17. (Though clearly ...
user avatar
28 votes
Accepted

How do I install solc on Mac Osx? Error encountered "Error: No formulae found in taps."

From Solidity - Binary Packages: brew update brew upgrade brew tap ethereum/ethereum brew install solidity
user avatar
25 votes
Accepted

having a problem with solc-x version "solc 0.6.0 has not been installed"

I'm working through this same course check this out and it will show you how to fix this error here: https://github.com/smartcontractkit/full-blockchain-solidity-course-py/blob/main/chronological-...
user avatar
  • 266
22 votes

Compiler solc expected a state variable declaration

instead of using function() public payable {} Use fallback() external payable {} with latest solidity we dont use function keyword. https://solidity.readthedocs.io/en/v0.7.4/contracts.html#fallback-...
user avatar
21 votes
Accepted

Internal compiler error: Accessors for mapping with dynamically-sized keys not yet implemented

The thing was that my mapping was public, and there are no public accessors implemented for it yet. The solution is just to not declare the mapping as public.
user avatar
20 votes
Accepted

What's the difference between solc's bin bytecode versus bin runtime?

TL;DR bin-runtime is the code that is actually placed on the blockchain. The regular bin output is the code placed on the blockchain plus the code needed to get this code placed on the blockchain, ...
user avatar
19 votes

What is the cause of the error: Expected import directive or contract definition

Not true in the OP's case, but a cause of this problem is missing a semi-colon from the first line specifiying compiler version, e.g.: pragma solidity ^0.4.6;
user avatar
  • 7,924
16 votes

Solc --version: command not found

If you have installed through npm install -g solc Here's how you use it. solcjs --version
user avatar
  • 261
15 votes
Accepted

How do I find out the solidity compiler version I am using?

Mist / Ethereum Wallet now has a built-in compiler that is not very well documented beyond screenshots in the tutorials in order to create, compile, and deploy contracts. However, the version of Mist'...
user avatar
  • 15.3k
15 votes
Accepted

How to include solidity file into another?

I deployed a contract using web3js sometime back and I faced the similar problem, I fixed it by defining all dependent contract in an input object and then compiled it. You can take a look at this ...
user avatar
  • 3,322
14 votes

Solidity Error: Struct containing a (nested) mapping cannot be constructed

from 0.7.0 do like below: struct Request{ string description; uint value; address recipient; bool complete; uint approvalsCount; ...
user avatar
12 votes
Accepted

Etherscan: How can I verify a contract with multiple imports deployed with Truffle?

Currently etherscan does not support verification of multifile contracts. But there is discussion on etherscan's reddit about this issue. Concatenating files into one worked some time ago, but since ...
user avatar
  • 2,896
11 votes
Accepted

What is the cryptic part at the end of a solidity contract bytecode?

This is the Swarm hash. It is documented at https://solidity.readthedocs.io/en/develop/metadata.html Extract follows Contract Metadata The Solidity compiler automatically generates a JSON file, the ...
user avatar
  • 8,722
11 votes
Accepted

Solidity Error: Struct containing a (nested) mapping cannot be constructed

The problem is in the construction, i.e., Request({ description: description }) Therefore changing the location of newRequest from memory to storage will not help. If you really want to make it work, ...
user avatar
  • 316
9 votes
Accepted

All cases when Solidity compiles to invalid jump destination

Jumps to invalid jump destinations are generated only for (explicit or implicit) exceptions. An explicit exception is when you use the keyword throw. Implicit exceptions happen for runtime errors: ...
user avatar
  • 3,212
8 votes

"[Errno 2] No such file or directory: 'solc' " Using py-solc and solidity

The problem is solc is not installed on your pc. get it installed through sudo add-apt-repository ppa:ethereum/ethereum sudo apt-get update sudo apt-get install solc or you can go here
user avatar
8 votes
Accepted

Tracing back tripped require() to a source code line

Something you are looking for is here How to map EVM trace to contract source?. As for me for development purposes I use requireDebugModifier from code below, for production I change ...
user avatar
8 votes
Accepted

Do intermediate memory variables cost gas?

Here is more information about storing data in solidity https://solidity.readthedocs.io/en/latest/introduction-to-smart-contracts.html#storage-memory-and-the-stack Those variables, which you defined,...
user avatar
  • 1,712
7 votes
Accepted

Is the Solidity compiler deterministic?

At least it should be deterministic. We eliminated some sources of non-determinism in May, so it now should always produce the same result on the same input, even on different platforms. If that is ...
user avatar
  • 3,212
7 votes
Accepted

Is it dangerous to name my function ccccvKygDv?

I believe this is just a bit mask. The code loads the call data, shifts it to the right, and then does a bitwise AND with 0xFFFFFFFF to get the (now) bottom four bytes (the function selector). Then ...
user avatar
  • 26.7k
7 votes

Error when calling the selfdistruct method in solidity

As of Solidity 0.5.0, there are two different address types in solidity: address and address payable. You can only transfer funds to an address payable. Therefore, your problem will be fixed by ...
user avatar
  • 9,157
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 ...
user avatar
7 votes
Accepted

Install Old Solc Compiler Versions

I maintain a Python library called py-solc-x that allows you to install and use multiple versions of solc at the same time. It supports versions >=0.4.11. I've included some code examples below to ...
user avatar
7 votes
Accepted

solc-v0.6.0: TypeError: Operator - not compatible with types tuple() and int_const 1

Yes, list.push will not return the length of it anymore. From https://solidity.readthedocs.io/en/v0.6.0/060-breaking-changes.html#how-to-update-your-code: Change uint length = array.push(value) to ...
user avatar
6 votes

All cases when Solidity compiles to invalid jump destination

Array Out Of Bounds contract InvalidJump { uint[5] data; function invalidJump1() { uint i = 6000; data[i] = 1; } } And the message is from debug.traceTransaction(...) is: ...
user avatar
6 votes
Accepted

How to get a contract verified on etherscan?

Depending on your Ethereum Wallet version, the compiler version is different as well. For the latest ones, you should select this version on Etherscan : v0.2.1-2016-01-30
user avatar
  • 178
6 votes
Accepted

Infinite gas estimation from solc for simple function

There are many cases when the gas estimator reports infinite gas. However, it doesn't necessarily mean that there is an infinite loop in your code or that your code is incorrect but just the estimator ...
user avatar
  • 10.3k
6 votes

structs, mappings, & enums. How to make them work together?

This is a really abbreviated snippet to give you some ideas. You may be after a more feature-complete relational model like is described here: https://medium.com/@robhitchens/enforcing-referential-...
user avatar
  • 51.9k
6 votes
Accepted

Truffle and Remix compiles differently

Alright, I've found the answer after digging a little bit more into remix's compilation option. It seems that right now, the default setting on remix is: evmVersion: "petersburg" Whereas on Truffle ...
user avatar
6 votes

Is the SafeMath library obsolete in solidity 0.8.0?

The Solidity v0.8.0 Breaking Changes Docs says: Checks for overflow are very common, so we made them the default to increase readability of code, even if it comes at a slight increase of gas costs. ...
user avatar
  • 111

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