Questions tagged [compilation]

For questions regarding contracts compilation.

Filter by
Sorted by
Tagged with
56
votes
5answers
14k views

How can you decompile a smart contract?

On the blockchain I can inspect the code of a contract, and see the EVM opcodes. Is there a way to decompile this and convert it back to (Solidity) source code?
52
votes
7answers
7k views

How can I verify that a contract on the blockchain matches the source code?

Given the (Solidity) source code of a smart contract, is there a way to deterministically compile the code and compare it with the code on the blockchain? I want to verify that the contract does what ...
36
votes
2answers
6k views

What are the steps to compile and deploy a library in Solidity?

I have several pieces of documentation about libraries, but I am not yet able to infer what steps are needed to compile and deploy a library and then a contract that uses it. The behavior of the ...
27
votes
6answers
15k views

How to compile Solidity contracts with Geth v1.6?

I tried to compile the following contract within geth: pragma solidity ^0.4.8; contract Test { uint256 public value; function Test() { value = 123; } } using the following ...
18
votes
2answers
1k views

What does bytecode of blank contract do?

When I compile a blank contract: contract A {} with solc --optimize --optimize-runs 300000 --opcodes test.sol I get: PUSH1 0x60 PUSH1 0x40 MSTORE PUSH1 0x6 DUP1 PUSH1 0x10 PUSH1 0x0 CODECOPY ...
14
votes
1answer
7k views

How should we set a import path in solidity?

I failed to compile a solidity file with import statement. Error: Source not found: File not found. import './contract.sol'; How should we set a import path? I used web3.js for compiling. ...
13
votes
2answers
4k views

How to load Solidity source file into geth

Is it possible to load Solidity source file .sol file to go-ethereum. I am using the 'loadScript' method by saving a .js file like the following and loads it. source = "contract test {\n" + " /// ...
13
votes
2answers
841 views

Why does a simple function returning a 'string', call another contract?

This trivial contract: contract Test { function test() returns (string) { return "foobar"; } } Results in assembly code output (in the solidity web compiler) for the function 'test' ...
13
votes
1answer
501 views

Is there a way to detect which compiler version produced a contract binary?

Given the compiled bytecode on the blockchain, is there a way to detect which compiler version is being used in order to verify source matches bytecode without having to bruteforce all available ...
12
votes
1answer
2k views

Bytecode on block chain different from the one used when deploying

