Hot answers tagged

27

From Solidity - Binary Packages: brew update brew upgrade brew tap ethereum/ethereum brew install solidity


26

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 the lower limit of 16 will be the one that kicks in...) CommonSubexpressionEliminator.cpp and CompilerUtils.cpp: assertThrow(instructionNum <= 16, ...


21

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

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;


19

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, the code of the constructor. Longer answer The basics of the Ethereum Virtual Machine is defined in Section 9.1 of the Ethereum Yellow Paper. To answer this ...


15

Mist / Ethereum Wallet now has a built in compiler that is not very well document beyond screenshots in the tutorials in order to create, compile, and deploy contracts. However, the version of Mist's compiler and whether or not it is optimized is...hard to figure out. Go to the Mist releases page. Click on the release you are using. ie: 0.5.2 Click "CODE" ...


15

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 code for reference - https://gist.github.com/inovizz/1fdc2af0182584b90008e0cf2895554c Hope this helps.


14

If you have installed through npm install -g solc Here's how you use it. solcjs --version


14

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-issues-from-video.md You just need to do the following: On the line that says from solcx import compile_standard We need to change it to this line: from solcx ...


12

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 version 0.4.7 Solidity includes hash of contract's metadata at the end of compiled contract. As this metadata contains file names and hashes, you may get the ...


12

from 0.7.0 do like below: struct Request{ string description; uint value; address recipient; bool complete; uint approvalsCount; mapping(address => bool) approvals; } uint numRequests; mapping (uint => Request) requests; function createRequest (...


12

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-function See release of 0.6.0 https://solidity.readthedocs.io/en/v0.7.4/060-breaking-changes.html#semantic-and-syntactic-changes


11

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 contract metadata, that contains information about the current contract. It can be used to query the compiler version, the sources used, the ABI and NatSpec ...


9

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: array access out of bounds failed sub-call (due to any reason reported by the EVM including invalid jump dest in the sub-call) ether sent to a library fallback ...


8

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


8

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 requireDebugModifier to requireModifier. contract DebugEvents { event Debug(string message); modifier requireDebugModifier(bool arg, string message) { if (!...


7

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 not the case, please report a bug.


7

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 it compares the four bytes extracted with the known function selector. It doesn't matter that the function signature you're looking for happens to be 0xFFFFFFFF....


7

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, will be stored in stack(if there is a space and you keep them in one function). in case if compile will optimize it properly it will be for free, if not, each ...


7

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 making admin an address payable: address payable admin;


7

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 your plugins is called "Solidity Extended" by beaugunderson and disable it.


7

From the Solidity 0.8.0 Release Announcement about the exponentiation operator (**): We hope that we found a rather efficient implementation and would also appreciate your feedback about that! For many special cases, we actually implemented it using the exp opcode instead of our own implementation. More specifically, exponentiation operations that use a ...


6

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: error: "invalid jump destination (PUSH1) 2" (Somewhat Related) Stack Limit Reached 1024 Not what was asked in the question, but interesting anyway. contract ...


6

Depending on your Ethereum Wallet version, the compiler version is different as well. For the latest ones, you should select this version on Etherscan : v0.2.1-2016-01-30


6

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 is quite restrictive when making decisions about how much gas can be consumed by the code. In particular, any backward jumps or loops in the assembly code will ...


6

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 give an idea of how it works. Installing a new version of solc: >>> from solcx import install_solc >>> install_solc('v0.4.25') Checking ...


6

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 array.push(value);. The new length can be accessed via array.length. So, now you must do it "manually": pragma solidity 0.6.0; contract Test { struct ...


6

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, create a state variable, say, mapping (uint => Request) requests. Now, inside your function, you can write Request storage newRequest = requests[index] where ...


5

seems that if semicolon is removed, it works. Contract should look like: contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill } function test() { choices = ActionChoices.GoStraight; } function getChoice() returns (uint d) { d = uint256(choices); } ActionChoices choices; }


5

I solved this by installing solc with apt-get like sudo apt-get install solc Then I typed which solc and it told me it was installed at /usr/bin/solc. So I fired up geth console and used the command admin.setSolc('/usr/bin/solc') to point to the path. Then it worked.


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