23 votes

Truffle: Error: Could not find a compiler version matching 0.5.0

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 ...
Andrey's user avatar
  • 1,087
9 votes
Accepted

Enabling truffle compile optimizer does not change the deployment gas cost

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....
kuzdogan's user avatar
  • 587
8 votes
Accepted

Solidity: Conversion bytes memory to uint

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 ...
libertylocked's user avatar
8 votes
Accepted

Is it safe to commit truffle build files to Github (open source)?

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 ...
goodvibration's user avatar
8 votes

Solidity ^0.6.0 Truffle Compile Error: Cannot read property ... of undefined

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....
linoleparquet's user avatar
7 votes

Unused function parameter. Remove or comment out the variable name to silence this warning

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 ...
Lauri Peltonen's user avatar
5 votes

Truffle Compile Error (Invalid input source specified, Compilation Failed)

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 './...
Malone's user avatar
  • 1,580
5 votes
Accepted

Contracts will not compile using truffle with the "emit" keyword included in front of events

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 (...
mirg's user avatar
  • 4,287
5 votes
Accepted

I'm getting an error when i have more than 3 indexed arg for an event

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 ...
goodvibration's user avatar
5 votes
Accepted

Could not find __Truffle__NotFound.sol from any sources

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).
Paul Razvan Berg's user avatar
4 votes
Accepted

How do you compile a contract that uses Open Zeppelin's Standard Token in Truffle?

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/...
Matt Swezey's user avatar
  • 1,236
4 votes

Best practice for sharing truffle build files between developers

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 = ...
mirg's user avatar
  • 4,287
4 votes
Accepted

Is it OK to use the reset flag with every Truffle compile and migrate when using the TestRPC client?

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 ...
Ismael's user avatar
  • 30.3k
4 votes

How to re-compile contracts using truffle which are updated?

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 ...
Dibi91's user avatar
  • 151
3 votes
Accepted

Truffle will not compile contract written in VS code. Pragma error

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 ...
Greg Jeanmart's user avatar
3 votes

Is it safe to commit truffle build files to Github (open source)?

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. ...
Lauri Peltonen's user avatar
3 votes
Accepted

Truffle compile fails: could not find file from any sources

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.
Adam Schmideg's user avatar
3 votes

Unused function parameter. Remove or comment out the variable name to silence this warning

Sometimes you will want to override a function provided by a library e.g. this ERC721._beforeTokenTransfer hook. Suppose that you want to override this hook to prevent a specific token 12345 from ...
dwardu's user avatar
  • 1,298
3 votes
Accepted

TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address"

You just need to change a few more of type address to be address payable. Namely here: struct Document { address requester; address verifier; string name; string description; ...
Lauri Peltonen's user avatar
3 votes

TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address"

You can declare the transfer_address as payable like, payable(transfer_address).transfer(address(this).balance); where transfer_address is the sender's address(msg.sender).
Gargi Kantesaria's user avatar
3 votes
Accepted

Set specific compiler version in truffle but still get "Source file requires different compiler version" error

I went through this error recently. This is happening because the compiler version configured on VS Code workspace is different from the version you want. To fix that just right click on the error and ...
Eduardo Wronscki's user avatar
3 votes

Error with "truffle compile" - Could not find a compiler version matching

It's an answer after half a year, but I thought I'd post it here for the benefits of other beginners. I just experienced similar issue in my Mac and after some research I found out it's because it's ...
Lee's user avatar
  • 131
2 votes

Getting async/await to work in truffle JS tests

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 ...
Pavel's user avatar
  • 228
2 votes

How to import a smart contract on github in a truffle contract?

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 ...
pabloruiz55's user avatar
  • 7,546
2 votes

How to import a smart contract on github in a truffle contract?

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 ...
rhlsthrm's user avatar
  • 425
2 votes

Truffle Compile on Windows "Could not find a suitable configuration file"

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 ...
farhankhwaja's user avatar
2 votes
Accepted

failure to verify truffle compiled contract on ropsten.etherscan.io

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....
Qkyrie's user avatar
  • 552
2 votes
Accepted

Solidity Array Element Access

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).
ivicaa's user avatar
  • 7,459
2 votes
Accepted

ParserError: Expected identifier, got 'LParen'

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:...
Inn0vative1's user avatar
2 votes
Accepted

DeclarationError: Identifier not found or not unique when deploying a facotry contract

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. ...
Rob Hitchens's user avatar
  • 54.3k

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