6

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; ...


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

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).


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

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 ...


4

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" }, ...


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

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

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 !


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

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

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

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 ....


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(...


2

Truffle 5.0.5 uses solc 0.5.x by default (not sure about the value of x). The override keyword is supported only from solc 0.6 onward. You should add in your Truffle configuration file: compilers: { solc: { version: "0.6.0" // or find out what the latest version is and use that instead } } See here for more details.


1

I managed to solve this by uninstalling and reinstalling nvm and node and then uninstalling and reinstalling truffle@beta. It could be that for some reason something was installed wrong (or didn't work with a later version) therefore creating the problem.


1

You've given space between '*' and '=' in j* = 10; , it's like this: j *= 10; Good Luck!


1

Solidity do not expose variables directly, but it creates a public getter function. Your example will behave like this. contract DappToken { uint256 public _totalSupply; function DappToken () public { _totalSupply = 10000000; } function totalSupply() public view returns (uint256) { return _totalSupply; } } To get the total supply you ...


1

Here, in this declaration add address in along with uint in the returns function ScheduleCall(uint256 blocknumber, address to, uint256 value, uint256 gaslimit, uint256 gasprice, bytes data, bool schedType) public payable returns (uint,address); Then it would work.


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