32
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 ...
31
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
29
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-...
24
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-...
23
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, ...
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.
19
votes
Solc --version: command not found
If you have installed through npm install -g solc
Here's how you use it. solcjs --version
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;
16
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;
...
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'...
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 ...
15
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, ...
14
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.
...
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 ...
11
votes
Error while compiling: Stack too deep
Uniswap seems to have found a neat solution for this issue. Surround a part of your function with brackets:
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
...
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
...
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:
...
9
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
9
votes
Accepted
What about calls you can do safely in constructor?
In a Solidity constructor:
this is the address of the contract that is being constructed. (even after using new or calling an external function of another contract)
msg.sender is the address of ...
8
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 ...
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 ...
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, ...
8
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 ...
8
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 ...
8
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 ...
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 ...
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 ...
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 ...
7
votes
Accepted
What are remappings and how do they work in solidity?
You may want to take a look at the docs on Layout of a Solidity Source File.
The solidity compiler can only reference files that exist locally on your computer. So importing directly from GitHub (as ...
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:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
solc × 350solidity × 198
truffle × 37
go-ethereum × 34
web3js × 34
compilation × 34
compiler × 30
contract-development × 26
contract-deployment × 20
remix × 18
solcjs × 18
evm × 14
nodejs × 13
python × 12
abi × 12
bytecode × 11
import × 11
hardhat × 11
contract-debugging × 10
etherscan × 9
truffle-compile × 7
py-solc-x × 7
javascript × 6
assembly × 6
mocha × 6