Skip to main content
33 votes
Accepted

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

First, let's save both of those files in the same directory and run solc --optimize --bin MetaCoin.sol. The output is: ======= MetaCoin ======= Binary: ...
redsquirrel's user avatar
29 votes
Accepted

How to compile Solidity contracts with Geth v1.6?

Alternative 1 - Use Remix To Compile, Then Copy-Paste To Deploy Use Remix from https://ethereum.github.io/browser-solidity: Copy the Web3 deployment instructions from the Remix page: var ...
BokkyPooBah's user avatar
  • 40.3k
15 votes

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

To add, it's possible to manually link contracts (if you wish to deploy both library and contract together.) The simplest way is just to replace all occurrences of the placeholders with the address. ...
Matthew Schmidt's user avatar
14 votes
Accepted

Bytecode on block chain different from the one used when deploying

Yes, it is normal and the code on the blockchain is always a subset of the compiled (byte)code, because the compiled code includes initialization code. The compiled code is/executes a function which ...
eth's user avatar
  • 85.8k
11 votes
Accepted

How should we set a import path in solidity?

Files and paths are explained in detail here: http://solidity.readthedocs.org/en/latest/layout-of-source-files.html Key points: Paths In import "filename";, filename is always treated as a path ...
tayvano's user avatar
  • 16k
11 votes

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

On discussing with the Solidity devs on Gitter, this is made clear: Solidity uses the identity function as a cheap memcpy operation, and the optimizer isn't currently clever enough to realise that it ...
Nick Johnson's user avatar
  • 8,154
11 votes

What does bytecode of blank contract do?

A user on Reddit kindly posted an opcode-by-opcode analysis for you: PUSH1 0x60 PUSH1 0x40 MSTORE Store 0x60 at memory location 0x40. I think this is normally used for variable indexing if you have ...
Tjaden Hess's user avatar
  • 37.1k
11 votes
Accepted

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

Here's one solution: contract Ceil { function ceil(uint a, uint m) constant returns (uint ) { return ((a + m - 1) / m) * m; } // To measure gas function ceil1(uint a, uint m) ...
BokkyPooBah's user avatar
  • 40.3k
10 votes
Accepted

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

Code execution in EVM always starts with PC=0. So the method you have called is jumped to in a switch-like code segment in the beginning of the bytecode of the EVM. CALLDATALOAD is not the argument ...
Thorkil Værge's user avatar
10 votes
Accepted

Status of ABIEncoderV2 now

Update 2020 (#2) As of Solidity 0.6.0, ABIEncoderV2 is no longer experimental. Update 2020 (#1) An update from the Solidity team reads: We are almost finished with implementing breaking changes and ...
Shane Fontaine's user avatar
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: ...
chriseth's user avatar
  • 3,392
9 votes
Accepted

How to load Solidity source file into geth

I found this Solidity Compile Helper ruby wrapper Usage solc_helper contract.sol This will generate a javascript file and print out a statement like the following. loadScript('/path/contract.js') ...
niksmac's user avatar
  • 9,673
9 votes
Accepted

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

The program counter is always 0 at the beginning of an execution. The contract sets the program counter to match the correct method call through a switch statement (a jump table) at the beginning of ...
Thorkil Værge's user avatar
8 votes
Accepted

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

My advice would be to use the Browser Solidity: Just copy paste your contract, and if it compiles without errors you can just copy past the content of Web3 deploy: var _numProposals = /* var of type ...
jayD's user avatar
  • 2,462
8 votes
Accepted

What does bytecode of blank contract do?

The "data" section mentioned in the yellow paper is the part that follows the PUSH instruction, i.e. the yellow paper only talks about push data. What you see in the assembly output is a higher-level ...
chriseth's user avatar
  • 3,392
8 votes

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

https://etherscan.io/verifyContract is a verification tool. By providing the Solidity Source Code it checks if the generated Bytecode matches to the contract Bytecode (under the given address). user ...
Badr Bellaj's user avatar
  • 18.8k
8 votes
Accepted

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

No, as there is no difference in the output of the bytecode from the simple contract Test {} plugged into Browser-solidity when using different recent versions of the Solidity compiler. There is ...
BokkyPooBah's user avatar
  • 40.3k
8 votes
Accepted

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

Try adding a pair of brackets after gas(800): feed.info.value(10).gas(800) becomes feed.info.value(10).gas(800)() What the error message is trying to tell you is that you're telling it to assign a ...
Edmund Edgar's user avatar
  • 16.9k
7 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: ...
BokkyPooBah's user avatar
  • 40.3k
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 ...
chriseth's user avatar
  • 3,392
7 votes

How to compile Solidity contracts with Geth v1.6?

I've encountered the same issue recently. There are a variety of workarounds, but here is the method I've employed. This isn't necessarily the best approach. To generate bytecode: > solc --bin ...
Max's user avatar
  • 636
7 votes
Accepted

Solidity: Function with same name but different parameter possible?

Yes, function overloading is possible, see here: https://solidity.readthedocs.io/en/v0.4.21/contracts.html#function-overloading Example from the docs: pragma solidity ^0.4.16; contract A { ...
TheFrozenOne's user avatar
6 votes

How can you decompile a smart contract?

There is a project Porosity now https://github.com/comaeio/porosity It's also integrated into Quorum toolchain https://www.coindesk.com/first-ethereum-decompiler-launches-jp-morgan-quorum-integration/
xvorsx's user avatar
  • 161
6 votes

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

Illustrating more of @Thorkil's answer. Example A very rough example, for conceptual purposes only, of the "switch-like statement at the beginning of the contract". method_id = first 4 bytes ...
eth's user avatar
  • 85.8k
6 votes
Accepted

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

According to the Ethereum Yellow Paper (section 4.2), the contract creation transaction does not have a data byte array where the arguments to method calls are placed. The contract creation only has ...
Thorkil Værge's user avatar
6 votes

Require in modifier: Undeclared identifier

require is available since Solidity 0.4.10: https://github.com/ethereum/solidity/releases Since your pragma requires an older Solidity version this leads to a compiler error.
SCBuergel's user avatar
  • 8,774
6 votes
Accepted

What is the proper way to build and call a specific version of solidity?

I solved my problem by RTFM. Mac users should install using Homebrew. From Installing Solidity brew update brew upgrade brew tap ethereum/ethereum brew install solidity brew linkapps solidity ...
maurelian's user avatar
  • 3,211
6 votes

Solidity Compiler - Error: Identifier already declared

This is because the method and the property have the same name. Since solidity automatically creates a public getter function for every public variable in the contract, you don't need function ...
Hari GTT Psicolabis's user avatar
6 votes
Accepted

Where are the smart contract constants stored?

Constants are not stored anywhere. They are replaced with their constant value in every usage at compilation time. For example, the following code. Notice how when I'm returning a constant from a ...
Jeremy Then's user avatar
  • 4,599
5 votes

How to load Solidity source file into geth

Update Jan 3 2017 Note that Solidity 4.7 compiler makes different code for the same contract when you have different whitespacing. This will be important when you try to add verified sources in the ...
BokkyPooBah's user avatar
  • 40.3k

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