Questions tagged [solc]
Questions related to the compiler for Solidity: solc
312
questions
36
votes
6
answers
12k
views
Error while compiling: Stack too deep
When trying to compile, I am getting the following error:
"Internal compiler error: Stack too deep, try removing local variables."
Is there any way around this? I'm not sure if I'll be able to ...
21
votes
2
answers
9k
views
How do I find out the solidity compiler version I am using?
Specifically, while using Mist. When I create a contract via the Mist GUI, I want to then be able to verify the source code over at Etherscan. However, Etherscan requires that you provide the ...
19
votes
6
answers
10k
views
having a problem with solc-x version "solc 0.6.0 has not been installed"
I m trying to print out the variable (compiled_sol) as you will see in the code below of the python file named deploy.py so I can deploy my smart contract, but I keep running at this error
*****INFO: ...
18
votes
3
answers
8k
views
Etherscan: How can I verify a contract with multiple imports deployed with Truffle?
When I deploy a contract with Truffle that has an import statement, and try to verify it on etherscan, my understanding is that I need to paste in the contents of the imported file.
I get an error on ...
17
votes
5
answers
8k
views
Is the SafeMath library obsolete in solidity 0.8.0?
SafeMath was commonly used to revert the transaction on overflow and underflow, instead of allowing the number to wrap around. The solidity 0.8.0 release notes state:
Code Generator: All arithmetic ...
17
votes
2
answers
4k
views
Is there a way to disable a warning in solidity code? [duplicate]
I'm writing unit tests for some contracts and in some of the tests I'm generating a warning on purpose and solc will display this warning when compiling.
Is there a way to disable warnings in solc ...
15
votes
5
answers
10k
views
Solidity Error: Struct containing a (nested) mapping cannot be constructed
My version of solc:
"solc": "^0.7.1",
When I try to construct a struct that contains mapping, I got this error:
"Struct containing a (nested) mapping cannot be constructed&...
13
votes
1
answer
2k
views
What's the difference between solc's bin bytecode versus bin runtime?
Solc says that bin-runtime is the runtime part of the contracts. What exactly is the runtime bytecode part and how does it differ from bin bytecode output?
12
votes
1
answer
579
views
How to generate sugared assembly code from Solidity code?
In the Solidity documentation I see a sample assembly code:
{
mstore(0x40, 0x60) // store the "free memory pointer"
// function dispatcher
switch div(calldataload(0), exp(2, 226))
case ...
11
votes
1
answer
11k
views
How do I install solc on Mac Osx? Error encountered "Error: No formulae found in taps."
I'm trying to install a solidity compiler on my Mac.
I've followed the guide here: https://github.com/ethereum/go-ethereum/wiki/Contract-Tutorial
The error that I've gotten when installing ccp-...
11
votes
3
answers
5k
views
Internal compiler error: Accessors for mapping with dynamically-sized keys not yet implemented
I have a mapping(string => Person) public map:
struct Person {
string name;
string description;
address primaryAddress;
string linkToWebsite;
string ...
10
votes
7
answers
20k
views
Solc --version: command not found
I'm trying to use solc with no success.
I download solc with npm install solc but when I run solc --version the console output is:
command not found.
If I list packages npm list I'm able to see ...
10
votes
1
answer
7k
views
Compiler solc expected a state variable declaration
I try example from book Mastering Ethereum:
contract Faucet {
function withdraw(uint withdraw_amount) public {
require(withdraw_amount<=10000000000000000);
msg.sender.transfer(...
10
votes
2
answers
771
views
How to get a contract verified on etherscan?
I'm having a hard time getting a contract verified on Etherscan.
I deployed the contract using Ethereum Wallet, I can effectively find it on Etherscan but when I copy-paste the exact same code to the ...
10
votes
1
answer
218
views
Is it dangerous to name my function ccccvKygDv?
For those keeping track at home, the function hash of a function named ccccvKygDv() is 0xffffffff, the same as a null address.
pragma solidity ^0.4.0;
contract NullFunction {
function ccccvKygDv()...
10
votes
3
answers
5k
views
Source "<filename>" not found: File outside of allowed directories. [solidity/solc]
I'm using vim with the syntastic plugin.
I'm getting this message:
Source "zeppelin-solidity/contracts/token/StandardToken.sol" not found: File outside of allowed directories. [solidity/solc]
when ...
9
votes
5
answers
13k
views
What is the cause of the error: Expected import directive or contract definition
I'm working on the tutorial at https://www.ethereum.org/dao and I'm getting the following error:
1:5: Error- Expected import directive or contract definition.
function owned() {
^
When I get ...
9
votes
1
answer
1k
views
What is the cryptic part at the end of a solidity contract bytecode?
Given the following contract:
pragma solidity ^0.4.11;
contract Simple {
bytes32 public v;
function set(bytes32 _v) {
v = _v;
}
}
When disassembling, neither remix, solc or evm ...
9
votes
1
answer
2k
views
Link solc with geth problem
After upgrading to geth 1.4.4 I am no longer able to from to reference the compiler from geth.
The solc compiler is installed in /usr/local/bin but this is what I get when I check for available ...
8
votes
2
answers
2k
views
Infinite gas estimation from solc for simple function
Here is a simple Solidity contract:
pragma solidity ^0.4.16;
contract Test {
uint[] array;
function testGasEstimation() public {
array.length = 1;
}
}
Here is the output of ...
8
votes
1
answer
625
views
When did the Ethereum "free memory pointer" change? (6060... -> 6080...)
I have been digging a bit deeper into the Ethereum bytecode with the specific goal to do contract verification from the source code.
I noticed, while doing some tests, that the initial bytes of the ...
7
votes
2
answers
2k
views
All cases when Solidity compiles to invalid jump destination
Solidity generates EVM bytecode that leads to an invalid jump destination when:
throw is used
... ?
... ?
Can the above list be completed, with examples?
To explain the first item, throw in ...
7
votes
1
answer
361
views
Tracing back tripped require() to a source code line
What would be the process to map failed transactions (require, throw, etc.) back to the source code line where they occurred?
Any examples of such yet?
7
votes
2
answers
5k
views
What is the proper way to build and call a specific version of solidity?
I am getting the following error from solc:
Error: Source file requires different compiler version (current compiler is 0.4.11-develop.2017.6.22+commit.68ef5810.Darwin.appleclang - note that nightly ...
7
votes
3
answers
998
views
Alternative to deprecated Greeter example code?
After loads of research, it seems the Ethereum.org Greeter example code no longer works. Here's the GitHub issues thread: https://github.com/ethereum/go-ethereum/issues/3793. There are some ...
7
votes
2
answers
3k
views
Unhandled rejection Error: Couldn't decode uint256 from ABI
I am working on using a sample Contract using NodeJS, Web3, and Solc but I encountered some error that the given address in the Contract that I've created couldn't decode. Am I doing something wrong? ...
6
votes
1
answer
5k
views
How to include solidity file into another?
I completely stuck on modules importing into Solidity contract. Here is my files/directory layout:
.
|-> contracts/
|-> contract1.sol
|-> contract2.sol
File contract1.sol contains only ...
6
votes
2
answers
1k
views
Do intermediate memory variables cost gas?
Example without an intermediate variable:
uint startTime = 9;
uint allowedTime = 7;
require(now > startTime + allowedTime);
Example with an intermediate variable:
uint startTime = 9;
uint ...
6
votes
3
answers
845
views
Solc Compiler oversight? Innappropriate mapping declaration overwrites storage
I have written a contract that has the mapping storage variable A & B. These variables get initialized with some values in constructor. A method getBalance returns the balance from mapping A & ...
6
votes
2
answers
5k
views
Using two solc versions within the same truffle project
I am creating an app that has various imports that require two different versions of solidity. AragonOS(0.4.x) and openzeppelin(0.5.x)
Of course, there are breaking changes in 0.5.x so my question is ...
6
votes
1
answer
492
views
Getting segmentation fault while compiling solidity contract
Getting segmentation fault when compiling a simple contract on geth on OSX Yosemite
web3.eth.getCompilers();
["Solidity"]
source = "contract test { function multiply(uint a) returns(uint d) { return ...
6
votes
2
answers
5k
views
Switch solc compiler versions
I have solc v0.5.2 on my system, but I have several contracts, that require solc < v0.5, so that I get errors:
Error: Source file requires different compiler version
What is the best way to run ...
6
votes
1
answer
637
views
Compiler Issue or Improper State Variable declaration?
After seeing some unexpected compiler results, I've reduced the issue to this tiny example:
The following compiles under 0.4.10 in Remix:
contract StorageMapping {
struct S {
mapping(...
6
votes
2
answers
873
views
Error: Member "assertNotEqual" not found or not visible after argument-dependent lookup in uint256
I am trying to run test cases in sol-unit for Solidity, but when I compile my code with solc compiler I get an error. I don't think the error is critical, but there is very little material on net ...
5
votes
3
answers
2k
views
Error when calling the selfdistruct method in solidity
I am quite new to solidity, and I have not managed to find a solution for this problem.
I am passing the function an address but it says the following:
"Invalid type for argument in function call. ...
5
votes
3
answers
5k
views
Installing solidity in Debian Linux
I'm trying to install solidity but apparently there are no online repositories with all dependencies. I have tried using the methods described here.
sudo add-apt-repository ppa:ethereum/ethereum
...
5
votes
1
answer
443
views
Is the Solidity compiler deterministic?
I am aware that you have to specify the Solidity compiler version and whether or not you use the optimisation flag. But even with all that considered - is the compiler deterministic?
5
votes
1
answer
3k
views
How do I host Ethereum on a server?
I recently tried to get geth and solidity up and running on a virtual server I have some free time on.
I got stuck trying to build the Solidity compiler due to issues with the OpenGL library. I've ...
5
votes
1
answer
2k
views
What is the behavior of solc with optimizer disabled?
When enabling the optimizer the documentation of solc tells you that you can choose between optimizing the gas cost at deployment or the gas cost at execution by setting the runs parameter.
But what ...
5
votes
2
answers
3k
views
Install Solc Compiler on Windows 8
I need a command line compiler in order to make an expert system that automatically builds, tests, and deploys systems of smart contracts based only on metadata. I have tried for several days to ...
5
votes
2
answers
1k
views
How do I fix Javascript stack overflows when compiling very large file with solc?
If I compile a very large file with solc the stack overflows. This will happen most commonly in node because the default stack is only 984kbytes, which is strangely what you would expect for a 1990s ...
5
votes
1
answer
2k
views
TypeError: 'setSolc' is not a function
I am trying to sync geth and solc.
which solc # I get the path to my solc
/usr/local/bin/solc
Open the geth console
geth console 2>>geth.log
and now I try to sync
admin.setSolc("/usr/local/...
5
votes
1
answer
518
views
Solidity compiler doesn't work in the Javascript Console
I'm using Geth 1.4.5-stable along with Solc version 0.3.5-0 both on Linux. It is run on a Digital Ocean server. I have a fully synced testnet chain and I'm trying to compile contracts from within the ...
4
votes
4
answers
7k
views
web3 contract instantiation
I'm trying to create a contract object with web3.
var contract_abi = result['contracts']['Test']["interface"];
//[{"constant":false,"inputs":[],"name":"inc","outputs":[],"payable":false,"type"...
4
votes
1
answer
565
views
VS code Expected identifier, got 'LParen'solc
I keep getting this error/warning on my vscode when I emit events and build constructors.
or
After a bit of googling I understand it is something about my compiler, since solc <0.4.18 does not ...
4
votes
1
answer
1k
views
What about calls you can do safely in constructor?
As a matter of fact, there is more than one discussion about what are the call you can safely do in the constructor.
Someone thinks “avoid all external call”, some other says “avoid to use ‘this’ or ...
4
votes
2
answers
864
views
Contract not deploying on blockchain using solc & web3
I am using the npm package of solc to compile the contracts and accessing it as given here. It is compiling my contracts. But when I try to deploy the contract using
web3.eth.sendTransaction({data: ...
4
votes
1
answer
2k
views
Enums in Solidity
Enum's are not working in solc? Just tried to compile demo contract from gihub documentation :
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill };
function test()
{
...
4
votes
1
answer
2k
views
Importing .sol files from an node_modules folder
Did i miss something in configuration, or will this be fixed in an future version?
Best regards
# ls -al
Makefile
README.md
build
cmd
contracts
node_modules
package.json
# ls -al ./contracts
Wallet....
4
votes
1
answer
4k
views
The solc is not generatig *.abi file with the option --abi and -o build
When I use the --abi option, the abi interface is generated:
$ solc Greeter.sol --abi
======= Greeter.sol:mortal =======
Contract JSON ABI
[{"constant":false,"inputs":[],"name":"kill","outputs":[],"...