8

It's possible but there's no easy way to do it. You either have to do some bitwise xor and shifting to build the uint, or use inline assembly to mload. Here's the working code, feel free to copy paste function sliceUint(bytes bs, uint start) internal pure returns (uint) { require(bs.length >= start + 32, "slicing out of range"); uint x; ...


6

Obviously it is really simple: The optimizer settings are in the wrong place. I used the example provided here but according to the documentation it needs to be under settings:{...} in the solc config. So this: compilers: { solc: { version: '^0.5.0', settings: { evmVersion: 'byzantium' // Default: "petersburg" }, ...


5

That is typically caused by a bad import statement. Check that something isn't being included incorrectly. A good example would be something like: import 'MyContract.sol'; as opposed to import './MyContract.sol';


5

I'm afraid that truffle is still using the old solc compiler, that's why you get that error. Indeed $ truffle version Truffle v4.1.3 (core: 4.1.3) //this is the last truffle version Solidity v0.4.19 (solc-js) You can try to update solc manually and the issue will be fixed. $ cd /usr/local/lib/node_modules/truffle $ npm install solc@0.4.21 this will ...


5

There are two problems with Truffle compilation output (JSON files), which make it difficult to keep them under version-control: The updatedAt field indicates the compilation time of the source file The bytecode field encodes the absolute path of the source file Due to problem #1, compiling the same input will always yield a different output. Due to ...


5

Nevermind, the issue was that I had a missing bracket at the end of the contract. It is possible to compile files with different contract names with truffle (not possible with sol-compiler though).


5

Turn out that Truffle v5 versions earlier than v5.1.5 won't successfully compile ^0.6.0 solidity contracts, because the solc wrapper Truffle used (directly from solc-js) was only compatible with ^0.5.0 contracts. The solution is to update the truffle package using npm update -g truffle Thanks to CruzMolina form GitHub !


4

OZ has updated their code besides restructuring some of the folders. Old Answer (pre 2.X.X release) Look here: https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20/BasicToken.sol Your direct answer: totalSupply_ (the underscore) is the variable name you're looking for. Current Answer Update (12/11/18): uint256 private ...


4

I don't know if there is a real answer for that, but I use this solution: I change the migration file and I write the ABI and its address after the deploy var fs = require('fs'); var MyContract = artifacts.require('./MyContract.sol'); var fileContent = require('../build/contracts/MyContract.json'); module.exports = function(deployer) { deployer.deploy(...


4

From the docs: Up to three parameters can receive the attribute indexed which will cause the respective arguments to be searched for: It is possible to filter for specific values of indexed arguments in the user interface.


4

The --reset flag will force to run all your migrations scripts again. Compiling if some of the contracts have changed. You have to pay gas for the whole migration again. For ganache/testrpc it should not be an issue it is just a extra delay. But for deploying against a public network: mainnet, rinkeby, ropsten, etc. it can be really annoying to have to wait ...


4

It's solved by running with elevated permissions once: sudo truffle compile - that will download the compiler and then you can continue using non-elevated command truffle compile. That is most probably an issue with a folder permissions on your system, but I wasn't able to figure out which exactly folder that would be. The above fix worked for me and others ...


3

My guess is that your file is encoded in UTF-8 with BOM. BOM encoding injects a sequence of bytes at the beginning of file mostly to signal a few things to a program reading the file. [Wikipedia] In the case of a Solidty file, the compiler expects a file starting with pragma but with UTF-8 BOM file, it starts with random bytes like 0xEF,0xBB,0xBF followed ...


3

To start: yes you can commit them, there's nothing sensitive in them. As far as I can tell, there is no real consensus about whether the build directory should be added to version control or not. Adding them mostly won't hurt, but it too has some side effects (the files contain some user-specific stuff). OpenZeppelin seems to add the build directory into ....


3

You will see the same warning in Remix if you look at the compiler page. The warning is quite clear: you have a variable which is not used anywhere in the function logic. It's not an error but the compiler is trying to help you to save gas and to make the function cleaner by removing the unneeded parameter. If you want you can just ignore the warning. ...


3

When you compile your contracts inside a truffle project, only the modified ones get compiled, if a build exists yet (if you want to recompile all contracts, run truffle compile --all). From the command line, there is no options to just deploy one specific contract, but you can use the flags --f <number> and --to <number> to specify which ...


2

I figured it out after deciding to post additional details with the versions of truffle and node. $ node --version v6.11.5 $ truffle test // no support for async ... install the latest node. $ node --version v8.9.0 $ truffle test // async now works :D


2

The other thing you can do to use Oraclize with Truffle is just copying the http://github.com/oraclize/ethereum-api/oraclizeAPI_0.4.sol file locally and importing that file in the contract where you want to use it. Truffle needs the contract to be named the same as the file in order to compile it, so you will need to rename the Oraclize file to ...


2

I copy-pasted the Oraclize contract into my Truffle and I was able to migrate the contracts to Kovan by running a Parity node locally. Were you running an account that had Ether on it? Looking at the Truffle docs, there is an EthPM registry that they suggest to install dependencies using: http://truffleframework.com/docs/getting_started/packages-ethpm. On ...


2

Even, I had the same error. From the Doc When using the Command Prompt on Windows, the default configuration file name can cause a conflict with the truffle executable.If this is the case, we recommend using Windows PowerShell or Git BASH as these shells do not have this conflict. Alternatively, you can rename the configuration file to truffle-config.js ...


2

You were trying to verify the "Migrations" contract that you used in your truffle configuration. You incrementer contract was the next contract you created, and can be found here: https://ropsten.etherscan.io/address/0x8705c513da621a16fd1defc9de8ae7cdead01fb8#code I verified it for you, using the Optimizer but setting it to 0 optimizations. You were using ...


2

There is no direct access to the fields from another contract. The public keyword in address[16] public adopters will generate a getter function with the same name, hence adoption.adopters(8).


2

I had a similar problem. In my case it was the system version of solc I had installed. Here's what I had. I had solc installed through Homebrew, and also truffle installed. when I run truffle version: Truffle v4.1.14 (core: 4.1.14) Solidity v0.4.24 (solc-js) So I had the latest version of truffle and seemingly, solc as well. However, when I run solc --...


2

uint not unit. It might be helpful to play around in Remix just to catch errors like that before moving on to Truffle. Set the compiler version to the same solc you see when do a truffle version. Hope it helps.


2

I haven't actually tried what you're doing, but I noticed a possible misinterpretation of the linked docs. Maybe it will help. If I'm not mistaken, their "native" is bundled with truffle, and the syntax you used for solc-js v0.5.0 is for docker containers that I don't think you are using. Did you try?: // Relative or absolute path to an npm installed ...


2

the question is old but I'll answer it anyway, if you use VS Code add "solidity.packageDefaultDependenciesContractsDirectory": "", "solidity.packageDefaultDependenciesDirectory": "node_modules" in it's settings.json


2

I managed to fix the problem. After googling the problem again I found these two links: Nested structs that are part of a mapping broken in Solidity 0.5.0? and Nested structs that are part of a mapping broken in Solidity 0.5.0? which sent me in the right direction. The problem ended up coming from having functions that an inherited contract will be using ...


2

I got the issue solved ! The array declares productsForSale also gives a by default getter as it is public, remove public and it will work Product[] public productsForSale; replace it by Product[] productsForSale;


2

The problem was I edited the file in VSCode, but autosave was turned off. So this is the error message you get if you have an empty file in the contracts directory.


2

Ensure you have installed openzeppelin-solidity in your project npm install openzeppelin-solidity Your imports are then as follows: pragma solidity ^0.5.0; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol"; contract DemirelToken is ERC20, ERC20Detailed { constructor(...


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