We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [solc]

Questions related to the compiler for Solidity: solc

Filter by
Sorted by
Tagged with
4
votes
2answers
274 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 ...
4
votes
4answers
3k 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"...
3
votes
1answer
439 views

solc.loadRemoteVersion is not a function error

I'm trying to load another version of solc using the following code var Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); var solc = require('solc'...
2
votes
1answer
58 views

What is this evm code produced by solc in this public array checking, and why?

When solc creates code for arrays when they are declared public. In particular, it contains a check on the length of the array. For example, this: contract OutOfBoundsException { uint256[8] ...
12
votes
1answer
399 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 ...
3
votes
1answer
111 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 { ^ (...
1
vote
0answers
111 views

How to compile solidity in the browser without using browser-solc?

I am thinking of implementing an API call to compile some source code entered by a user and then return the bytecode for deployment using metamask. I have tried browser-solc but it had some errors ...
1
vote
0answers
21 views

Manually configure EVM Assembly Tag

I have read that Ethereum during the compilation splits the code into tags. The solc optimizer doesn’t optimize across tags. If we consider “1+1”, it can be optimized to 0x2 if under the same tag: /...
1
vote
2answers
194 views

How to compile and deploy smart contracts programmatically with Infura in NodeJs

I understand that i will need to be able to unlock my account in web3 to be able to deploy smart contracts. It's all good except i'm using Infura's hosted network instead which prevents me from ...
1
vote
1answer
1k views

structs, mappings, & enums. How to make them work together?

I have this code. My question pretains to struct variables weapons, armour, & stats enum Armour {Chest, Helm, Boots, Leggings, Gloves, Shield} enum Weapon {Sword, Axe, Wand, Gun, Hammer, Fist} ...
2
votes
1answer
35 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 ...
0
votes
1answer
631 views

Can't get contract to contract function calls working

I can't quite seem to figure out an issue preventing contract to contract function calls. I'm feeling fairly confident it's something with how I'm deploying. Preface: I have a Parent and Child ...
1
vote
1answer
366 views

warning about security/enforce-explicit-visibility: No visibility specified explicitly for multiply function [duplicate]

my ide is vs(can find solc version is 0.4.17),but my solcjs is 0.4.24.when I run this simple code `pragma solidity^ 0.4.45; contract test{ function multiply(uint a) constant returns(uint d){ ...
1
vote
1answer
101 views

What is the “clone-bin” output in solc?

When it comes to bytecode solc has three types of outputs: --bin Binary of the contracts in hex. --bin-runtime Binary of the runtime part of the contracts in hex. --clone-bin ...
1
vote
1answer
310 views

Compile multiple contracts

When compiling a .sol file that contains multiple contracts you get multiple binaries. How do I know which one belongs to the root contract? For example looking at etherdelta contract code I can see ...
0
votes
1answer
34 views

Solidity says my function can by marked as view but my code changes state?

Given the code below, when I compile the code with Remix it says the function processBandPayments() can be marked as view. This concerns me greatly since in my mind, the code is changing state by ...
0
votes
1answer
156 views

In Node.js connected to Geth : solc.compile prefixes an additional ':' before contractName

I'm trying the following script on Node.js while running a node connected to Rinkeby Testnet (from https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethcontract): const fs = require("fs"); ...
0
votes
0answers
162 views

Transaction remains pending on RINKEBY network

var Web3 = require('web3'); var Tx = require('ethereumjs-tx'); const fs = require('fs'); const solc = require('solc'); const generateWallet = require('ethereumjs-wallet'); var toAccount = 'TO ACCOUNT';...
1
vote
2answers
838 views

Solidity Compiler - Error: Identifier already declared

Full source code of the file 'Test.sol' : pragma solidity ^0.4.23; contract Mortal{ address owner; string ownerInfo = "Contract Owner name XYZ"; constructor () public { owner =...
0
votes
2answers
498 views

How to get an output similar to remix in solc, woth opcodes + comments from source

I would like to compile my contracts and to get an output with the opcodes in detail (not just assembly) but with references to the solidity source code at each line. This is the output one gets by ...
2
votes
1answer
252 views

what's the “Contract Creation Code” in Etherscan Verfied Contract?

what's the difference between "Contract Creation Code" in Etherscan Verfied Contract and the bytecode compiled by Solc?
1
vote
1answer
276 views

Why is my transaction not visible on ropsten.etherscan

I am testing a contract on a Ropsten network using geth 1.8.8 with command line: geth --testnet --datadir="" In order to connect to geth I use web3js version 1, beta 34 running from node.js. ...
0
votes
0answers
43 views

Does the solC compiler work in the geth Javascript console anymore

does the solC compiler work in the javascript console anymore, and if it does how can I install it. I have tried using the compiler methods in the javascript console api however they do not work and ...
1
vote
0answers
117 views

Solc compatibility with various versions of Geth

I'm looking for information about what minimal version of solc is compatible with geth, including older versions of geth (1.6+).
0
votes
1answer
316 views

Deploying a smart contract with several solidity files

I have a contract contains 4 .sol files and when I generate its bytecode and api as follows: > solc --bin GreenToken.sol > solc --abi GreenToken.sol I receive: ======= BasicToken.sol:...
1
vote
0answers
26 views

txList.length returns different value for different Solidity versions

I have RLPReader smart contract, took it from here. And I have a function untouched for a while: function deposit(bytes txBytes) public pure returns (uint) { RLP.RLPItem[] memory txList = ...
1
vote
1answer
45 views

Problems with binary generated by solc

I'm compiling a contract with solc and I'm getting something like this (I replaced most of the hexadecimal digits with three dots to make it shorter): 608060405234801561001057600080fd5b5060008054600.....
3
votes
3answers
3k views

“[Errno 2] No such file or directory: 'solc' ” Using py-solc and solidity

I installed py-solc and solidity: solc, the solidity compiler commandline interface Version: 0.4.16+commit.d7661dd9.Darwin.appleclang and ran this code in python (with a contract source example): ...
7
votes
2answers
2k 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? ...
0
votes
1answer
203 views

Cannot verify a particular smart contract code on Etherscan with optimization enabled

I've already deployed many smart contracts to Ropsten testnet and successfully verified them in Etherscan, but today I encountered one contract which doesn't get verified through all my attempts. This ...
1
vote
1answer
446 views

Calling Transfer event causes infinite gas estimation solc

solc estimates an infinite gas usage from _transfer and I am unsure why. I did find that if I comment out the Transfer(_from, _to, _amount) line, the gas usage becomes finite. Here is the minimum ...
1
vote
2answers
491 views

Calling a function from a contract passed in as an argument

Im Trying to create a DAPP with two contracts generating assets. One is acting as the "factory" for the other contracts. From the latter I try to call a function in the factory without knowing its ...
1
vote
1answer
44 views

Use shared library type in contracts

I want to reuse on type DateRange in two contracts. However, I fail with multiple errors. Currently I have one error: G21FE98E9 Member "endTicks" not found or not visible after argument-dependent ...
1
vote
0answers
40 views

Linker not working on solc v0.4.23

I can't seem to make the linker.linkBytecode() method to work... Here's how I'm using it: const linkedBytecode = linker.linkBytecode(mainContract.bytecode, { 'UserLib': userLibContract....
2
votes
2answers
1k views

How to use Solidity solc to compile A.sol that imports B.sol file?

I know how to install solc via "npm install --save solc" then use solc.compile to compile one sol file. But now I've got A.sol file that imports B.sol file, and when I run node compile.js, no error in ...
1
vote
1answer
160 views

What is ethereum bytecode link references is?

I compiled contract from there and found some strange things in bytecode: <some_bytecode>...__CrowdsaleTokenExt:SafeMathLibExt______6366098d4f9091836000604051...<some-bytecode> As I ...
1
vote
1answer
972 views

Deploy smart-contract using nodejs

I am trying to follow the following example. http://hypernephelist.com/2016/12/13/compile-deploy-ethereum-smart-contract-web3-solc.html But I get the following error. Can anybody show me what is ...
1
vote
1answer
452 views

How to install solc and build then build smart contract?

How to install solc on windows and then build smart contract ? I use following command : npm install -g solc Is it enough to use it ? Finally, I want to deploy my smart contract
1
vote
1answer
704 views

Is there a way to compile solidity code to javascript in javascript?

This example constructs the javascript code from a solidity code in a shell script. https://github.com/okue/Hello-Ethereum/blob/master/bin/compile Is there a function in javascript that can convert ...
0
votes
0answers
350 views

Solcjs doesn't use the last version of compiler

I am compiling a contract using the npm package solcjs. The package is at version 0.4.21 (npm view solc). However compilation fails because my pragma is set to ^0.4.21 while solcjs states current ...
0
votes
1answer
80 views

solc compiler; ParserError: Token incompatible with Solidity parser

I am trying to compile this contract (part of an online tutorial, not my contract). I'm running ethereumjs-testrpc (ganace precursor) on one terminal, then on another instantiate web3 object; > ...
10
votes
1answer
148 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()...
4
votes
0answers
67 views

What is the keccak256 reference in opcodes from solc? [duplicate]

Opcodes - Opcodes: PUSH1 0x60 PUSH1 0x40 MSTORE CALLVALUE ISZERO PUSH1 0xE JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0xA0 DUP1 PUSH2 0x1C PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN STOP PUSH1 0x60 ...
8
votes
5answers
11k 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 ...
2
votes
0answers
471 views

Importing files from an “outside” folder

I am trying to import files from a relative path outside of my Truffle-project folder: import '../../../common/solidity/contracts/token/ERC20/BurnableToken.sol'; import '../../../common/solidity/...
1
vote
0answers
153 views

verifying code deployed with web3.js

I am deploying my smart contracts using web3.js and compiling the code using solc. The contracts are deployed successfully with no issues however I am having a bit of a problem in verifying my ...
7
votes
2answers
1k 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 ...
1
vote
1answer
389 views

Infinite gas estimate caused by Internal function type

When I flag a simple function with the type internal, remix throws an infinite gas estimate warning. Without this type, everything is fine. Please, do you know why? function half(uint a) { ...
2
votes
0answers
161 views

Reasons for and debugging a contract that failed when deploying into blockchain

I have a program that has been tested from remix's VM, and compiled with solc, in both cases without any failure. However, when I try to use a custom script for deploying it into the rinkeby testnet (...
0
votes
1answer
484 views

How does solc generate the bytecode for a contract?

I got sick of using remix and copying-pasting my web3 deploy text so I'm trying to write a python script that will generate this deploy test for me. However, one of the fields in the instantiation ...