Questions tagged [compiler]
A compiler is a computer program that translates a higher-level programming language into a lower-level language. For example: Solidity is compiled into EVM opcodes.
95
questions
0
votes
0answers
24 views
Solidity Ethereum Errors [closed]
I am new to solidity and I have been spending hours trying to figure out what was wrong but I still can't find it. Any help would be appreciated.
pragma solidity ^0.5.10;
contract ...
0
votes
1answer
14 views
Stack too deep error [duplicate]
Not sure what the best approach is to get around this. New to solidity. I've read the complicated 'answers' to this that suggest using structs, arrays, etc. but I can't figure out how to address this. ...
0
votes
0answers
15 views
Different compile version solidity
Is there an automated tool to convert old smart contracts to the newest one? There are many breaking changes in different versions and it is hard to keep up with them all.
I want to use my old ...
2
votes
1answer
46 views
Solidity Compiler and EVM relationship
When I compile the below code in 0.6.6 it doesn't compile (requires public) but in 0.7.3 it does compile.
If I make the below code compilable (adding public) in 0.6.6 I can successfully deploy on ...
0
votes
1answer
44 views
faucet = (new Faucet).value(0.5 ether)(); Doesn't compile
I am practicing with the code examples from Andreas' Mastering Ethereum book Chapter 7. I don't understand why this does not compile when I made the Faucet constructor Payable. See images below.
...
0
votes
0answers
81 views
Remix Compiler Errors - Transferred GitHub .SOL Codes to Remix
I transferred all 23 Sol extension files (smart contracts for Syscoin and Ether) from GitHub to Remix but only 3 of them can be compiled and deployed. The rest of them show errors.
[Here is the link ...
1
vote
1answer
18 views
Library calls fail depending on compiler version?
I'm trying to deploy my library and call it afterwards with the specific address.
While testing this I encountered that the behavior changed over the course of compilers.
I tried to follow How to call ...
1
vote
0answers
54 views
How to separately optimize bytecode?
This question is regarding the bytecode-optimizer of the solidity-compiler, not the yul-optimizer:
Is there any way to separately optimize bytecode?
Normally the solidity-compiler optimizes the ...
0
votes
1answer
27 views
How to detect compiler version given only Solidity Source Code
I've collected some random smart contracts from the internet, many of them do not specify compiler version using pragma in their source code. Is there any way or any tool that can help me identify the ...
1
vote
1answer
153 views
Compiler version incompatibility nightmare
I'm new to Solidity and Truffle. I'm trying to compile my Solidity code within Truffle to create an ERC-20 token. I have @truffle/hdwallet-provider and @openzeppelin/contracts as my dependencies. Now,...
0
votes
3answers
205 views
Trying to compile running: 'node compile.js', but get error: “assert.js:350 throw err;” [Udemy 'Complete Developers Guide' Course]
This is the first contract with this Udemy course.
Trying to compile by running: "node compile.js" but get the following error:
iii@iii:~/inbox$ node compile.js
assert.js:350
throw err; ^
...
0
votes
1answer
21 views
How do I update compiler for embark?
I am rewriting an old contract I had. I am using the latest version of OZ contracts.. but they require:
pragma solidity ^0.6.2
I am using embark 5.2.3 and current compiler is 0.6.1+commit.e6f7d5a4....
1
vote
1answer
352 views
Contract import from GitHub gives an error “Unable to import ”undefined“: TypeError: Failed to fetch”
This would be an old issue, but the solutions I have seen on this site aren't working. I'm trying to import a contract of OpenZeppelin to my Remix IDE.
import "https://github.com/OpenZeppelin/...
1
vote
2answers
38 views
How to publish in ethereum with “imports” ? or how to do?
Hello i have this question in my mind now :
How to publish in ethereum with "imports" ? or how to do ?
why i say this ?
answer : when i wanna "verify and publish Contract Source Code" with a ...
0
votes
2answers
911 views
Function, variable, struct or modifier declaration expected [duplicate]
I am using the following code structure;
pragma solidity ^0.5.0;
contract TtdmToken {
uint256 public totalSupply;
function TtdmToken () public {
totalSupply = 1000000;
}
}
...
1
vote
1answer
54 views
Are there any risks of undefined behavior when calling a function which doesn't return anything using a prototype of it which returns bool?
According to the ERC-20 Token Standard, functions transfer and transferFrom should return a boolean value indicating success or failure:
interface IERC20Token {
function transfer(address _to, ...
1
vote
2answers
175 views
Function overriding versus Solidity Compiler Warning: Function state mutability can be restricted to pure
I have a function in a base contract that could have the state mutability modifier "pure" because it always returns true:
BaseContract {
function x(bytes memory)
public
...
0
votes
1answer
32 views
Error While Compiling In Remix During Tutorial
During a tutorial on my first compile I received this error:
:1:1: Parser error: Expected import directive or contract definition.
pragma solidity ^0.5.12;
^
What's that about? How do I fix it? I'...
1
vote
0answers
160 views
Contract can't import remote repository locally
I made a compiler script that takes all contracts in folder ./contracts/ and produces a .json for each contract, containing an ABI and Bytecode. This worked fine for a while. However, I added some ...
4
votes
1answer
256 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 ...
3
votes
2answers
326 views
Setting Remix default Compiler Version
Is it possible to set the default Compiler version in Remix?
Each time I open Remix, the compiler defaults to version 0.5.0+commit.1d4f565a. However, there is currently up to version 0.5.10 available ...
2
votes
4answers
764 views
How to deploy Library contract separate from the main contract and link it
For deployment I am using remix. When I deploy Hello.sol the compiler typically merges SafeMath.sol as a part of the main contract (Hello.sol) and deploys. This adds up library and main contract's ...
0
votes
2answers
48 views
Solidity code sequence for owner
How can I make my code sequential, meaning I'd like functions to be performed in a certain order.
Can I make a function not run able till another is run.
An example would be great help.
1
vote
1answer
1k views
Function declared as view, but this expression (potentially) modifies the state requires payable
I'm trying to change the an address data variable to a one, which is selected via a function.
Keep getting the below error.
Function declared as view, but this expression (potentially) modifies the ...
1
vote
2answers
1k views
Type uint256 is not implicitly convertible to expected type int256
I'm trying to compile the following keep getting an error, even though used this before in second code and its working fine.
Simply trying to change the temp to the new temperature set by the user, so ...
1
vote
0answers
86 views
What is the value range of the parameter optimize-runs when running the solidity compiler?
I would like to know what the allowed value range of the parameter optimize-runs is when running the Solidity compiler. I didn't find the answer in the official document of Solidity.
1
vote
2answers
73 views
Get values from stack when certain Opcode is called
I am currently trying to use genetic algorithms to automatically generate test cases that for ethereum smart contracts similar to https://ieeexplore.ieee.org/abstract/document/7840029>this paper. In ...
0
votes
1answer
80 views
ABIEncoderV2PackedStorage bug, is something to worry about? any info?
I have a simple factory of ERC-20 Tokens, deployed to Rinkeby using remix.
When I create contracts with this factory and verify the code in Etherscan (using etherscan API) I am having this warning in ...
0
votes
0answers
102 views
solc command is generating empty .bin files
Firstly, this is not an inheritance problem like in this post
I have the following two files ( ManagedWallet.sol & ManagedWalletLookup.sol )
pragma solidity ^0.4.24;
contract ...
0
votes
2answers
2k views
Is there a way to download Remix IDE locally and access it from the Terminal (Linux)?
Is there a way to download Remix IDE locally and access it from the Terminal (Linux)?
Hi,
I think I have read that it should be possible to download Remix IDE and use it offline. In the latest ...
0
votes
1answer
502 views
Unhandled Rejection (Error): invalid string value (arg=“x”, coderType=“string”, value=5)
Using Truffle unbox react to unbox a boilerplate.
received the following error from running npm run start
Changes:
Addition of "memory" parameters in the simpleStorage.sol
Changed unit to string in ...
0
votes
1answer
90 views
Understanding the “.send” warning message
Warning: Failure condition of 'send' ignored. Consider using 'transfer' instead.
Is this a new compiler warning, and what exactly does it mean?
0
votes
0answers
68 views
Why the same contract has more bytecode size in solidity 0.5 in compare to 0.4.24?
My earlier contract was compatible with solc@0.4.24. Now I am upgrading my contract to make it compatible with solidity 0.5 but it leads to an increase in bytecode size. AFAICT There is no change in ...
0
votes
1answer
86 views
Error in external function parameter defination for an interface
Dear community members,
I have come across an error while defining an interface (just using the standard one interface ERC721TokenReceiver)
this interface is mentioned in this link https://github....
1
vote
2answers
2k views
Unable to run truffle compile
I want to run truffle compile on my AWS Ubuntu 18.4 server. I'm able to compile the same contracts on my local with no compilation errors but when I tried to run truffle compile on AWS ubuntu server ...
0
votes
1answer
92 views
Problem with wallet.transfer in newer solidity compilers
I read the documentation of the changes on 0.5.0 but I do not know how to get this done with my code snippet. I tried to make the constructor payable but this does not work. Can someone help me. The ...
0
votes
0answers
798 views
Can we eliminate specifying solc compiler version at the beginning of each smart contract.
Is it possible to eliminate specifying the solc compiler version at the beginning of each smart contract. This would help in separating the compiler version from the smart contract, so if the compiler ...
4
votes
2answers
2k 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 ...
0
votes
1answer
239 views
I build solc from source v0.4.18 but can't not use it to compile solidity. How can I solve this problem?
$ solc --bin -o ./contracts SimpleStore.sol
Warning: This is a pre-release compiler version, please do not use it in product ...
1
vote
1answer
416 views
Nested structs that are part of a mapping broken in Solidity 0.5.0?
The following code compiled successfully with Soldity 0.4.21. With 0.5.0 it triggers a fatal compilation error as follows:
UnimplementedFeatureError: Encoding type "struct TestNestedStructInMapping....
0
votes
1answer
346 views
Is it safe to call revert() instead of returning a value?
I have the following piece of code:
function func() public returns (bool) {
if (some condition on msg.sender) {
do some stuff
return true;
}
revert();
}
The compiler (0.4....
2
votes
2answers
28 views
Can I count on this general pattern executing correctly (similarly to C, C++ and probably any other language)?
Suppose I have something like this:
contract MyToken is ERC20 {
MyTokenImpl private myTokenImpl;
constructor(MyTokenImpl _myTokenImpl) public {
myTokenImpl = _myTokenImpl;
}
...
1
vote
1answer
92 views
Deploying fails with different compile version
I'm trying to implement a simple card game. Actually, everything is working fine. Until I tried to move from 0.4.0 to 0.4.22. Any idea what is going wrong?
Thanks a lot. And here the code:
pragma ...
2
votes
1answer
1k views
Why is there a difference between a public array and a function which returns it?
On-chain example:
pragma solidity 0.4.24;
contract MyContract {
uint[] public array;
constructor() public {
array.push(1);
array.push(2);
array.push(3);
}
...
2
votes
1answer
116 views
How to get the correct line numbers from `solc --ast-json`?
I have the following in a file:
contract Coin {
address public minter;
mapping (address => uint) public balances;
event Sent(address from, address to, uint amount);
function Coin() ...
2
votes
1answer
41 views
Why solc does not detect issue in this code?
I wrote a sample Solidity code below: in function call() of contract sample_call, I make a call to function add_car() function of another contract sample, but this is a bug, since variable v is never ...
1
vote
1answer
637 views
Remix IDE nolonger loads old solidity compilers. Error: "mock compiler: source not found|
The Ethereum solidity Remix IDE doesn't work for some reason.
It doesn't seem to load the various compiler versions and renders the error:
mock compiler: source not found
I've tried to install ...
2
votes
0answers
14 views
What is the compiler version of a contract created by internal transaction? [duplicate]
I want to be able to verify and publish a contract source code on Etherscan.io.
I have created a new contract from a factory contract, in which I successfully published and verified.
When I come to ...
2
votes
1answer
1k views
Do modifiers work in interfaces
Can an interface enforce a modifier on a function?
For example, does this work:
contract TokenSeller {
modifer enforceSale(uint256 amount) {
ERC20 t = token();
uint256 beforeBalance = t....
0
votes
3answers
286 views
Stack too deep compiler error, but function only has 5 parameters?
I have a function, shown in its entirety below, that is getting the dreaded "stack too deep" compiler error. I have read several of the other posts on this forum about this error, but all of them ...