When I deploy a contract from node.js using the web3 JavaScript API (connected to a locally running geth), and then check the deployed bytecode using eth.getCode(address) (either from the JS console ...
8
votes
1answer
261 views

Could a contract, or parts of a contract, be reverse engineered from bytecode if the ABI was available?

Compilation back to the original source code from just the bytecode is impossible because all variable names, type names and even function names are removed. (source) It's possible to call functions ...
7
votes
2answers
1k 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
2answers
792 views

Can I compile a smart contract without removing the line breaks?

According to an official document, compiling a smart contract needs to remove all the line-breaks in the contract's source-code: If you have the SolC Solidity Compiler installed, you need now ...
7
votes
1answer
834 views

Why does compiled solidity code do this check on the argument with which it was called?

I have compiled the following Solidity code: pragma solidity ^0.4.9; import "./Callee.sol"; contract Caller{ function call(address callee_address){ Callee callee = Callee(callee_address); ...
7
votes
1answer
270 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
1answer
165 views

Distinct, inconsistent compilation of inherited but identical contract in solidity

Consider the following solidity source file A.sol: pragma solidity ^0.4.8; contract A {} and B.sol: pragma solidity ^0.4.8; contract A {} contract B is A {} Using solc version 0.4.8, the code ...
7
votes
1answer
5k views

How to compile .sol file from the command-line?

How do I compile a solidity file (e.g. 05_greeter.sol) from the command-line into bytecode? Without using IDE such as Mix.
7
votes
2answers
2k views

Why does solidity compiled bytecode not match data for creating transaction?

I'm trying to independently verify the source code of solidity contracts, and stumbled across a case where the compiled bytecode for the source code of the contract does not match the data of the ...
6
votes
1answer
910 views

Not enough components (4) in value to assign all variables (6)

This is an exception on compilation I am getting with truffle. The code I am running builds a store from a container contract and then makes a call to get a product from it. Store s = Store(saddress)...
5
votes
2answers
2k views

What is the cheapest way to roundup() or ceil() to multiple of 1000?

What is the cheapest way to roundup() or ceil() to multiple of 1000? For example if cheapest way to roundup is implemented in the ceil function: function ceil(uint a, uint m) returns (uint) { /...
5
votes
4answers
848 views

I can't verify my contract on the Rinkeby etherscan site

I'm getting the following error when verifying on the RINKEBY etherscan site: Error! Unable to verify source code Exception #1 Occured: ERROR|The Contract solidity compilation has exceeded the ...
5
votes
1answer
549 views

Status of ABIEncoderV2 now

Do you know the current status of ABIEncoderV2? I want to know the current status of ABIEncoderV2 Live projects using ABIEncoderV2 right now Restriction on the normal encoder Risks of using ...
5
votes
4answers
2k views

web3.eth.compile.solidity doesn't compile

I am trying to deploy a contract through my front-end via web3 API. However nothing appear to compile and there is no contract address or ABI to interact with the deployed contract (if it is deployed) ...
5
votes
1answer
246 views

Why does inserting a Struct cost 5,000 extra gas per item in the Struct?

Related to the findings in: Solidity bool size in Structs Why does inserting a Struct cause an increase of 5,000 gas per item in the Struct? For example: // A Struct that, when tightly packed, is ...
5
votes
2answers
753 views

Optimizing storage for an array of addresses

When possible, does Solidity optimize a storage array of address? For example, does address[8] take up 5 storage slots (160 bytes), or 8 storage slots? contract C { address[8] arr; } If 8 slots ...
4
votes
3answers
2k views

Compiling contract in web3: “Method eth_compileSolidity not supported”

I have web3 and truffle running. I am able to execute the following commands: > node > Web3 = require('web3') > web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); >...
4
votes
2answers
621 views

What is the program counter at the start of an Ethereum method execution?

When a method in a deployed contract is called (either by an externally controlled account or by another smart contract), what will the program counter be at the beginning of the method call? In other ...
4
votes
2answers
783 views

Why and how does the “low security” functions affect the biggest multi signature contract?

People use this contract everyday http://github.com/ethereum/dapp-bin/blob/master/wallet/wallet.sol and it's also the contract with most ethereums right now. Also you can create a multisig account on ...
4
votes
2answers
2k 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 ...
4
votes
2answers
675 views

totalSupply() Solidity signature causing conflict error

I'm writing a very basic ERC20 token using solidity in the Mist wallet. For some reason the compiler doesn't like the totalSupply() function name. If I change this name it compiles fine. To be ERC20 ...
4
votes
1answer
3k views

returns (uint256) is not implicitly convertible to expected type uint256

I try to compile the following (in Solidity) ... contract InfoFeed { function info() payable returns (uint ret) { return 42; } } contract Consumer { uint attribut = 0; InfoFeed feed; ...
4
votes
1answer
331 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?
4
votes
2answers
2k views

how to build the mix IDE

anyone knows how to build the mix IDE? I found no info on this in the README or elsewhere. When I try to build master via cmake I am getting: ➜ 3rd cmake mix -- The C compiler ...
4
votes
1answer
548 views

How to compile Solidity ^0.5.5 contract with Node.js?

I am terribly new in Solidity and now I try to learn how to compile a contract in Solidity ^0.5.5 (No versions below). I have the contract as follow (UsersContract.sol) pragma solidity ^0.5.5; ...
4
votes
1answer
333 views

Difference between unoptimized and optimized solidity code

I am trying to find a source on what the difference is between optimized and unoptimized code. My main question is what the unoptimized compiler does, especially in the sense of calling the SSTORE ...
4
votes
1answer
831 views

solc returns empty bin for contracts with constructor and inheritance

Having a simple contract structure like this: pragma solidity ^0.4.8; contract A { uint public a1; } contract B is A { uint8 public b1; } I can compile it with: > solc --combined-json "abi,...
4
votes
2answers
343 views

Why is the jump address calculation so complex in compiled Solidity code?

I have the following simple Solidity contract: pragma solidity ^0.4.0; contract Test { function Test() { intfunc(5); } uint8 store; function intfunc (uint8 a) internal { ...
4
votes
1answer
185 views

How to disable 'Gas requirement not constant' warning in Solidity

I keep getting these warnings when compiling Solidity code: Gas requirement of function [...] unknown or not constant. I know that the gas requirement is not constant, and I've implemented a ...
3
votes
1answer
1k views

How are the arguments of the constructor encoded in the contract creation transaction?

The Ethereum ABI defines how arguments are encoded and passed when a method is called. But how are the arguments to the constructor encoded in the contract creation transaction which creates the smart ...
3
votes
5answers
2k views

Error “Trying to create an instance of an abstract contract.” for standard token

When I try to create a new instance of the standard token, compiler throws an error: Error: Trying to create an instance of an abstract contract. I suppose it is due to abstract receiveApproval ...
3
votes
1answer
220 views

Structure with 16 elements

I have created structure with 16 elements and received solidity compiler error. Exception during compilation: /src/libsolidity/../libevmasm/Instruction.h(217): Throw in function dev::solidity::...
3
votes
1answer
1k views

Compiling solidity code with geth+testrpc - Error: Invalid JSON RPC response

I'm attempting to compile the following contract using geth console attached to a testrpc instance: contract UnitCounter { mapping (address => uint256) public UnitsFrom; uint256 public ...
3
votes
1answer
120 views

v0.4.22 solc compile failing - not predictable behavior

Error: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. function CappedCrowdsale(uint256 _cap) public { ^ (...
3
votes
0answers
216 views

Stack too deep when compiling inline assembly

I'm running into a YulException: Stack too deep when compiling inline assembly: Variable headStart is 1 slot(s) too deep inside the stack. using a smart contract that has this function. I took this ...
3
votes
1answer
277 views

How to use evm compile?

I have been testing with evm and I am not getting any output. Code - pragma solidity ^0.4.18; contract d8 { function myBalance() pure public returns (uint) { return 880; } } My ...
3
votes
0answers
173 views

What's the difference between unlinked_binary and bytecode?

I have two different projects. In one, the build/token.json file contains an unlinked_binary field. In the other, there's no unlinked_binary, but there's bytecode. What's the difference between the ...
3
votes
0answers
559 views

Compile Smart Contract with Solidity on Windows 10

I wanted to use solidity within geth in Windows 10. I tried the compiled version that comes with Ethereum 1.0 but it has an issue mentioned in this thread. I'd like to get a new binary of a newer ...
3
votes
0answers
326 views

How can I install Ethereum on the Windows 10 Ubuntu Bash

Windows 10 new preview release includes the Ubuntu Bash. I would like to know if anybody has had some luck installing ethereum using the bash, and can provide details instructions. apt-get install ...
2
votes
2answers
2k views

unable to verify the contract on etherscan.io. How to resolve this issue?

I am unable to verify the contract in etherscan.io. I was able to deploy the same solidity code in (Geth, Mist). But the same code I am unable to verify in etherscan.io. What mistake am I doing here? ...
2
votes
1answer
2k views

Require in modifier: Undeclared identifier

curious why the require statement throws up Undeclared identifier in this solidity code: pragma solidity ^0.4.8; contract Escrow { .... modifier onlyafter(uint _time) { require(now >...